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§
Sourcefn is_present(&self) -> bool
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.
Sourcefn into_view_parts(self, cx: &Cx, parts: &mut PartsWriter<'_>)
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
impl ClassViewParts for &String
fn is_present(&self) -> bool
fn into_view_parts(self, cx: &Cx, parts: &mut PartsWriter<'_>)
Source§impl ClassViewParts for &str
impl ClassViewParts for &str
fn is_present(&self) -> bool
fn into_view_parts(self, _cx: &Cx, parts: &mut PartsWriter<'_>)
Source§impl ClassViewParts for Cow<'static, str>
impl ClassViewParts for Cow<'static, str>
fn is_present(&self) -> bool
fn into_view_parts(self, _cx: &Cx, parts: &mut PartsWriter<'_>)
Source§impl ClassViewParts for String
impl ClassViewParts for String
fn is_present(&self) -> bool
fn into_view_parts(self, _cx: &Cx, parts: &mut PartsWriter<'_>)
Source§impl<T> ClassViewParts for Option<T>where
T: ClassViewParts,
impl<T> ClassViewParts for Option<T>where
T: ClassViewParts,
fn is_present(&self) -> bool
fn into_view_parts(self, cx: &Cx, parts: &mut PartsWriter<'_>)
Implementors§
impl ClassViewParts for &ViewPart
impl ClassViewParts for ViewPart
An attribute value, such as one taken from an
Attributes collection with
get, spliced in as a single entry.