This create provides weak pointers for
Pin<std::rc::Arc<T>> cannot be converted safely to
Weak<T> equivalent if
T does not implement
That's because it would otherwise be possible to do something like this:
; let pinned = pin; // This is unsafe ... let weak = unsafe ; // ... because otherwise it would be possible to move the content of pinned: let mut unpinned_rc = weak.upgrade.unwrap; drop; // unpinned_rc is now the only reference so this will work: let x = replace;
In that example,
x is the original
SomeStruct which we moved in memory,
that is undefined behavior, do not do that at home.
This crate simply provide a
sync::PinWeak which allow to
get weak pointer from
This is safe because you can one can only get back a
Pin out of it when
trying to upgrade the weak pointer.
PinWeak can be created using the
PinWeak downgrade function.
use *; ; let pinned = pin; let weak = downgrade; assert_eq!; drop; assert!;