Frugal Async Rust
worm-blossom.org·12w·
Discuss: Hacker News

Async Rust can be quite complex. By adhering to certain restrictions, however, you can eliminate some incidental complexity:

  • Assume that nothing is cancel-safe.
  • Assume that no futures are Send.
  • Assume that panics always abort.

On Cancel-Safety

A value is cancel-safe if you can call one of its async methods, drop the returned future without polling it to completion, and then know that the original value is still in a well-defined state.

In synchronous code, methods always run to completion. As the author of a method, you do not need to worry about only half of your code running and then being stopped by an outside force. If that was the case, every single method mutating more than a single piece of state would b…

Similar Posts

Loading similar posts...

Keyboard Shortcuts

Navigation
Next / previous item
j/k
Open post
oorEnter
Preview post
v
Post Actions
Love post
a
Like post
l
Dislike post
d
Undo reaction
u
Recommendations
Add interest / feed
Enter
Not interested
x
Go to
Home
gh
Interests
gi
Feeds
gf
Likes
gl
History
gy
Changelog
gc
Settings
gs
Browse
gb
Search
/
General
Show this help
?
Submit feedback
!
Close modal / unfocus
Esc

Press ? anytime to show this help