torin/values/
alignment.rs1#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
2#[derive(PartialEq, Eq, Clone, Debug, Default)]
3pub enum Alignment {
4 #[default]
6 Start,
7 Center,
9 End,
11 SpaceBetween,
13 SpaceEvenly,
15 SpaceAround,
17}
18
19impl Alignment {
20 pub fn start() -> Alignment {
22 Alignment::Start
23 }
24
25 pub fn center() -> Alignment {
27 Alignment::Center
28 }
29
30 pub fn end() -> Alignment {
32 Alignment::End
33 }
34
35 pub fn space_between() -> Alignment {
37 Alignment::SpaceBetween
38 }
39
40 pub fn space_evenly() -> Alignment {
42 Alignment::SpaceEvenly
43 }
44
45 pub fn space_around() -> Alignment {
47 Alignment::SpaceAround
48 }
49
50 pub const fn is_not_start(&self) -> bool {
51 !matches!(self, Self::Start)
52 }
53
54 pub const fn is_spaced(&self) -> bool {
55 matches!(
56 self,
57 Self::SpaceBetween | Self::SpaceAround | Self::SpaceEvenly
58 )
59 }
60
61 pub fn pretty(&self) -> String {
62 match self {
63 Self::Start => "start".to_string(),
64 Self::Center => "center".to_string(),
65 Self::End => "end".to_string(),
66 Self::SpaceBetween => "space-between".to_string(),
67 Self::SpaceEvenly => "space-evenly".to_string(),
68 Self::SpaceAround => "space-around".to_string(),
69 }
70 }
71}