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.
Return the first len bytes of this str.
This will return the full str if the len is
longer than the actual inner str.
Input is split by char’s, not bytes.
Same as [head()] but the String ends with ...
This will return the full string without ... if
the len is longer than the actual inner str.
Input is split by char’s, not bytes.
Return the last len bytes of this str.
This will return the full str if the len is
longer than the actual inner str.
Input is split by char’s, not bytes.
Same as [tail()] but returns a String starting with ...
This will return the full string without ... if
the len is longer than the actual inner str.
Input is split by char’s, not bytes.
Return the first head bytes and last tail
bytes of this string separated with ....
Input is split by char’s, not bytes.