exhaust/impls/
core_result.rs

1use crate::patterns::delegate_factory_and_iter;
2use crate::Exhaust;
3
4impl<T: Exhaust, E: Exhaust> Exhaust for Result<T, E> {
5    delegate_factory_and_iter!(remote::Result<T, E>);
6
7    fn from_factory(factory: Self::Factory) -> Self {
8        match remote::Result::from_factory(factory) {
9            remote::Result::Ok(v) => Ok(v),
10            remote::Result::Err(v) => Err(v),
11        }
12    }
13}
14
15/// Like the Serde “remote derive” pattern, we define a type imitating the real type
16/// which the derive macro can process.
17mod remote {
18    #[allow(missing_debug_implementations)] // not actually public
19    #[derive(crate::Exhaust)]
20    pub enum Result<T, E> {
21        Ok(T),
22        Err(E),
23    }
24}