zesterer / flume

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

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

Open joshtriplett opened 4 weeks ago

joshtriplett commented 4 weeks 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 3 weeks 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.