Skip to main content

AttrSet

Trait AttrSet 

Source
pub trait AttrSet {
    // Required method
    fn add_attrs(&self, attrs: &mut Attrs);
}
Expand description

Something that can contribute whole entries to an Attrs.

The seam a #[prop(rest)] field is filled through: attrs={…} written at a call site, {...expr} spread onto a component, and every positional entry of {@attrs(…)}. A set is read from a reference and folded in, rather than moved out of the component holding it.

Notably not implemented for strings. A string is markup, and this bag holds pairs it escapes one at a time; the diagnostic below is what the older attrs={r#"data-controller="signup""#} spelling now says, so a call site that still assembles markup is a build failure rather than a page that looks right until a value in it needs escaping.

Required Methods§

Source

fn add_attrs(&self, attrs: &mut Attrs)

Dyn Compatibility§

This trait is dyn compatible.

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

Implementations on Foreign Types§

Source§

impl<K: AsRef<str>, V: IntoAttrValue + Clone, S> AttrSet for HashMap<K, V, S>

Visited in key order rather than the map’s own, because a HashMap has no stable one — the same render would otherwise emit the same attributes in a different order each run, which no snapshot test or cache could live with.

Source§

fn add_attrs(&self, attrs: &mut Attrs)

Source§

impl<K: AsRef<str>, V: IntoAttrValue + Clone, const N: usize> AttrSet for [(K, V); N]

Source§

fn add_attrs(&self, attrs: &mut Attrs)

Source§

impl<K: AsRef<str>, V: IntoAttrValue + Clone> AttrSet for BTreeMap<K, V>

Source§

fn add_attrs(&self, attrs: &mut Attrs)

Source§

impl<K: AsRef<str>, V: IntoAttrValue + Clone> AttrSet for Vec<(K, V)>

Source§

fn add_attrs(&self, attrs: &mut Attrs)

Source§

impl<K: AsRef<str>, V: IntoAttrValue + Clone> AttrSet for [(K, V)]

Source§

fn add_attrs(&self, attrs: &mut Attrs)

Source§

impl<T: AttrSet + ?Sized> AttrSet for &T

Source§

fn add_attrs(&self, attrs: &mut Attrs)

Source§

impl<T: AttrSet> AttrSet for Option<T>

Source§

fn add_attrs(&self, attrs: &mut Attrs)

Implementors§