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 48 49 50
use crate::widget::{component::WidgetComponent, unit::WidgetUnit}; #[derive(Debug, Clone)] pub enum WidgetNode { None, Component(WidgetComponent), Unit(WidgetUnit), } impl WidgetNode { pub fn is_none(&self) -> bool { match self { Self::None => true, Self::Unit(unit) => unit.is_none(), _ => false, } } pub fn is_some(&self) -> bool { match self { Self::None => false, Self::Unit(unit) => unit.is_some(), _ => true, } } } impl Default for WidgetNode { fn default() -> Self { Self::None } } impl From<()> for WidgetNode { fn from(_: ()) -> Self { Self::None } } impl From<WidgetComponent> for WidgetNode { fn from(component: WidgetComponent) -> Self { Self::Component(component) } } impl From<WidgetUnit> for WidgetNode { fn from(unit: WidgetUnit) -> Self { Self::Unit(unit) } }