1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
//! Marker trait for custom state.
/// Marker trait to represent a custom state that is `Send + 'a`.
///
/// This trait is **not** automatically implemented for arbitrary types.
///
/// Custom state is stored in the [`StateRegistry`] and can be accessed according to
/// the typical borrowing model (one writer xor multiple readers).
///
/// [`StateRegistry`]: crate::state::StateRegistry
///
/// # Requires
///
/// Requires to implement [`better_any::Tid`], which can be done using the `Tid` derive macro.
///
/// # Examples
///
/// Custom state wrapping a owned type:
/// ```
/// use better_any::{Tid, TidAble};
/// use mahf::CustomState;
///
/// #[derive(Tid)]
/// pub struct Owned(usize);
/// impl CustomState<'_> for Owned {}
/// ```
///
/// Custom state wrapping a reference with a lifetime:
/// ```
/// use better_any::{Tid, TidAble};
/// use mahf::CustomState;
///
/// #[derive(Tid)]
/// pub struct Reference<'a>(&'a mut usize);
/// impl<'a> CustomState<'a> for Reference<'a> {}
/// ```