News for hackers. Stuff that matters.
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:

  void foo(int? x) {}
  void main() {
    foo(5);
  }
This is not fine in Rust:

  fn foo(x: Option<i32>) {}
  fn main() {
    foo(5);
  }
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.
Re:Things Go needs more than generics by Ryuuke on Monday October 04, 2021 @11:25AM (#28747897)
It might not work in Rust, but in Swift it works just fine.