5
submitted 1 year ago by xhci@lemmy.world to c/rustlang@lemmyrs.org

I’m just starting to learn Rust, and was wondering if there is a good way to do coroutines/channels. I’ve grown fond of languages based around CSP, but am not sure that maps well to idiomatic Rust.

Thanks in advance!

you are viewing a single comment's thread
view the rest of the comments
[-] dillekant@slrpnk.net 3 points 1 year ago

Wait is there a difference between coroutines and async/await? I thought they were practically the same model.

[-] chrysn@chaos.social 1 points 1 year ago

Coroutines are one means of implementing async; the way they are implemented in Rust is more like building a state machine out of the async function. It can still be mapped to coroutines, and there are probably crates that use async and macros to make coroutines usable on stable, but the effort to have a stable language feature is still ongoing, with https://lang-team.rust-lang.org/design_notes/general_coroutines.html giving the overview.

this post was submitted on 06 Jul 2023
5 points (100.0% liked)

Rust Lang

3 readers
1 users here now

Rules [Developing]

Observe our code of conduct

Constructive criticism only

No endless relitigation

No low-effort content

No memes or image macros

No NSFW Content

founded 1 year ago
MODERATORS