Ancestors

Toot

Written by Display Name on 2024-12-09 at 13:58

That mpsc::Receiver does not have a function peek(&self) -> bool is very annoying. I think it is easy to build a wrapper that provides peek(&mut self) -> bool but I do not want to introduce a mutable self in this code section just to peek() when nothing needs to be mutated regardless of the result.

=> More informations about this toot | More toots from Teufelchen@hal9.ooo

Descendants

Written by chrysn on 2024-12-09 at 14:31

@Teufelchen I think you can use interior mutability to manage the peeked item (setting which is otherwise a mutation), and put that Option in a (Ref)Cell.

The receiver is already not Sync, so you don't need fancy synchronization.

=> More informations about this toot | More toots from chrysn@chaos.social

Proxy Information
Original URL
gemini://mastogem.picasoft.net/thread/113623215659710921
Status Code
Success (20)
Meta
text/gemini
Capsule Response Time
247.797457 milliseconds
Gemini-to-HTML Time
0.436491 milliseconds

This content has been proxied by September (3851b).