Re:Rust’s async isn’t colored
by majewsky on Thursday March 11, 2021 @07:40AM
(#26423363)
Instead of
you'd write something like
if f2 takes a future, or
if it takes a value. (The latter is more common.) The equivalent in JS would be
[ Parent
| on HN ]
The example uses `g(h2)`, not `g(h2())` - `g` takes the function `h2` as an argument, and the call(s) to `h2` are made from within `g` itself.
If calling `h2` requires an `await` if and only if `h2` is async, then the function `g` can’t be used for both the synchronous and async cases. AFAIK this is the main objection to having two function colours.