pub struct SingletonRef<'a, 'slf, T, L, const IS_MUT: bool = false> { /* private fields */ }Expand description
A lightweight handle to a singleton that can be captured inside q!() closures.
Created via Singleton::by_ref(). When used
inside a q!() closure, resolves to a reference to the singleton’s value (&T) at runtime.
This type is Copy (required by q!() macro internals).
TODO(mingwei): https://github.com/hydro-project/stageleft/issues/73
Implementations§
Source§impl<'slf, T, L, const IS_MUT: bool> SingletonRef<'_, 'slf, T, L, IS_MUT>
impl<'slf, T, L, const IS_MUT: bool> SingletonRef<'_, 'slf, T, L, IS_MUT>
Sourcepub fn as_ref(&self) -> SingletonRef<'_, 'slf, T, L, false>
pub fn as_ref(&self) -> SingletonRef<'_, 'slf, T, L, false>
Converts this singleton into a shared (non-mut) SingletonRef.
Sourcepub fn as_mut(&self) -> SingletonRef<'_, 'slf, T, L, true>
pub fn as_mut(&self) -> SingletonRef<'_, 'slf, T, L, true>
Converts this singleton into an exclusive (mut) SingletonRef.
Trait Implementations§
Source§impl<T, L, const IS_MUT: bool> Clone for SingletonRef<'_, '_, T, L, IS_MUT>
impl<T, L, const IS_MUT: bool> Clone for SingletonRef<'_, '_, T, L, IS_MUT>
impl<T, L, const IS_MUT: bool> Copy for SingletonRef<'_, '_, T, L, IS_MUT>
Auto Trait Implementations§
impl<'a, 'slf, T, L, const IS_MUT: bool = false> !RefUnwindSafe for SingletonRef<'a, 'slf, T, L, IS_MUT>
impl<'a, 'slf, T, L, const IS_MUT: bool = false> !Send for SingletonRef<'a, 'slf, T, L, IS_MUT>
impl<'a, 'slf, T, L, const IS_MUT: bool = false> !Sync for SingletonRef<'a, 'slf, T, L, IS_MUT>
impl<'a, 'slf, T, L, const IS_MUT: bool = false> !UnwindSafe for SingletonRef<'a, 'slf, T, L, IS_MUT>
impl<'a, 'slf, T, L, const IS_MUT: bool> Freeze for SingletonRef<'a, 'slf, T, L, IS_MUT>
impl<'a, 'slf, T, L, const IS_MUT: bool> Unpin for SingletonRef<'a, 'slf, T, L, IS_MUT>where
L: Unpin,
impl<'a, 'slf, T, L, const IS_MUT: bool> UnsafeUnpin for SingletonRef<'a, 'slf, T, L, IS_MUT>
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
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> ⓘ
Converts
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> ⓘ
Converts
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 moreCreates a shared type from an unshared type.