use crate::settings::TableOption; #[cfg(feature = "std")] use crate::grid::config::Entity; #[cfg(feature = "std")] use crate::settings::CellOption; /// Settings is a combinator of [`TableOption`]s. #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] pub struct Settings(A, B); impl Default for Settings { fn default() -> Self { Self(EmptySettings, EmptySettings) } } impl Settings<(), ()> { /// Creates an empty list. pub const fn empty() -> Settings { Settings(EmptySettings, EmptySettings) } } impl Settings { /// Creates a new combinator. pub const fn new(settings1: A, settings2: B) -> Settings { Settings(settings1, settings2) } /// Add an option to a combinator. pub const fn with(self, settings: C) -> Settings { Settings(self, settings) } } #[cfg(feature = "std")] impl CellOption for Settings where A: CellOption, B: CellOption, { fn change(self, records: &mut R, cfg: &mut C, entity: Entity) { self.0.change(records, cfg, entity); self.1.change(records, cfg, entity); } } impl TableOption for Settings where A: TableOption, B: TableOption, { fn change(self, records: &mut R, cfg: &mut C, dims: &mut D) { self.0.change(records, cfg, dims); self.1.change(records, cfg, dims); } } /// A marker structure to be able to create an empty [`Settings`]. #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] pub struct EmptySettings; #[cfg(feature = "std")] impl CellOption for EmptySettings { fn change(self, _: &mut R, _: &mut C, _: Entity) {} } impl TableOption for EmptySettings { fn change(self, _: &mut R, _: &mut C, _: &mut D) {} }