ClassList

Enum ClassList 

Source
pub enum ClassList {
    Owned(Vec<Cow<'static, str>>),
    Static(&'static str),
    Const(&'static [&'static str]),
    Empty,
}
Expand description

Represents a collection of CSS classes applied to a DOM node.

Variants§

§

Owned(Vec<Cow<'static, str>>)

Owned storage for the list of classes.

§

Static(&'static str)

Single static class stored without allocation.

§

Const(&'static [&'static str])

Multiple static classes stored without allocation.

§

Empty

Explicit empty list of classes.

Implementations§

Source§

impl ClassList

Source

pub const fn is_empty(&self) -> bool

Returns true if the list contains no classes.

Source

pub const fn len(&self) -> usize

Returns the number of classes in the list.

Source

pub fn first(&self) -> Option<&str>

Returns the first class if present.

Source

pub fn get(&self, index: usize) -> Option<&str>

Gets a class at a specific index if it exists.

Source

pub fn get_mut(&mut self, index: usize) -> Option<&mut Cow<'static, str>>

Gets a mutable reference to a class at a specific index.

Source

pub fn reserve(&mut self, additional: usize)

Reserves capacity for additional classes when owned.

Source

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

Returns true if the class list contains the specified class name.

Source

pub fn push<S>(&mut self, class: S)
where S: Into<Cow<'static, str>>,

Pushes a class onto the list, ignoring empty entries.

Source

pub fn insert<S>(&mut self, index: usize, class: S)
where S: Into<Cow<'static, str>>,

Inserts a class at the specified position, ignoring empty entries.

Source

pub fn iter(&self) -> ClassListIter<'_>

Iterate over all classes in the list.

Trait Implementations§

Source§

impl Clone for ClassList

Source§

fn clone(&self) -> ClassList

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ClassList

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ClassList

Source§

fn default() -> ClassList

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

impl Extend<Cow<'static, str>> for ClassList

Source§

fn extend<T: IntoIterator<Item = Cow<'static, str>>>(&mut self, iter: T)

Extends a collection with the contents of an iterator. Read more
Source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Source§

impl From<&'static [&'static str]> for ClassList

Source§

fn from(value: &'static [&'static str]) -> Self

Converts to this type from the input type.
Source§

impl From<&'static str> for ClassList

Source§

fn from(value: &'static str) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<Cow<'static, str>>> for ClassList

Source§

fn from(value: Vec<Cow<'static, str>>) -> Self

Converts to this type from the input type.
Source§

impl<'a> IntoIterator for &'a ClassList

Source§

type Item = &'a str

The type of the elements being iterated over.
Source§

type IntoIter = ClassListIter<'a>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl PartialEq for ClassList

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.