Function rfind_and_count

Source
pub fn rfind_and_count(source: &str, char: char) -> usize
Expand description

Count number of characters since the last occurrence of char.

Finds last occurrence of char in source, returns number of characters from that last occurrence. If char is not found, return number of characters total.

assert_eq!(rfind_and_count("abcde", 'e'), 0);
assert_eq!(rfind_and_count("abcde", 'b'), 3);
assert_eq!(rfind_and_count("abcde", 'z'), 5);