pub enum MergeStrategy {
UnionConditions,
KeepSelf,
PanicOnConflict,
}Expand description
Strategy for handling token collisions in Classes::merge and
ClassesBuilder::with_merged.
The variants differ only in what happens on a token collision; non-overlapping entries are
appended in either case. UnionConditions is the Default and the
recommended choice when you do not have a specific reason to pick another: it never panics
(regardless of what the caller passes in) and never silently drops a caller-supplied
condition.
§Comparison with leptos-styles
Styles::merge in the sibling crate has a fixed override-with-fallback semantic
(theme-then-user-override layering). Classes::merge instead asks the caller to choose,
because classes have no values to “override” - the right behavior on collision depends entirely
on the caller’s intent.
Variants§
UnionConditions
On collision, replace self’s entry with one whose condition is the logical OR of both
sides. The token renders when either condition is active.
Does not preserve toggle-pair structure: if either side of the collision was a toggle half, the OR produces a well-defined condition for the merged entry, but the other half of any colliding toggle is left as an orphan flat entry.
KeepSelf
On collision, drop the entry from other and leave self’s entry unchanged. Useful when
self is a layered default that must win against override attempts. To get the opposite
direction (other wins), call other.merge(self, MergeStrategy::KeepSelf) - this yields
the same entry set with other’s conditions surviving collisions.
If a dropped entry was half of a toggle pair in other, the surviving half lands as a
regular flat entry under its own reactive condition - the toggle pair is not preserved as
a structural unit.
PanicOnConflict
Panic with the standard duplicate-class-token message on the first colliding entry from
other. The strictest option; equivalent to manually re-adding each entry of other into
self via add / add_reactive / add_toggle.
Only safe when both sides of the merge are under your own control. Avoid this strategy
for any merge that combines an arbitrary classes: Classes prop with internal classes:
a caller passing a colliding token would crash the component. Use
UnionConditions or KeepSelf there.
Trait Implementations§
Source§impl Clone for MergeStrategy
impl Clone for MergeStrategy
Source§fn clone(&self) -> MergeStrategy
fn clone(&self) -> MergeStrategy
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for MergeStrategy
impl Debug for MergeStrategy
Source§impl Default for MergeStrategy
impl Default for MergeStrategy
Source§fn default() -> MergeStrategy
fn default() -> MergeStrategy
Source§impl PartialEq for MergeStrategy
impl PartialEq for MergeStrategy
Source§fn eq(&self, other: &MergeStrategy) -> bool
fn eq(&self, other: &MergeStrategy) -> bool
self and other values to be equal, and is used by ==.impl Copy for MergeStrategy
impl Eq for MergeStrategy
impl StructuralPartialEq for MergeStrategy
Auto Trait Implementations§
impl Freeze for MergeStrategy
impl RefUnwindSafe for MergeStrategy
impl Send for MergeStrategy
impl Sync for MergeStrategy
impl Unpin for MergeStrategy
impl UnsafeUnpin for MergeStrategy
impl UnwindSafe for MergeStrategy
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more