Update linked_list.rs

Removed an unnecessary `transmute` and replaced some code with an equivalent method.
This commit is contained in:
Jexell 2015-06-03 16:14:35 +01:00
parent 8f209d5a3e
commit 7972a000e3

View File

@ -107,16 +107,14 @@ impl<T> Rawlink<T> {
/// Convert the `Rawlink` into an Option value
fn resolve_immut<'a>(&self) -> Option<&'a T> {
unsafe {
mem::transmute(self.p.as_ref())
self.p.as_ref()
}
}
/// Convert the `Rawlink` into an Option value
fn resolve<'a>(&mut self) -> Option<&'a mut T> {
if self.p.is_null() {
None
} else {
Some(unsafe { mem::transmute(self.p) })
unsafe {
self.p.as_mut()
}
}