pub trait SplitToBoundary {
// Required methods
fn split_to_boundary(&self, boundary: usize) -> Vec<&str>;
fn split_to_offset(&self, offset: usize) -> Vec<&str>;
fn split_all_to_boundary(&self, boundary: usize) -> Vec<&str>;
}
Required Methods§
fn split_to_boundary(&self, boundary: usize) -> Vec<&str>
fn split_to_offset(&self, offset: usize) -> Vec<&str>
fn split_all_to_boundary(&self, boundary: usize) -> Vec<&str>
Implementations on Foreign Types§
Source§impl SplitToBoundary for str
impl SplitToBoundary for str
Source§fn split_to_boundary(&self, boundary: usize) -> Vec<&str>
fn split_to_boundary(&self, boundary: usize) -> Vec<&str>
performs a ‘truncate_to_boundary’ and produces a vector with the rest of the string on the right side. This can be regarded as a left-side-split with unicode awareness trimming.
Source§fn split_to_offset(&self, offset: usize) -> Vec<&str>
fn split_to_offset(&self, offset: usize) -> Vec<&str>
performs a ‘truncate_to_byte_offset’ and produces a vector with the rest of the string on the right side. This can be regarded as a left-side-split with unicode awareness and trimming.
§Examples:
use truncrate::*;
let s = "🤚🏾a🤚 ";
assert_eq!(s.split_to_offset(7), vec!("", "🤚🏾a🤚 "));
assert_eq!(s.split_to_offset(8), vec!("🤚🏾", "a🤚 "));
Source§fn split_all_to_boundary(&self, boundary: usize) -> Vec<&str>
fn split_all_to_boundary(&self, boundary: usize) -> Vec<&str>
performs a ‘split_to_boundary’ until all of the string has been split properly. Also removes needless spaces and empty strings.
§Examples:
use truncrate::*;
let mut s = "🤚🏾a🤚 ";
assert_eq!(s.split_all_to_boundary(1), vec!("a", "🤚"));
assert_eq!(s.split_all_to_boundary(2), vec!("🤚🏾", "a🤚",));
Source§impl SplitToBoundary for Vec<&str>
impl SplitToBoundary for Vec<&str>
Source§fn split_to_boundary(&self, boundary: usize) -> Vec<&str>
fn split_to_boundary(&self, boundary: usize) -> Vec<&str>
performs a ‘split_to_boundary’ on the last element of a Vec<&str> thus adding another item to the list with the truncated string based on a character boundary.