varcon_core/
borrowed.rs

1#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
2pub struct Cluster {
3    pub header: &'static str,
4    pub verified: bool,
5    pub level: usize,
6    pub entries: &'static [Entry],
7    pub notes: &'static [&'static str],
8}
9
10impl Cluster {
11    pub fn into_owned(self) -> crate::Cluster {
12        crate::Cluster {
13            header: self.header.to_owned(),
14            verified: self.verified,
15            level: self.level,
16            entries: self.entries.iter().map(|s| s.into_owned()).collect(),
17            notes: self.notes.iter().map(|s| (*s).to_owned()).collect(),
18        }
19    }
20}
21
22#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
23pub struct Entry {
24    pub variants: &'static [Variant],
25    pub pos: Option<crate::Pos>,
26    pub archaic: bool,
27    pub description: Option<&'static str>,
28    pub note: Option<&'static str>,
29    pub comment: Option<&'static str>,
30}
31
32impl Entry {
33    pub fn into_owned(self) -> crate::Entry {
34        crate::Entry {
35            variants: self.variants.iter().map(|v| v.into_owned()).collect(),
36            pos: self.pos,
37            archaic: self.archaic,
38            description: self.description.map(|s| s.to_owned()),
39            note: self.note.map(|s| s.to_owned()),
40            comment: self.comment.map(|s| s.to_owned()),
41        }
42    }
43}
44
45#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
46pub struct Variant {
47    pub types: &'static [crate::Type],
48    pub word: &'static str,
49}
50
51impl Variant {
52    pub fn into_owned(self) -> crate::Variant {
53        crate::Variant {
54            types: self.types.to_vec(),
55            word: self.word.to_owned(),
56        }
57    }
58}