konst::string

Function rfind

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

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

ยงExample

use konst::string;

assert_eq!(string::rfind("bar-baz-baz", 'q'), None);
assert_eq!(string::rfind("bar-baz-baz", '-'), Some(7));

assert_eq!(string::rfind("bar-baz", "foo"), None);
assert_eq!(string::rfind("bar-baz-foo", "foo"), Some(8));
assert_eq!(string::rfind("foo-bar-baz", "foo"), Some(0));