2 ms·
Is x = 57u8 actually idiomatic when compared to x: u8 = 57? I don't remember any Rust resource using that.
by Hamuko 2y ago
Is x = 57u8 actually idiomatic when compared to x: u8 = 57? I don't remember any Rust resource using that.
- School-Cotton 2y agoIt doesn’t really make a difference imo.
- leoedin 2y agoIt's not only not really idiomatic, it's almost never necessary in practice. I was struggling to think of a time I'd ever given a type annotation to an integer local variable - because normally the place the variable ends up dictates the type. Local variable becomes part of struct? Struct dictates type. Passed into function? Function dictates type. Multiplied by other variable and then that is passed to function? The type is determined by the function.
- School-Cotton 2y agoIt can be necessary if you’re passing it to a generic type/function.
- serial_dev 2y agoSame, I don’t think that’s idiomatic at all
- broneedsjob 2y ago[flagged]