pub const fn find_keep<'a, 'p, P>(this: &'a str, needle: P) -> Option<&'a str>where
P: Pattern<'p>,
Expand description
Advances this
up to the first instance of needle
.
Returns None
if no instance of needle
is found.
Returns Some(this)
if needle
is empty.
This takes Pattern
implementors as the needle.
ยงExample
use konst::string;
{
const FOUND: Option<&str> = string::find_keep("foo-bar-baz", '-');
assert_eq!(FOUND, Some("-bar-baz"));
}
{
const FOUND: Option<&str> = string::find_keep("foo bar baz", "bar");
assert_eq!(FOUND, Some("bar baz"));
}
{
const NOT_FOUND: Option<&str> = string::find_keep("foo bar baz", "qux");
assert_eq!(NOT_FOUND, None);
}