use crate::{FromType, Reflect}; /// A struct used to provide the default value of a type. /// /// A [`ReflectDefault`] for type `T` can be obtained via [`FromType::from_type`]. #[derive(Clone)] pub struct ReflectDefault { default: fn() -> Box, } impl ReflectDefault { pub fn default(&self) -> Box { (self.default)() } } impl FromType for ReflectDefault { fn from_type() -> Self { ReflectDefault { default: || Box::::default(), } } }