enum_ref/
lib.rs

1#![no_std]
2
3pub use enum_ref_macro::{EnumMut, EnumRef};
4
5/// Trait implemented by `enum` types for shared access.
6///
7/// This trait usually is implemented via `#[derive(EnumRef)]`.
8pub trait EnumRef {
9    /// A wrapper type around `Self` for shared access.
10    type Ref<'a>
11    where
12        Self: 'a;
13
14    /// Returns a shared reference wrapper to `self`.
15    fn as_ref(&self) -> Self::Ref<'_>;
16}
17
18/// Trait implemented by `enum` types for exclusive access.
19///
20/// This trait usually is implemented via `#[derive(EnumMut)]`.
21pub trait EnumMut {
22    /// A wrapper type around `Self` for shared access.
23    type Mut<'a>
24    where
25        Self: 'a;
26
27    /// Returns an exlusive reference wrapper to `self`.
28    fn as_mut(&mut self) -> Self::Mut<'_>;
29}