diff --git a/druid/src/data.rs b/druid/src/data.rs index 9433734ba9..2a2f16f4f6 100644 --- a/druid/src/data.rs +++ b/druid/src/data.rs @@ -135,6 +135,8 @@ macro_rules! impl_data_simple { }; } +// Standard library impls + impl_data_simple!(i8); impl_data_simple!(i16); impl_data_simple!(i32); @@ -161,6 +163,17 @@ impl_data_simple!(std::num::NonZeroU32); impl_data_simple!(std::num::NonZeroU64); impl_data_simple!(std::num::NonZeroU128); impl_data_simple!(std::num::NonZeroUsize); +impl_data_simple!(std::time::SystemTime); +impl_data_simple!(std::time::Instant); +impl_data_simple!(std::time::Duration); +impl_data_simple!(std::io::ErrorKind); +impl_data_simple!(std::net::Ipv4Addr); +impl_data_simple!(std::net::Ipv6Addr); +impl_data_simple!(std::net::SocketAddrV4); +impl_data_simple!(std::net::SocketAddrV6); +impl_data_simple!(std::net::IpAddr); +impl_data_simple!(std::net::SocketAddr); +impl_data_simple!(std::ops::RangeFull); impl_data_simple!(druid::piet::InterpolationMode); //TODO: remove me!? impl_data_simple!(String); @@ -189,12 +202,24 @@ impl Data for Arc { } } +impl Data for std::sync::Weak { + fn same(&self, other: &Self) -> bool { + std::sync::Weak::ptr_eq(self, other) + } +} + impl Data for Rc { fn same(&self, other: &Self) -> bool { Rc::ptr_eq(self, other) } } +impl Data for std::rc::Weak { + fn same(&self, other: &Self) -> bool { + std::rc::Weak::ptr_eq(self, other) + } +} + impl Data for Option { fn same(&self, other: &Self) -> bool { match (self, other) { @@ -269,6 +294,75 @@ impl Data for (T0, T } } +impl Data for std::marker::PhantomData { + fn same(&self, _other: &Self) -> bool { + // zero-sized types + true + } +} + +impl Data for std::mem::Discriminant { + fn same(&self, other: &Self) -> bool { + *self == *other + } +} + +impl Data for std::mem::ManuallyDrop { + fn same(&self, other: &Self) -> bool { + (&**self).same(&**other) + } +} + +impl Data for std::num::Wrapping { + fn same(&self, other: &Self) -> bool { + self.0.same(&other.0) + } +} + +impl Data for std::ops::Range { + fn same(&self, other: &Self) -> bool { + self.start.same(&other.start) && self.end.same(&other.end) + } +} + +impl Data for std::ops::RangeFrom { + fn same(&self, other: &Self) -> bool { + self.start.same(&other.start) + } +} + +impl Data for std::ops::RangeInclusive { + fn same(&self, other: &Self) -> bool { + self.start().same(other.start()) && self.end().same(other.end()) + } +} + +impl Data for std::ops::RangeTo { + fn same(&self, other: &Self) -> bool { + self.end.same(&other.end) + } +} + +impl Data for std::ops::RangeToInclusive { + fn same(&self, other: &Self) -> bool { + self.end.same(&other.end) + } +} + +impl Data for std::ops::Bound { + fn same(&self, other: &Self) -> bool { + use std::ops::Bound::*; + match (self, other) { + (Included(t1), Included(t2)) if t1.same(t2) => true, + (Excluded(t1), Excluded(t2)) if t1.same(t2) => true, + (Unbounded, Unbounded) => true, + _ => false, + } + } +} + +// druid & deps impls + impl Data for Scale { fn same(&self, other: &Self) -> bool { self == other