konst::string

Function find_skip

Source
pub const fn find_skip<'a, 'p, P>(this: &'a str, needle: P) -> Option<&'a str>
where P: Pattern<'p>,
Expand description

Advances this past 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_skip("foo bar baz", ' ');
    assert_eq!(FOUND, Some("bar baz"));
}

{
    const FOUND: Option<&str> = string::find_skip("foo bar baz", "bar");
    assert_eq!(FOUND, Some(" baz"));
}
{
    const NOT_FOUND: Option<&str> = string::find_skip("foo bar baz", "qux");
    assert_eq!(NOT_FOUND, None);
}