pub struct Style { /* private fields */ }
Expand description
A set of style components.
Implementations§
source§impl Style
impl Style
sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Returns a new style with enough capacity to hold capacity
components
without reallocting.
sourcepub fn push<T: DynamicComponent + Clone>(&mut self, component: T)
pub fn push<T: DynamicComponent + Clone>(&mut self, component: T)
Adds a component to this style. Any existing values of the same type will be replaced.
sourcepub fn with<T: DynamicComponent + Clone>(self, component: T) -> Self
pub fn with<T: DynamicComponent + Clone>(self, component: T) -> Self
Adds a component to the style and returns it. Any existing values of the same type will be replaced.
sourcepub fn get<T: StyleComponent>(&self) -> Option<&T>
pub fn get<T: StyleComponent>(&self) -> Option<&T>
Returns the style component of type T
, if present.
sourcepub fn get_by_name(&self, name: &Name) -> Option<&AnyComponent>
pub fn get_by_name(&self, name: &Name) -> Option<&AnyComponent>
Returns the style component of type T
, if present.
sourcepub fn get_or_default<T: StyleComponent + Default + Clone>(&self) -> T
pub fn get_or_default<T: StyleComponent + Default + Clone>(&self) -> T
Returns the style component of type T
. If not present, T::default()
will be returned.
sourcepub fn merged_with(self, other: &Self) -> Self
pub fn merged_with(self, other: &Self) -> Self
Returns a new Style
, merging the components of self
with other
.
If both self
and other
contain a value of the same type, the value
in self
will be used.
sourcepub fn inherited_from(self, parent: &Self) -> Self
pub fn inherited_from(self, parent: &Self) -> Self
Trait Implementations§
source§impl<'a> IntoIterator for &'a Style
impl<'a> IntoIterator for &'a Style
Auto Trait Implementations§
impl RefUnwindSafe for Style
impl Send for Style
impl Sync for Style
impl Unpin for Style
impl UnwindSafe for Style
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