Skip to main content

Split

Trait Split 

Source
pub trait Split:
    Send
    + Sync
    + 'static {
    // Required methods
    fn split_once<'s>(&self, haystack: &'s str) -> Option<(&'s str, &'s str)>;
    fn split<'s>(&self, haystack: &'s str) -> impl Iterator<Item = &'s str>;
}
Expand description

Pattern usable for splitting strings. Used in Delimited and DelimitedEntries deserializers.

§Standard implementations

  • &str: matches a string exactly
  • [char; _]: matches any of the chars
  • LazyRegex: matches a regular expression

Required Methods§

Source

fn split_once<'s>(&self, haystack: &'s str) -> Option<(&'s str, &'s str)>

Splits the given haystack at most once from its start. This generalizes str::split_once().

Source

fn split<'s>(&self, haystack: &'s str) -> impl Iterator<Item = &'s str>

Splits the given haystack. This generalizes str::split().

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl Split for &'static str

Source§

fn split_once<'s>(&self, haystack: &'s str) -> Option<(&'s str, &'s str)>

Source§

fn split<'s>(&self, haystack: &'s str) -> impl Iterator<Item = &'s str>

Source§

impl<const N: usize> Split for [char; N]

Source§

fn split_once<'s>(&self, haystack: &'s str) -> Option<(&'s str, &'s str)>

Source§

fn split<'s>(&self, haystack: &'s str) -> impl Iterator<Item = &'s str>

Implementors§

Source§

impl<T> Split for &'static LazyRegex<T>
where T: Deref<Target = Regex> + Send + Sync,