Skip to main content

HasLength

Trait HasLength 

Source
pub trait HasLength {
    // Required method
    fn rusdantic_length(&self) -> usize;

    // Provided method
    fn rusdantic_length_unit(&self) -> &'static str { ... }
}
Expand description

Trait for types that have a measurable length. Used by the length validator to work with both strings and collections.

Required Methods§

Source

fn rusdantic_length(&self) -> usize

Return the length of this value (character count for strings, element count for collections).

Provided Methods§

Source

fn rusdantic_length_unit(&self) -> &'static str

Return the unit name for error messages (“characters” for strings, “items” for collections).

Implementations on Foreign Types§

Source§

impl HasLength for &str

Source§

impl HasLength for String

Source§

impl<K: Ord, V> HasLength for BTreeMap<K, V>

Source§

impl<K: Hash + Eq, V> HasLength for HashMap<K, V>

Source§

impl<T> HasLength for LinkedList<T>

Source§

impl<T> HasLength for VecDeque<T>

Source§

impl<T> HasLength for Vec<T>

Source§

impl<T: Ord> HasLength for BTreeSet<T>

Source§

impl<T: Hash + Eq> HasLength for HashSet<T>

Implementors§