Editor's note: As of Rust 1.43, this works as expected.
I have a type alias type CardId = u64; and I want to initialize it to the maximum number it can have through the std::u64::MAX constant. And was surprised to learn that I cannot do the same from the alias.
use std::u64;
type CardId = u64;
fn main() {
let this_works = u64::MAX;
let this_doesnt_work = CardId::MAX;
println!("Max amount in integer: {} and {}", this_works, this_doesnt_work);
}
I was expecting the MAX constant to be accessible from the type alias also. This would aid me when I would change the type to u32, and this causes the code to have two points where I would need to modify instead of just location of the type alias. Why was this decision made, and did I miss something which which maybe would make this possible?