#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
pub struct Size {
width: usize,
height: usize,
}
impl Size {
pub const ZERO: Self = Self {
width: 0,
height: 0,
};
pub const fn new(width: usize, height: usize) -> Self {
Self { width, height }
}
pub const fn width(&self) -> usize {
self.width
}
pub const fn height(&self) -> usize {
self.height
}
pub const fn is_empty(&self) -> bool {
self.width == 0 || self.height == 0
}
}
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
pub struct Available {
width: Option<usize>,
height: Option<usize>,
}
impl Available {
pub const NONE: Self = Self {
width: None,
height: None,
};
pub const fn new(width: Option<usize>, height: Option<usize>) -> Self {
Self { width, height }
}
pub const fn columns(width: usize) -> Self {
Self::new(Some(width), None)
}
pub const fn size(width: usize, height: usize) -> Self {
Self::new(Some(width), Some(height))
}
pub const fn width(&self) -> Option<usize> {
self.width
}
pub const fn height(&self) -> Option<usize> {
self.height
}
}
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
pub(super) struct Constraint {
pub reference: Option<usize>,
pub cap: Option<usize>,
}
impl Constraint {
pub const fn unbounded() -> Self {
Self {
reference: None,
cap: None,
}
}
pub const fn available(extent: Option<usize>) -> Self {
Self {
reference: extent,
cap: extent,
}
}
pub const fn established(extent: usize) -> Self {
Self::available(Some(extent))
}
}