Function rsplit_once

Source
pub const fn rsplit_once<'a>(
    this: &'a str,
    delim: &str,
) -> Option<(&'a str, &'a str)>
Expand description

A const-equivalent of the str::rsplit_once method.

This only accepts &str as the delimiter.

§Version compatibility

This requires the "rust_1_64" feature.

§Example

use konst::string;

assert_eq!(string::rsplit_once("", "-"), None);
assert_eq!(string::rsplit_once("foo", "-"), None);
assert_eq!(string::rsplit_once("foo-", "-"), Some(("foo", "")));
assert_eq!(string::rsplit_once("foo-bar", "-"), Some(("foo", "bar")));
assert_eq!(string::rsplit_once("foo-bar-baz", "-"), Some(("foo-bar", "baz")));