Splitable

Trait Splitable 

Source
pub trait Splitable<'a, T> {
    // Required method
    fn split(
        &'a self,
        pattern: T,
    ) -> Box<dyn Iterator<Item = Split<Self, Self>> + 'a>
       where Self: Sized;
}
Expand description

Text objects that can be split on a delimiter or pattern

Required Methods§

Source

fn split( &'a self, pattern: T, ) -> Box<dyn Iterator<Item = Split<Self, Self>> + 'a>
where Self: Sized,

Split a text object on the given pattern.

§Example
use stylish_stringlike::text::{Split, Splitable};
let path = String::from("/Some/complicated/path");
let mut split = Splitable::<&str>::split(&path, "/");
assert_eq!(
    Some(Split {
        delim: Some(String::from("/")),
        segment: None,
    }),
    split.next()
);
assert_eq!(
    Some(Split {
        delim: Some(String::from("/")),
        segment: Some(String::from("Some"))
    }),
    split.next()
);
assert_eq!(
    Some(Split {
        delim: Some(String::from("/")),
        segment: Some(String::from("complicated"))
    }),
    split.next()
);
assert_eq!(
    Some(Split {
        delim: None,
        segment: Some(String::from("path"))
    }),
    split.next()
);

Implementors§

Source§

impl<'a, T> Splitable<'a, &'a str> for T
where T: Sliceable + RawText,