Struct stylecs::Style

source ·
pub struct Style { /* private fields */ }
Expand description

A set of style components.

Implementations§

source§

impl Style

source

pub fn new() -> Self

Returns a new style with no components.

source

pub fn with_capacity(capacity: usize) -> Self

Returns a new style with enough capacity to hold capacity components without reallocting.

source

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.

source

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.

source

pub fn get<T: StyleComponent>(&self) -> Option<&T>

Returns the style component of type T, if present.

source

pub fn get_by_name(&self, name: &Name) -> Option<&AnyComponent>

Returns the style component of type T, if present.

source

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.

source

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.

source

pub fn inherited_from(self, parent: &Self) -> Self

Returns a new Style, merging the components of self with other only when the component is inherited.

source

pub fn len(&self) -> usize

Returns the number of components in this style.

source

pub fn is_empty(&self) -> bool

Returns true if this style has no components.

source

pub fn iter(&self) -> Iter<'_>

Returns an iterator over the elements in this style.

Trait Implementations§

source§

impl Clone for Style

source§

fn clone(&self) -> Style

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Style

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Style

source§

fn default() -> Style

Returns the “default value” for a type. Read more
source§

impl<'a> IntoIterator for &'a Style

§

type IntoIter = Iter<'a>

Which kind of iterator are we turning this into?
§

type Item = &'a AnyComponent

The type of the elements being iterated over.
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl IntoIterator for Style

§

type IntoIter = IntoIter

Which kind of iterator are we turning this into?
§

type Item = AnyComponent

The type of the elements being iterated over.
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more

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> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.