3 ms·
You can do it at runtime quite easily in rust. But the rust compiler doesn’t understand what you’re doing - so it can’t make use of that information for peephol
by josephg 1y ago
You can do it at runtime quite easily in rust. But the rust compiler doesn’t understand what you’re doing - so it can’t make use of that information for peephole optimisations or to elide array bounds checks when using your custom type. And you don’t get runtime errors instead of compile time errors if you try to assign the wrong value into your type.
- deleted 1y ago[deleted]
- someone_19 1y agoHere is example of compile time error with wrong newtype argument: https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=ecfa34c3577f8b0e3e60b336c189ab1c https://play.rust-lang.org/?version=stable&mode=debug&editio... rust-analyzer gives an error directly in IDE.