pub struct TempInst<'a, T: TempRepr + 'a>(/* private fields */);Expand description
A wrapper around an instance of T which implements TempRepr, i.e. is a temporary
representation of a type T::Shared<'a>.
TempInst itself has a lifetime parameter 'a and borrows the object passed to
TempInst::new for that lifetime; therefore it is logically equivalent to T::Shared<'a>.
However, it can hand out references to the lifetime-less type T via its Deref
implementation.
See the module documentation for usage examples.
Implementations§
Source§impl<'a, T: TempRepr> TempInst<'a, T>
impl<'a, T: TempRepr> TempInst<'a, T>
Sourcepub fn new(obj: T::Shared<'a>) -> Self
pub fn new(obj: T::Shared<'a>) -> Self
Creates a TempInst from an instance of T::Shared. Note that T::Shared is always the
non-mutable variant of T; e.g. even if T is TempRefMut<X>, T::Shared is &X, not
&mut X.
A shared reference to T can be obtained from the result via Deref.
Sourcepub fn call_with<R>(obj: T::Shared<'a>, f: impl FnOnce(&T) -> R) -> R
pub fn call_with<R>(obj: T::Shared<'a>, f: impl FnOnce(&T) -> R) -> R
Calls f with a shared reference to T which is constructed from obj, and returns the
value returned by f.
This method exists for consistency (with respect to TempInstMut::call_with), but is
actually just a trivial application of Self::new and Deref::deref.
Trait Implementations§
Source§impl<'a, T: Ord + TempRepr + 'a> Ord for TempInst<'a, T>
impl<'a, T: Ord + TempRepr + 'a> Ord for TempInst<'a, T>
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl<'a, T: PartialOrd + TempRepr + 'a> PartialOrd for TempInst<'a, T>where
T::Shared<'a>: PartialOrd,
impl<'a, T: PartialOrd + TempRepr + 'a> PartialOrd for TempInst<'a, T>where
T::Shared<'a>: PartialOrd,
impl<'a, T: Copy + TempRepr + 'a> Copy for TempInst<'a, T>
impl<'a, T: Eq + TempRepr + 'a> Eq for TempInst<'a, T>
impl<'a, T: TempRepr + 'a> StructuralPartialEq for TempInst<'a, T>
Auto Trait Implementations§
impl<'a, T> Freeze for TempInst<'a, T>where
T: Freeze,
impl<'a, T> RefUnwindSafe for TempInst<'a, T>
impl<'a, T> Send for TempInst<'a, T>
impl<'a, T> Sync for TempInst<'a, T>
impl<'a, T> Unpin for TempInst<'a, T>
impl<'a, T> UnwindSafe for TempInst<'a, T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more