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

I expect Rust should be able to handle this nicely, but I'm more familiar with Pony... So here's how to do it nicely in it:

    fun f(x: (T1 | T2 | None)): ReturnType =>
      match x
      | T2 => /* do something */
      | T1 => /* do something else */
      | None => /* Handle badly behaved. Optional to have, compiler can enforce good behaviour if you want. */
Note: You can see formatting at https://news.ycombinator.com/formatdoc


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

Search: