Re:Things Go needs more than generics
by IshKebab on Monday October 04, 2021 @11:10AM
(#28747709)
They're not quite the same. With option types `Some(x)` is a distinct type and value to `x`. That's not true in e.g. Kotlin or Dart. For example this is fine in Dart:
This is not fine in Rust:
You might not think that makes much difference, but consider if `foo()` starts off as `fn foo(x: i32)` and after using it 10k different places you want to change it to `fn foo(x: Option<i32>)`. That's a backwards compatible change in Dart (and I presume Kotlin), but not in Rust.
[ Parent
| on HN ]