Dark side of ergonomics in Rust
Speaking of ergonomics, I seem to write a good deal of this for short-circuiting in Rust:<p><pre><code>    let x = match x {
      Some(x) => x,
      None => return None,
    }
</code></pre>
Rust doesn't have any other way to short-circuit and it gets pretty tedious.<p>I think Kotlin's named returns are most ergonomic of all. That way you can just short-circuit from anywhere whether in the middle of a fold or a deeply nested iteration.<p><pre><code>    fn foo() {
      for x in xs {
        for y in ys {
          if y == 42 {
            return@foo 42
          }
        }
      }
    }
</code></pre>
The other thing I'd like for other languages to steal for Kotlin is how everything has the .let/.apply/etc. methods.<p>I'm rusty so this is more pseudocode, but these methods basically let you bring your own chaining to any value.<p><pre><code>    let y = x.let { x ->
        x + 100
    }.apply { x ->
        println(x)
    }.let { x -> 
        x * 2
    }
</code></pre>
Once you use it, it feels pretty silly that library authors in other languages have to deliberately design a chainable API for the same ergonomics. ...And infuriating when you want to chain some more in other languages but you've run out of chain context.<p>Like when you use `.unwrap_or()` in Rust but still want to continue chaining on to the value. But can't because it's not in a container anymore with a chainable API.<p><pre><code>    let x = maybe
        .map(foo)
        .and_then(bar)
        .unwrap_or(42);
        // ugh, want to apply a function to the result so
        // far but can't use `.map(to_base16)` because 
        // it's been unwrapped into u32.
</code></pre>
Just some things from my wishlist for the next language someone makes.