What is the difference between `...` and `..=`?

fn main() {
    let x = 5;

    match x {
        1..=5 => println!("one through five"),
        _ => println!("something else"),
    }
}
fn main() {
    let x = 5;

    match x {
        1...5 => println!("one through five"),
        _ => println!("something else"),
    }
}

When I saw the official tutorial, some people wrote ... and others wrote .. = . What is the difference between them? I am confused? Current observations have found that there are warnings when using ... , so when should you use ... ? Pattern Syntax - The Rust Programming Language
Pattern Syntax - The Rust Programming Language

They are the same, but ... looks too similar to .. (which will/might eventually be stabilized for a non-inclusive range pattern), so it’s deprecated.

3 Likes

The answer is to always use ..= over ....

3 Likes

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.