bevy_reflect/serde/ser/
serializable.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use core::ops::Deref;

/// A type-erased serializable value.
pub enum Serializable<'a> {
    Owned(Box<dyn erased_serde::Serialize + 'a>),
    Borrowed(&'a dyn erased_serde::Serialize),
}

impl<'a> Deref for Serializable<'a> {
    type Target = dyn erased_serde::Serialize + 'a;

    fn deref(&self) -> &Self::Target {
        match self {
            Serializable::Borrowed(serialize) => serialize,
            Serializable::Owned(serialize) => serialize,
        }
    }
}