cronback_dto_core/
traits.rs

1pub trait ProstLazyDefault {
2    fn default_instance() -> &'static Self;
3}
4
5pub trait ProstOptionExt {
6    type Item;
7    fn get_or_default(&self) -> &Self::Item;
8}
9
10impl<T: ProstLazyDefault + 'static> ProstOptionExt for Option<T> {
11    type Item = T;
12
13    fn get_or_default(&self) -> &T {
14        self.as_ref().unwrap_or_else(|| T::default_instance())
15    }
16}