zesterer / flume

A safe and fast multi-producer, multi-consumer channel.
https://crates.io/crates/flume
Apache License 2.0
2.47k stars 85 forks source link

Please support creating a Receiver from a Sender and vice versa #155

Open joshtriplett opened 1 month ago

joshtriplett commented 1 month ago

Receiver and Sender both contain the same Shared structure. I'd love to have a Sender::make_receiver function that produces a Receiver from a Sender (and vice versa with Receiver::make_sender), to allow storing only one in a data structure rather than storing the pair.

For precedent, see https://docs.rs/tokio/latest/tokio/sync/watch/struct.Sender.html#method.subscribe .

zesterer commented 1 month ago

That sounds like a reasonable suggestion. I'm very happy to accept a PR. Alternatively, I'll get round to it when I can find the time.