3 ms·
> there is no room in the type system to return an error There is: you panic, like in the array case. That would have been much robust (at the cost of perform
by jfkebwjsbx 6y ago
> there is no room in the type system to return an error
There is: you panic, like in the array case.
That would have been much robust (at the cost of performance).
- kibwen 6y agoFor consistency you would also expect `257u32 as u8` to panic (which it doesn't, and never has); the `as` operator has always been about fast-and-lossy conversions, with the standard library ideally providing methods for more principled conversions.