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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/// How excess space is distributed when layout constraints are satisfied.
#[derive(Debug, Default, Clone, Copy, Eq, PartialEq, Hash)]
pub enum Flex {
/// Excess space goes into the last element (ratatui legacy behavior).
Legacy,
/// Align items to the start.
#[default]
Start,
/// Align items to the end.
End,
/// Center items.
Center,
/// Space between items, none at edges.
SpaceBetween,
/// Space around items.
SpaceAround,
/// Even space before, between, and after items.
SpaceEvenly,
}
impl Flex {
/// Returns `true` if this is [`Flex::Legacy`].
pub const fn is_legacy(self) -> bool {
matches!(self, Self::Legacy)
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn flex_default() {
assert_eq!(Flex::default(), Flex::Start);
}
#[test]
fn flex_is_legacy() {
assert!(Flex::Legacy.is_legacy());
assert!(!Flex::Start.is_legacy());
assert!(!Flex::End.is_legacy());
assert!(!Flex::Center.is_legacy());
assert!(!Flex::SpaceBetween.is_legacy());
assert!(!Flex::SpaceAround.is_legacy());
assert!(!Flex::SpaceEvenly.is_legacy());
}
}