smol-rs / async-broadcast

Async broadcast channels
Apache License 2.0
160 stars 26 forks source link

How does async-broadcast differ from async-channel? #6

Closed kennetpostigo closed 3 years ago

kennetpostigo commented 3 years ago

Hi 👋,

Whats the difference between async-broadcast and async-channel? Sorry if this is obvious, it just isn't immediately apparent to me

zeenix commented 3 years ago

Hi,

Whats the difference between async-broadcast and async-channel?

The former sends every receiver a copy (clone actually) of the message and hence requires Clone implementation from the message type, while the latter only delivers the sent message to one of the receivers and hence doesn't require Clone.

Sorry if this is obvious, it just isn't immediately apparent to me

Don't blame you. I myself was first confused before async-broadcast. I actually thought I compared them in the docs+README but seems I didn't in the end. I'll keep this open till I fix that.