check if a string contains consecutive letters that occur only once

You can check if a string contains consecutive letters that occur only once in Rust by iterating over the characters of the string and comparing each character with the previous one. Here's an example code snippet that demonstrates this:

fn contains_consecutive_unique_letters(s: &str) -> bool {
    let mut prev_char: Option<char> = None;

    for c in s.chars() {
        if let Some(prev) = prev_char {
            if c == prev {
                return false;
            }
        }
        prev_char = Some(c);
    }

    true
}

fn main() {
    let s1 = "hello";
    let s2 = "world";
    let s3 = "goodbye";

    println!("s1 contains consecutive unique letters: {}", contains_consecutive_unique_letters(s1));
    println!("s2 contains consecutive unique letters: {}", contains_consecutive_unique_letters(s2));
    println!("s3 contains consecutive unique letters: {}", contains_consecutive_unique_letters(s3));
}

This code defines a function contains_consecutive_unique_letters that takes a string s as input and returns a boolean value indicating whether the string contains consecutive letters that occur only once. Inside the function, we iterate over the characters of the string using the chars method. We compare each character with the previous one using an if statement, and if they are the same, we return false. If the iteration completes without finding any consecutive repeated letters, we return true.

In the main function, we demonstrate the usage of the contains_consecutive_unique_letters function by checking three example strings: "hello", "world", and "goodbye". The results are printed using the println! macro.