News for hackers. Stuff that matters.
Re:Use Your Type System by josephg on Thursday July 24, 2025 @07:42PM (#44677711)
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.
Re:Use Your Type System by someone_19 on Friday July 25, 2025 @01:34AM (#44679887)
Here is example of compile time error with wrong newtype argument:

https://play.rust-lang.org/?version=stable&mode=debug&editio...

rust-analyzer gives an error directly in IDE.