Skip to content

Commit 2c1f472

Browse files
committed
Don't repeat yourself
1 parent 9144d51 commit 2c1f472

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

library/alloc/src/sync.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2843,14 +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).
28522853
Some(unsafe {
2853-
let ptr = self.ptr.as_ptr();
28542854
WeakInner { strong: &(*ptr).strong, weak: &(*ptr).weak }
28552855
})
28562856
}

0 commit comments

Comments
 (0)