pub trait HeadTail: AsRef<str> {
// Provided methods
fn head(&self, len: usize) -> &str { ... }
fn head_dot(&self, len: usize) -> String { ... }
fn tail(&self, len: usize) -> &str { ... }
fn tail_dot(&self, len: usize) -> String { ... }
fn head_tail(&self, head: usize, tail: usize) -> String { ... }
}Expand description
Head/Tail characters of a str
This trait provides some functionality for
cutting off a string either by the head, tail,
or both, with optional ... after/before/in-between.
Anything that implements AsRef<str> can use this trait.
Provided Methods§
sourcefn head_dot(&self, len: usize) -> String
fn head_dot(&self, len: usize) -> String
Same as HeadTail::head() but the String ends with ...
This will return the full string without ... if
the len is longer than the actual inner str.
Note
Input is split by char’s, not bytes.