smol-rs / async-broadcast

Async broadcast channels

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Allow Sender::set_capacity and Sender::set_overflow to take &self instead of &mut self

IGreyGooI opened this issue · comments

Or is there a reason for both functions to only take exclusive references?

Sorry for the very late reply but I was on vacation.

That's because you're modifying the channel (or Sender in this case). Since we're using mutex internally, at the moment it's not needed but if we were to change the implementation so that we require exterior mutability (i-e &mut self), we'll have to break the API so it's future proof at least. IMO it also makes it explicitly clear that channel is being modified by the call.

I hope that answers you question.