pub const fn split_once<'a>(
this: &'a str,
delim: &str,
) -> Option<(&'a str, &'a str)>
Expand description
A const-equivalent of the str::split_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::split_once("", "-"), None);
assert_eq!(string::split_once("foo", "-"), None);
assert_eq!(string::split_once("foo-", "-"), Some(("foo", "")));
assert_eq!(string::split_once("foo-bar", "-"), Some(("foo", "bar")));
assert_eq!(string::split_once("foo-bar-baz", "-"), Some(("foo", "bar-baz")));