Function konst::string::split_terminator

source ·
pub const fn split_terminator<'a, 'p, P>(
    this: &'a str,
    delim: P,
) -> SplitTerminator<'a, 'p, P>
where P: Pattern<'p>,
Expand description

Const equivalent of str::split_terminator, which only takes a &str delimiter.

This does the same as split, except that, if the string after the last delimiter is empty, it is skipped.

This takes Pattern implementors as the delimiter.

§Example

use konst::string;
use konst::iter::collect_const;

const STRS: [&str; 3] = collect_const!(&str =>  
    string::split_terminator("foo,bar,baz,", ',')
);

assert_eq!(STRS, ["foo", "bar", "baz"]);