DEV Community

Discussion on: Rust, Iterators, and Skill Regression

Collapse
 
yondrin profile image
Alex Doroshenko

Just my 50 cents, there's indeed a 3rd party library for things like that:

use itertools::Itertools;

fn has_double(s: &str) -> bool {
    s.chars().tuple_windows().any(|(a, b)| a == b)
}

Here's this code in playground

Collapse
 
rpalo profile image
Ryan Palo

Good to know, thank you!