this post was submitted on 17 Jan 2024
10 points (91.7% liked)

Rust

5999 readers
21 users here now

Welcome to the Rust community! This is a place to discuss about the Rust programming language.

Wormhole

!performance@programming.dev

Credits

  • The icon is a modified version of the official rust logo (changing the colors to a gradient and black background)

founded 1 year ago
MODERATORS
 

Please let me know if this is possible...

I would like to be able to have a coroutine / generator yield to resume with a value.

This is a simplified version of what I am looking for:

https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=8be2f397f600236b66970fce5c0ecab6

In this example, yield would end up requesting from the parent, that it wants to read the next byte, and the parent would resume the coroutine with the next byte. (In this case, it's hardcoded to 54, but it can be any value.)

Yet it seems like Rust doesn't have the ability to resume a yield with a value.

Is there any way I can get this to work?

you are viewing a single comment's thread
view the rest of the comments
[–] taladar@sh.itjust.works 3 points 10 months ago (5 children)

I think your playground link might be broken because of all the amp bits.

[–] van2z@lemmy.world 3 points 10 months ago (2 children)

You are right. I fixed it just now. That is an annoying "feature" of lemmy...

[–] mac@programming.dev 2 points 10 months ago* (last edited 10 months ago)

Converting ampersands to say amp instead is a bug that got fixed in version 0.19, world hasnt upgraded yet though

[–] sugar_in_your_tea@sh.itjust.works -1 points 10 months ago (1 children)

Amp is a Google thing, not a Lemmy thing. I can't see the original, so I can't tell if it's a Lemmy thing or some client that has issues.

[–] lolcatnip@reddthat.com 4 points 10 months ago (1 children)

They're talking about &, the HTML code for an ampersand.

[–] sugar_in_your_tea@sh.itjust.works 1 points 10 months ago

Ah, thanks. :)

load more comments (2 replies)