Skip to main content

Classes

Struct Classes 

Source
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_slice borrows a &'a [&'a str] directly — used by NodeRef, it is zero-allocation (a compile-time guarantee when the source is &'static str).
  • Classes::from_vec owns a Vec<&'a str> — used by OwnedNode, it costs one Vec allocation per call (acceptable; the hot path uses NodeRef).

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>

Source

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.

Source

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.

Source

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].

Source

pub fn contains(&self, name: &str) -> bool

Whether name is present (case-sensitive).

Source

pub fn is_empty(&self) -> bool

Source

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> 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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
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.