Skip to content

Commit 75d76c8

Browse files
committed
Don't repeat yourself
1 parent 9144d51 commit 75d76c8

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

library/alloc/src/sync.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -2843,16 +2843,14 @@ impl<T: ?Sized, A: Allocator> Weak<T, A> {
28432843
/// (i.e., when this `Weak` was created by `Weak::new`).
28442844
#[inline]
28452845
fn inner(&self) -> Option<WeakInner<'_>> {
2846-
if is_dangling(self.ptr.as_ptr()) {
2846+
let ptr = self.ptr.as_ptr();
2847+
if is_dangling(ptr) {
28472848
None
28482849
} else {
28492850
// We are careful to *not* create a reference covering the "data" field, as
28502851
// the field may be mutated concurrently (for example, if the last `Arc`
28512852
// is dropped, the data field will be dropped in-place).
2852-
Some(unsafe {
2853-
let ptr = self.ptr.as_ptr();
2854-
WeakInner { strong: &(*ptr).strong, weak: &(*ptr).weak }
2855-
})
2853+
Some(unsafe { WeakInner { strong: &(*ptr).strong, weak: &(*ptr).weak } })
28562854
}
28572855
}
28582856

0 commit comments

Comments
 (0)