Skip to main content

shared

Attribute Macro shared 

Source
#[shared]
Expand description

Transforms a struct into a shared, cheaply-cloneable wrapper.

Always generates:

  • XxxInner with each field wrapped in Mutex<T> or stored raw
  • Xxx(Arc<XxxInner>) with Clone = Arc::clone
  • Xxx::new(...) constructor
  • Per-field async accessors

Field attributes:

  • (default) Mutex<T>, generates async fn field() -> MutexGuard<T>
  • #[raw] stored as-is, generates fn field() -> &T