#[derive(
Debug, Clone, Copy, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize, Default,
)]
pub enum WindowPlacement {
#[default]
Floating,
Maximized,
Fullscreen,
Minimized,
}
impl WindowPlacement {
pub fn is_fullscreen(self) -> bool {
matches!(self, WindowPlacement::Fullscreen)
}
pub fn is_maximized(self) -> bool {
matches!(self, WindowPlacement::Maximized)
}
pub fn is_minimized(self) -> bool {
matches!(self, WindowPlacement::Minimized)
}
pub fn is_floating(self) -> bool {
matches!(self, WindowPlacement::Floating)
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn predicates_match_variant() {
assert!(WindowPlacement::Floating.is_floating());
assert!(!WindowPlacement::Floating.is_fullscreen());
assert!(WindowPlacement::Fullscreen.is_fullscreen());
assert!(WindowPlacement::Maximized.is_maximized());
assert!(WindowPlacement::Minimized.is_minimized());
}
#[test]
fn default_is_floating() {
assert_eq!(WindowPlacement::default(), WindowPlacement::Floating);
}
}