Skip to main content

ClassViewParts

Trait ClassViewParts 

Source
pub trait ClassViewParts {
    // Required methods
    fn is_present(&self) -> bool;
    fn into_view_parts(self, cx: &Cx, parts: &mut PartsWriter<'_>);
}
Expand description

Converts a value used as a class list entry into view parts.

When this trait is implemented on a type, it can be used as an entry in the class! macro or stored in a Class directly.

A class list separates its entries with single spaces. An absent entry must not produce a separator, so is_present is the hook that makes that decision: the built-in Option<T> implementation reports None as absent, and the string implementations report empty strings as absent.

Required Methods§

Source

fn is_present(&self) -> bool

Returns whether this value contributes to the class list.

An absent value is skipped entirely and does not produce a separating space.

Source

fn into_view_parts(self, cx: &Cx, parts: &mut PartsWriter<'_>)

Appends this value to the class list being built.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl ClassViewParts for &String

Source§

fn is_present(&self) -> bool

Source§

fn into_view_parts(self, cx: &Cx, parts: &mut PartsWriter<'_>)

Source§

impl ClassViewParts for &str

Source§

fn is_present(&self) -> bool

Source§

fn into_view_parts(self, _cx: &Cx, parts: &mut PartsWriter<'_>)

Source§

impl ClassViewParts for Cow<'static, str>

Source§

fn is_present(&self) -> bool

Source§

fn into_view_parts(self, _cx: &Cx, parts: &mut PartsWriter<'_>)

Source§

impl ClassViewParts for String

Source§

fn is_present(&self) -> bool

Source§

fn into_view_parts(self, _cx: &Cx, parts: &mut PartsWriter<'_>)

Source§

impl<T> ClassViewParts for Option<T>
where T: ClassViewParts,

Source§

fn is_present(&self) -> bool

Source§

fn into_view_parts(self, cx: &Cx, parts: &mut PartsWriter<'_>)

Implementors§

Source§

impl ClassViewParts for &ViewPart

Source§

impl ClassViewParts for ViewPart

An attribute value, such as one taken from an Attributes collection with get, spliced in as a single entry.

Source§

impl<T> ClassViewParts for Class<T>
where T: ClassEntries,