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
38
39
40
41
42
use BorrowMut;
use crate::;
/// The trait of values containing unique types which may be stored.
///
/// Implementing this trait for your own types is easy:
///
/// ```
/// # use genz::*;
/// pub struct MyStruct<'c, T> {
/// ty: UniqueType<'c, T>,
/// name: &'static str
/// }
///
/// impl<T> Storable for MyStruct<'static, T>
/// {
/// type Generative<'c> = MyStruct<'c, T>;
/// }
///
/// let mut x = Gen::<MyStruct<'static, _>>::from_type::<u8>(|ty| MyStruct { ty, name: "u8" });
/// assert_eq!("u8", x.with_ref(|s| s.name));
/// x.with_mut(|s| s.name = "foo");
/// assert_eq!("foo", x.with_ref(|s| s.name));
/// ```