pub enum StyleStructRef<'a, T: 'static> {
Borrowed(&'a T),
Owned(UniqueArc<T>),
Vacated,
}Expand description
A reference to a style struct of the parent, or our own style struct.
Variants§
Borrowed(&'a T)
A borrowed struct from the parent, for example, for inheriting style.
Owned(UniqueArc<T>)
An owned struct, that we’ve already mutated.
Vacated
Temporarily vacated, will panic if accessed
Implementations§
Source§impl<'a, T> StyleStructRef<'a, T>where
T: Clone + 'a,
impl<'a, T> StyleStructRef<'a, T>where
T: Clone + 'a,
Sourcepub fn mutate(&mut self) -> &mut T
pub fn mutate(&mut self) -> &mut T
Ensure a mutable reference of this value exists, either cloning the borrowed value, or returning the owned one.
Sourcepub fn ptr_eq(&self, struct_to_copy_from: &T) -> bool
pub fn ptr_eq(&self, struct_to_copy_from: &T) -> bool
Whether this is pointer-equal to the struct we’re going to copy the value from.
This is used to avoid allocations when people write stuff like font: inherit or such all: initial.
Sourcepub fn take(&mut self) -> UniqueArc<T>
pub fn take(&mut self) -> UniqueArc<T>
Extract a unique Arc from this struct, vacating it.
The vacated state is a transient one, please put the Arc back
when done via put(). This function is to be used to separate
the struct being mutated from the computed context
Sourcepub fn get_if_mutated(&mut self) -> Option<&mut T>
pub fn get_if_mutated(&mut self) -> Option<&mut T>
Get a mutable reference to the owned struct, or None if the struct
hasn’t been mutated.
Trait Implementations§
Auto Trait Implementations§
impl<'a, T> Freeze for StyleStructRef<'a, T>
impl<'a, T> RefUnwindSafe for StyleStructRef<'a, T>where
T: RefUnwindSafe,
impl<'a, T> Send for StyleStructRef<'a, T>
impl<'a, T> Sync for StyleStructRef<'a, T>
impl<'a, T> Unpin for StyleStructRef<'a, T>where
T: Unpin,
impl<'a, T> UnwindSafe for StyleStructRef<'a, T>where
T: RefUnwindSafe + 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
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