pub struct Borrowed<B> { /* private fields */ }Expand description
A type generated by Holder that wraps a value in it shallowly.
This struct implements Deref and DerefMut for the inner value so
that clients can use this struct like the inner value.
If check feature is enabled, this struct tracks borrow status at runtime,
and will warn you if borrow rule was violated.
Implementations§
Source§impl<B> Borrowed<B>
impl<B> Borrowed<B>
Sourcepub fn map<T>(self, f: impl FnOnce(B) -> T) -> Borrowed<T>
pub fn map<T>(self, f: impl FnOnce(B) -> T) -> Borrowed<T>
Converts inner value through the given function while maintaining borrow state.
§Examples
use my_ecs::ds::Holder;
let holder = unsafe { Holder::new(0, |v| v, |v| v) };
let value = holder.borrow().unwrap();
let value = value.map(|v| v.to_string());Trait Implementations§
Auto Trait Implementations§
impl<B> Freeze for Borrowed<B>where
B: Freeze,
impl<B> RefUnwindSafe for Borrowed<B>where
B: RefUnwindSafe,
impl<B> Send for Borrowed<B>where
B: Send,
impl<B> Sync for Borrowed<B>where
B: Sync,
impl<B> Unpin for Borrowed<B>where
B: Unpin,
impl<B> UnwindSafe for Borrowed<B>where
B: UnwindSafe,
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> 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 more