tokio-rs / tokio

A runtime for writing reliable asynchronous applications with Rust. Provides I/O, networking, scheduling, timers, ...
https://tokio.rs
MIT License
26.59k stars 2.45k forks source link

`arcmutex!` convenience macro #6617

Closed amab8901 closed 4 months ago

amab8901 commented 4 months ago

Is your feature request related to a problem? Please describe. Frustration lies in the verbosity (and hard-to-readness) of having to write:

let state_of_devices = Arc::new(Mutex::new(STATE_OF_DEVICES.clone()));

Describe the solution you'd like Convenience macro:

let state_of_devices = arcmutex!(STATE_OF_DEVICES.clone());

Describe alternatives you've considered

Additional context I think it would make sense to use a convenience macro for Arc<Mutex<T>> because it's a common pattern.

Darksonn commented 4 months ago

You can define it yourself. It will not be added to Tokio.