[][src]Trait truncrate::SplitToBoundary

pub trait SplitToBoundary {
    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>

Loading content...

Implementations on Foreign Types

impl SplitToBoundary for str[src]

fn split_to_boundary(&self, boundary: usize) -> Vec<&str>[src]

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.

fn split_to_offset(&self, offset: usize) -> Vec<&str>[src]

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🤚 "));

fn split_all_to_boundary(&self, boundary: usize) -> Vec<&str>[src]

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🤚",));

impl<'_> SplitToBoundary for Vec<&'_ str>[src]

fn split_to_boundary(&self, boundary: usize) -> Vec<&str>[src]

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.

fn split_to_offset(&self, offset: usize) -> Vec<&str>[src]

performs a 'split_to_offset' on the last element of a Vec<&str> thus adding another item to the list with the truncated string based byte limitation.

fn split_all_to_boundary(&self, boundary: usize) -> Vec<&str>[src]

performs a split_all_to_boundary on the last element of a Vec<&str> thus performing a unicode aware split on of its strings, along with trimming and removal of empty strings.

Loading content...

Implementors

Loading content...