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§
Sourcefn rusdantic_length(&self) -> usize
fn rusdantic_length(&self) -> usize
Return the length of this value (character count for strings, element count for collections).
Provided Methods§
Sourcefn rusdantic_length_unit(&self) -> &'static str
fn rusdantic_length_unit(&self) -> &'static str
Return the unit name for error messages (“characters” for strings, “items” for collections).