exhaust/impls/
core_fmt.rs

1use core::fmt;
2
3use crate::patterns::{delegate_factory_and_iter, impl_singleton};
4use crate::Exhaust;
5
6impl Exhaust for fmt::Alignment {
7    delegate_factory_and_iter!(remote::Alignment);
8
9    fn from_factory(factory: Self::Factory) -> Self {
10        match remote::Alignment::from_factory(factory) {
11            remote::Alignment::Left => fmt::Alignment::Left,
12            remote::Alignment::Right => fmt::Alignment::Right,
13            remote::Alignment::Center => fmt::Alignment::Center,
14        }
15    }
16}
17
18impl_singleton!([], fmt::Error);
19
20/// Like the Serde “remote derive” pattern, we define a type imitating the real type
21/// which the derive macro can process.
22mod remote {
23    #![allow(missing_debug_implementations)] // not actually public
24
25    #[derive(crate::Exhaust)]
26    pub enum Alignment {
27        Left,
28        Right,
29        Center,
30    }
31}