4 ms·
Backwards compatibility is more difficult in Rust for many reasons. For example, you can't add a new item to an enum without creating missing-case errors everyw
by whatshisface 2y ago
Backwards compatibility is more difficult in Rust for many reasons. For example, you can't add a new item to an enum without creating missing-case errors everywhere it is used.
- skitter 2y agoAdding an enum variant can be backwards incompatible just as easily in languages that don't do this, you just don't get to see the error at compile time.
- dwattttt 2y agoThat's a true effect, although I'd question whether it makes it harder or easier for things to be backwards compatible. I use Rust because I trust it to throw up a bunch of errors when I make changes; if I handle all the cases of an enum somewhere, and suddenly there's a new enum variant, the answer is probably that I need to handle the new variant there too.
- sanxiyn 2y agoYou can use #[non_exhaustive] if you want to avoid this.
- deleted 2y ago[deleted]
- tialaramex 2y agoRight. This even tidily forbids the exhaustive matching for other people's code (ie requires them to write a default) using your crate but still allows it within the crate, reasoning that you should know which values you added even if you never promise an exhaustive list to your users.
- anonymoushn 2y agoYou can't add a method in Go without causing new interfaces to match, which breaks at runtime.