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
use crate::Yaml;
use alloc::{rc::Rc, sync::Arc};
use core::{fmt::Debug, hash::Hash, ops::Deref};
pub struct RcRepr;
pub struct ArcRepr;
pub trait Repr: Sized {
type Rc: Deref<Target = Yaml<Self>> + Hash + Eq + Clone + Debug;
fn new_rc(yaml: Yaml<Self>) -> Self::Rc;
}
impl Repr for RcRepr {
type Rc = Rc<Yaml<Self>>;
fn new_rc(yaml: Yaml<Self>) -> Self::Rc {
Rc::new(yaml)
}
}
impl Repr for ArcRepr {
type Rc = Arc<Yaml<Self>>;
fn new_rc(yaml: Yaml<Self>) -> Self::Rc {
Arc::new(yaml)
}
}