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>
impl<S: Refineable + Default> Cascade<S>
Sourcepub fn reserve(&mut self) -> CascadeSlot
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().
Sourcepub fn base(&mut self) -> &mut S::Refinement
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.
Sourcepub fn set(&mut self, slot: CascadeSlot, refinement: Option<S::Refinement>)
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.
Sourcepub fn merged(&self) -> S::Refinement
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.