object_rainbow/impls/
boxed.rs

1use crate::*;
2
3impl<T: ?Sized + ToOutput> ToOutput for Box<T> {
4    fn to_output(&self, output: &mut dyn Output) {
5        (**self).to_output(output);
6    }
7}
8
9impl<T: ?Sized + InlineOutput> InlineOutput for Box<T> {}
10
11impl<T: Parse<I>, I: ParseInput> Parse<I> for Box<T> {
12    fn parse(input: I) -> crate::Result<Self> {
13        T::parse(input).map(Self::new)
14    }
15}
16
17impl<T: ParseInline<I>, I: ParseInput> ParseInline<I> for Box<T> {
18    fn parse_inline(input: &mut I) -> crate::Result<Self> {
19        T::parse_inline(input).map(Self::new)
20    }
21}
22
23impl<T: ?Sized + ListHashes> ListHashes for Box<T> {
24    fn list_hashes(&self, f: &mut impl FnMut(Hash)) {
25        (**self).list_hashes(f);
26    }
27
28    fn topology_hash(&self) -> Hash {
29        (**self).topology_hash()
30    }
31
32    fn point_count(&self) -> usize {
33        (**self).point_count()
34    }
35}
36
37impl<T: ?Sized + Topological> Topological for Box<T> {
38    fn traverse(&self, visitor: &mut impl PointVisitor) {
39        (**self).traverse(visitor);
40    }
41
42    fn topology(&self) -> TopoVec {
43        (**self).topology()
44    }
45}
46
47impl<T: ?Sized + Tagged> Tagged for Box<T> {
48    const TAGS: Tags = T::TAGS;
49    const HASH: Hash = T::HASH;
50}
51
52impl<T: ?Sized + Size> Size for Box<T> {
53    const SIZE: usize = T::SIZE;
54    type Size = T::Size;
55}
56
57impl<T: ?Sized + MaybeHasNiche> MaybeHasNiche for Box<T> {
58    type MnArray = T::MnArray;
59}
60
61impl<T> Equivalent<T> for Box<T> {
62    fn into_equivalent(self) -> T {
63        *self
64    }
65
66    fn from_equivalent(object: T) -> Self {
67        Box::new(object)
68    }
69}