embassy-rs / embassy

Modern embedded framework, using Rust and async.
https://embassy.dev
Apache License 2.0
5.31k stars 732 forks source link

embassy_sync's blocking mutexes do not provide interior mutability #1246

Open kesyog opened 1 year ago

kesyog commented 1 year ago

The lock and borrow API's for embassy_sync's blocking Mutex and ThreadModeMutex types provide only shared references to their inner data. Shouldn't they provide mutable references to provide interior mutability? Why are their API's different from the async mutexes?

kesyog commented 1 year ago

I see that the critical_section crate's Mutex also does not provide interior mutability, but their documentation makes that fact and the reasoning explicit whereas the documentation for embassy_sync's blocking mutex implies that it provides interior mutability.