Skip to content

Commit 7972a00

Browse files
committed
Update linked_list.rs
Removed an unnecessary `transmute` and replaced some code with an equivalent method.
1 parent 8f209d5 commit 7972a00

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/libcollections/linked_list.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,16 +107,14 @@ impl<T> Rawlink<T> {
107107
/// Convert the `Rawlink` into an Option value
108108
fn resolve_immut<'a>(&self) -> Option<&'a T> {
109109
unsafe {
110-
mem::transmute(self.p.as_ref())
110+
self.p.as_ref()
111111
}
112112
}
113113

114114
/// Convert the `Rawlink` into an Option value
115115
fn resolve<'a>(&mut self) -> Option<&'a mut T> {
116-
if self.p.is_null() {
117-
None
118-
} else {
119-
Some(unsafe { mem::transmute(self.p) })
116+
unsafe {
117+
self.p.as_mut()
120118
}
121119
}
122120

0 commit comments

Comments
 (0)