Some string constants

Perhaps I’ve already asked in past. In the Python std lib there’s the ‘string’ module:

It contains some constants:


Is it a good idea to add such constants to rust stdlib too?

Currently you could generate them like this in user code:

let ascii_lowercase: String = (b'a' ..= b'z').map(char::from).collect();
let ascii_uppercase: String = (b'A' ..= b'Z').map(char::from).collect();
let ascii_letters = ascii_lowercase + &ascii_uppercase;
let digits: String = (b'0' ..= b'9').map(char::from).collect();

i think this is left out for the same reason that date formatting is left out of the standard library and to external crates: for some purposes one might want to make the definition of lowercase/uppercase depend on the locale, for others it needs to be deterministic, just too many variations and interpretation—why would ASCII be special?

The standard library does have corresponding methods like is_ascii_lowercase.

oh! yes then it’s arguably a small step to exposing them in some other way

What would you use them for? When are they better than the ranges, or the predicates that already exist?