blob: 10873e890347866e4a3df9341d0d35a5f50583eb (
plain) (
blame)
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
|
/// The strategy used to fill space in a specific dimension.
#[derive(Debug, Clone, Copy, PartialEq, Hash)]
pub enum Length {
/// Fill all the remaining space
Fill,
/// Fill the least amount of space
Shrink,
/// Fill a fixed amount of space
Units(u16),
}
impl Length {
/// Returns the _fill factor_ of the [`Length`].
///
/// The _fill factor_ is a relative unit describing how much of the
/// remaining space should be filled when compared to other elements. It
/// is only meant to be used by layout engines.
///
/// [`Length`]: enum.Length.html
pub fn fill_factor(&self) -> u16 {
match self {
Length::Fill => 1,
Length::Shrink => 0,
Length::Units(_) => 0,
}
}
}
impl From<u16> for Length {
fn from(units: u16) -> Self {
Length::Units(units)
}
}
|