Expand description
Length-based rules for strings, slices, and other measurable values.
Each rule here works on any type that implements HasLength. The crate
ships impls for str and [T] (always), and for String and Vec<T> when
the alloc feature is enabled, plus a blanket impl for shared references so a
rule applies equally to str and &str.
For strings, “length” is the number of chars (Unicode scalar values), not
the number of bytes — the count a human means by “at most 20 characters”. For
slices and vectors it is the number of elements.
Structs§
- LenRange
- Accepts values whose length is in the inclusive range
MIN..=MAX. - MaxLen
- Accepts values with at most
MAXelements (inclusive). - MinLen
- Accepts values with at least
MINelements (inclusive). - NonEmpty
- Accepts any value whose
lengthis greater than zero.
Traits§
- HasLength
- A value with a measurable length, used by the length rules.