|
|
|
|
|
by fluffybucktsnek
48 days ago
|
|
I'll give my two cents here. I work with Dart daily, and it also uses the `await future` syntax. I can cite a number of ergonomic issues: ```dart
(await taskA()).doSomething()
(await taskB()) + 1
(await taskC()) as int
``` vs. ```rust
taskA().await.doSomething()
taskB().await + 1
taskC().await as i32
``` It gets worse if you try to compose: ```dart
(await taskA(
(await taskB(
(await taskC()) as int
)) + 1)
).doSomething()
``` This often leads to trading the await syntax for `then`: ```dart
await taskC()
.then((r) => r as i32)
.then(taskB)
.then((r) => r + 1)
.then(taskA)
.then((r) => r.doSomething())
``` But this is effectively trading the await structured syntax for a callback one. In Rust, we can write it as this: ```rust
taskA(taskB(taskC().await as i32).await + 1).await.doSomething()
``` |
|