Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.


It might not work in Rust, but in Swift it works just fine.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: