Skip to main content

Singleton

Derive Macro Singleton 

Source
#[derive(Singleton)]
{
    // Attributes available to this derive:
    #[singleton]
}
Available on crate feature singleton only.
Expand description

Derive the Singleton trait.

This requires that the struct or enum is Send.

This derive procedural macro accepts an attribute: #[singleton]. The attribute may configure the underlying lock used for securing access to the singleton. Valid values:

  • #[singleton(lock = "mutex")] (default)
  • #[singleton(lock = "rwlock")]

Required available imports: