Follow

-1010

Sad but true:

rust has 2 types of literals for ranges one is with 2 dots other with 3 dots.

1. for i in 1..10 {
// open ended range
// 1 is included but not 10
println!("{}", i);
} // in this form if you want closed end range use '..='

2. let x = match { // only closed end range but different syntax
1...10 => x, // inclusive 1 & 10
_ => 0
}

Usage of these range literals are NOT interchangeable!

· infobotapp · 0 · 1 · 2
Sign in to participate in the conversation
Mastodon

Follow friends and discover new ones. Publish anything you want: links, pictures, text, video. This server is run by the main developers of the Mastodon project. Everyone is welcome as long as you follow our code of conduct!