Cascade

Struct Cascade 

Source
pub struct Cascade<S: Refineable>(/* private fields */);
Expand description

A cascade of refinements that can be merged in priority order.

A cascade maintains a sequence of optional refinements where later entries take precedence over earlier ones. The first slot (index 0) is always the base refinement and is guaranteed to be present.

This is useful for implementing configuration hierarchies like CSS cascading, where styles from different sources (user agent, user, author) are combined with specific precedence rules.

Implementations§

Source§

impl<S: Refineable + Default> Cascade<S>

Source

pub fn reserve(&mut self) -> CascadeSlot

Reserves a new slot in the cascade and returns a handle to it.

The new slot is initially empty (None) and can be populated later using set().

Source

pub fn base(&mut self) -> &mut S::Refinement

Returns a mutable reference to the base refinement (slot 0).

The base refinement is always present and serves as the foundation for the cascade.

Source

pub fn set(&mut self, slot: CascadeSlot, refinement: Option<S::Refinement>)

Sets the refinement for a specific slot in the cascade.

Setting a slot to None effectively removes it from consideration during merging.

Source

pub fn merged(&self) -> S::Refinement

Merges all refinements in the cascade into a single refinement.

Refinements are applied in order, with later slots taking precedence. Empty slots (None) are skipped during merging.

Trait Implementations§

Source§

impl<S: Refineable + Default> Default for Cascade<S>

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl<S> Freeze for Cascade<S>

§

impl<S> RefUnwindSafe for Cascade<S>

§

impl<S> Send for Cascade<S>
where <S as Refineable>::Refinement: Send,

§

impl<S> Sync for Cascade<S>
where <S as Refineable>::Refinement: Sync,

§

impl<S> Unpin for Cascade<S>
where <S as Refineable>::Refinement: Unpin,

§

impl<S> UnwindSafe for Cascade<S>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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 T
where 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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.