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
43
44
45
46
47
use crate::account::Account;
use crate::book::Book;
use crate::move_::Move;
use crate::unit::Unit;
use duplicate::duplicate;
use std::cell::Ref;
pub trait Metadata: Clone {
type Book;
type Account;
type Unit;
type Move;
}
impl<B, A, U, M> Metadata for (B, A, U, M)
where
B: Clone,
A: Clone,
U: Clone,
M: Clone,
{
type Book = B;
type Account = A;
type Unit = U;
type Move = M;
}
#[cfg(test)]
pub type BlankMetadata = ((), (), (), ());
#[duplicate(Entity; [Book]; [Account]; [Unit]; [Move])]
impl<T: Metadata> Entity<T> {
pub fn set_metadata(&self, meta: T::Entity) {
*self.meta.borrow_mut() = meta;
}
pub fn get_metadata(&self) -> Ref<T::Entity> {
self.meta.borrow()
}
}