longest_consecutive_values

Function longest_consecutive_values 

Source
pub fn longest_consecutive_values<T: PartialOrd>(
    arr: &[T],
    val: &T,
) -> Option<(usize, usize)>
Expand description

Searches the provided array for the longest consecutive repeated sequence of ‘val’.

§Example

let (position,length) = longest_consecutive_values(&[1,0,0,0,0,0,1,2,3,4,5,6], &0).unwrap();

assert_eq!(position, 1);
assert_eq!(length, 5);