Struct PinWeak

Source
pub struct PinWeak<T>(/* private fields */);
Expand description

Safe Pinned Weak references.

Pin<Arc<T>> can’t be converted to/from Weak safely, because there is know way to know if a given weak reference came from a pinned Arc. This wraps the weak reference in a new type so we know that it came from a pinned Arc.

There is a pin-weak crate that provides this for std::sync::Arc, but not for the one in the portable-atomic-utils crate.

Implementations§

Source§

impl<T> PinWeak<T>

Source

pub fn downgrade(this: Pin<Arc<T>>) -> Self

Downgrade an Pin<Arc<T>> into a PinWeak.

This would be easier to use if it could be added to Arc.

Source

pub fn upgrade(&self) -> Option<Pin<Arc<T>>>

Upgrade back to a Pin<Arc<T>>.

Auto Trait Implementations§

§

impl<T> Freeze for PinWeak<T>

§

impl<T> RefUnwindSafe for PinWeak<T>
where T: RefUnwindSafe,

§

impl<T> Send for PinWeak<T>
where T: Sync + Send,

§

impl<T> Sync for PinWeak<T>
where T: Sync + Send,

§

impl<T> Unpin for PinWeak<T>

§

impl<T> UnwindSafe for PinWeak<T>
where T: RefUnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.