konst::string

Function find

Source
pub const fn find<'a, P>(left: &str, pat: P) -> Option<usize>
where P: Pattern<'a>,
Expand description

A const equivalent of str::find , taking a Pattern parameter.

ยงExample

use konst::string;

assert_eq!(string::find("foo-bar-baz", 'q'), None);
assert_eq!(string::find("foo-bar-baz", '-'), Some(3));

assert_eq!(string::find("foo-bar-baz-foo", "qux"), None);
assert_eq!(string::find("foo-bar-baz-foo", "foo"), Some(0));
assert_eq!(string::find("foo-bar-baz-foo-bar", "bar"), Some(4));
assert_eq!(string::find("foo-the-baz-foo-bar", "bar"), Some(16));