pub struct Classes<'a> { /* private fields */ }Expand description
A borrowable view over an element’s class list.
Two representations back the same query surface:
Classes::from_sliceborrows a&'a [&'a str]directly — used byNodeRef, it is zero-allocation (a compile-time guarantee when the source is&'static str).Classes::from_vecowns aVec<&'a str>— used byOwnedNode, it costs oneVecallocation per call (acceptable; the hot path usesNodeRef).
Use as_slice for iteration (&[&str]) rather than
iter() so both representations unify behind a single concrete return
type.
Implementations§
Source§impl<'a> Classes<'a>
impl<'a> Classes<'a>
Sourcepub fn from_slice(slice: &'a [&'a str]) -> Self
pub fn from_slice(slice: &'a [&'a str]) -> Self
Zero-allocation view over a borrowed slice. The NodeRef path uses
this — when slice is &'static [&'static str] no heap allocation
occurs at any point.
Sourcepub fn from_vec(v: Vec<&'a str>) -> Self
pub fn from_vec(v: Vec<&'a str>) -> Self
Owning view built from an existing Vec<&str>. Used by OwnedNode
which stores Strings and must materialize &str borrows per call.
Sourcepub fn as_slice(&self) -> &[&'a str]
pub fn as_slice(&self) -> &[&'a str]
Unified read-only access to the underlying class names, regardless of
representation. Prefer this over an iter() — both reprs return the
same concrete &[&str].
pub fn is_empty(&self) -> bool
pub fn len(&self) -> usize
Auto Trait Implementations§
impl<'a> Freeze for Classes<'a>
impl<'a> RefUnwindSafe for Classes<'a>
impl<'a> Send for Classes<'a>
impl<'a> Sync for Classes<'a>
impl<'a> Unpin for Classes<'a>
impl<'a> UnsafeUnpin for Classes<'a>
impl<'a> UnwindSafe for Classes<'a>
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
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>
Converts
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>
Converts
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