File tree Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -1675,7 +1675,14 @@ impl<T> Weak<T> {
16751675 pub fn new ( ) -> Weak < T > {
16761676 Weak { ptr : NonNull :: new ( usize:: MAX as * mut RcBox < T > ) . expect ( "MAX is not 0" ) }
16771677 }
1678+ }
16781679
1680+ pub ( crate ) fn is_dangling < T : ?Sized > ( ptr : NonNull < T > ) -> bool {
1681+ let address = ptr. as_ptr ( ) as * mut ( ) as usize ;
1682+ address == usize:: MAX
1683+ }
1684+
1685+ impl < T : ?Sized > Weak < T > {
16791686 /// Returns a raw pointer to the object `T` pointed to by this `Weak<T>`.
16801687 ///
16811688 /// The pointer is valid only if there are some strong references. The pointer may be dangling,
@@ -1808,14 +1815,7 @@ impl<T> Weak<T> {
18081815 }
18091816 }
18101817 }
1811- }
18121818
1813- pub ( crate ) fn is_dangling < T : ?Sized > ( ptr : NonNull < T > ) -> bool {
1814- let address = ptr. as_ptr ( ) as * mut ( ) as usize ;
1815- address == usize:: MAX
1816- }
1817-
1818- impl < T : ?Sized > Weak < T > {
18191819 /// Attempts to upgrade the `Weak` pointer to an [`Rc`], delaying
18201820 /// dropping of the inner value if successful.
18211821 ///
You can’t perform that action at this time.
0 commit comments