pub trait Len {
// Required method
fn len(&self) -> usize;
// Provided method
fn is_empty(&self) -> bool { ... }
}
Expand description
Basic trait for anything that could have a length.
Even if a lot of struct have a len()
method in the standard library,
to my knowledge this function is not included into any standard trait.