1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
use crate::VariantCase;

#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct Variant {
    pub(crate) cases: Vec<VariantCase>,
}

impl Variant {
    pub fn cases(&self) -> &[VariantCase] {
        &self.cases
    }

    pub fn cases_mut(&mut self) -> &mut Vec<VariantCase> {
        &mut self.cases
    }
}

impl<I, C> From<I> for Variant
where
    I: IntoIterator<Item = C>,
    C: Into<VariantCase>,
{
    fn from(value: I) -> Self {
        Self {
            cases: value.into_iter().map(|c| c.into()).collect(),
        }
    }
}