3 ms·
I’m glad that domain-limited integer types are called out: I wish more languages had that. At the same time: there’s a reasonable practical argument that both
by woodruffw 3y ago
I’m glad that domain-limited integer types are called out: I wish more languages had that.
At the same time: there’s a reasonable practical argument that both have essentially safe semantics, and that “safer” one is really just the more successful (easier to integrate into existing codebases, more online resources, &c.) one. Rust is (thus far) winning at that.
- okl 3y agoThat feature really helps when you use integers for indexing, e.g., like an enum. Say you are parsing a file format with a type field which can have values 5, 6, 7, you can easily check if that's valid with a single call and lookup something, like a corresponding length in an array without having to translate those field values to array indices first.
- woodruffw 3y agoYep, although Rust manages to get there just fine with sum types and fallible conversion traits.