I wanted to create a vector with 'a'..'z' values (inclusive).
This doesn't compile:
let vec: Vec<char> = ('a'..'z'+1).collect();
What's the idiomatic way to have 'a'..'z'
?
I wanted to create a vector with 'a'..'z' values (inclusive).
This doesn't compile:
let vec: Vec<char> = ('a'..'z'+1).collect();
What's the idiomatic way to have 'a'..'z'
?
Inclusive range feature stabilised and released as part of version 1.26. Below is valid syntax for inclusive range
Rust 1.26
As of Rust 1.26, you can use "inclusive ranges":
Rust 1.0 through 1.25
You need to add one to your end value:
This will not work if you need to include all the values:
However, you cannot iterate over a range of characters:
See Why can't a range of char be collected? for solutions.
I would just specify the set of characters you are interested in: