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
use super::{any::Any, arc::Arc};
use std::ops::Deref;

#[repr(C)]
pub struct BoxAny {
    inner: Arc<BoxAnyInner>,
}

struct BoxAnyInner {
    value: Any,
}

impl BoxAny {
    pub fn new(value: Any) -> Self {
        Self {
            inner: BoxAnyInner { value }.into(),
        }
    }
}

impl Deref for BoxAny {
    type Target = Any;

    fn deref(&self) -> &Any {
        &self.inner.value
    }
}