#[repr(transparent)]pub struct Ptr<T> { /* private fields */ }
Expand description
This type is a thin wrapper around T to enable cheap clone and comparisons. Internally it is an Arc that is compared by address instead of by the implementation of the pointed to value.
Additionally, Ptr implements Error where T: Error. This makes working with TryEventuals easier since many error types do not impl Value, but when wrapped in Ptr do.
One thing to be aware of is that because values are compared by address subscribers may be triggered unnecessarily in some contexts. If this is undesirable use Arc instead.
This type is not specifically Eventual related, but is a useful pattern.
Implementations
Trait Implementations
sourceimpl<T> Error for Ptr<T> where
T: Error,
impl<T> Error for Ptr<T> where
T: Error,
sourcefn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
The lower-level source of this error, if any. Read more
sourcefn backtrace(&self) -> Option<&Backtrace>
fn backtrace(&self) -> Option<&Backtrace>
backtrace
)Returns a stack backtrace, if available, of where this error occurred. Read more
1.0.0 · sourcefn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
sourceimpl<T> Ord for Ptr<T>
impl<T> Ord for Ptr<T>
sourceimpl<T> PartialOrd<Ptr<T>> for Ptr<T>
impl<T> PartialOrd<Ptr<T>> for Ptr<T>
sourcefn partial_cmp(&self, other: &Self) -> Option<Ordering>
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
impl<T> Eq for Ptr<T>
Auto Trait Implementations
impl<T> RefUnwindSafe for Ptr<T> where
T: RefUnwindSafe,
impl<T> Send for Ptr<T> where
T: Send + Sync,
impl<T> Sync for Ptr<T> where
T: Send + Sync,
impl<T> Unpin for Ptr<T>
impl<T> UnwindSafe for Ptr<T> where
T: RefUnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more