Enum style::properties::StyleStructRef
source · pub enum StyleStructRef<'a, T: 'static> {
Borrowed(&'a BuilderArc<T>),
Owned(UniqueArc<T>),
Vacated,
}
Expand description
A reference to a style struct of the parent, or our own style struct.
Variants§
Borrowed(&'a BuilderArc<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.