konst::string

Function rsplit_terminator

Source
pub const fn rsplit_terminator<'a, 'p, P>(
    this: &'a str,
    delim: P,
) -> RSplitTerminator<'a, 'p, P>
where P: Pattern<'p>,
Expand description

Const equivalent of str::rsplit_terminator.

This does the same as rsplit, except that, if the string before the first 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::rsplit_terminator(":foo:bar:baz", ":")
);

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