diff --git a/src/types/dynamic.rs b/src/types/dynamic.rs index aeb3eaea..b4deb26d 100644 --- a/src/types/dynamic.rs +++ b/src/types/dynamic.rs @@ -346,11 +346,52 @@ impl Dynamic { #[inline] #[must_use] pub fn is(&self) -> bool { - if TypeId::of::() == TypeId::of::() { - self.type_id() == TypeId::of::() - } else { - self.type_id() == TypeId::of::() + if TypeId::of::() == TypeId::of::<()>() { + return matches!(self.0, Union::Unit(..)); } + if TypeId::of::() == TypeId::of::() { + return matches!(self.0, Union::Bool(..)); + } + if TypeId::of::() == TypeId::of::() { + return matches!(self.0, Union::Char(..)); + } + if TypeId::of::() == TypeId::of::() { + return matches!(self.0, Union::Int(..)); + } + #[cfg(not(feature = "no_float"))] + if TypeId::of::() == TypeId::of::() { + return matches!(self.0, Union::Float(..)); + } + if TypeId::of::() == TypeId::of::() + || TypeId::of::() == TypeId::of::() + { + return matches!(self.0, Union::Str(..)); + } + #[cfg(not(feature = "no_index"))] + if TypeId::of::() == TypeId::of::() { + return matches!(self.0, Union::Array(..)); + } + #[cfg(not(feature = "no_index"))] + if TypeId::of::() == TypeId::of::() { + return matches!(self.0, Union::Blob(..)); + } + #[cfg(not(feature = "no_object"))] + if TypeId::of::() == TypeId::of::() { + return matches!(self.0, Union::Map(..)); + } + #[cfg(not(feature = "decimal"))] + if TypeId::of::() == TypeId::of::() { + return matches!(self.0, Union::Decimal(..)); + } + if TypeId::of::() == TypeId::of::() { + return matches!(self.0, Union::FnPtr(..)); + } + #[cfg(not(feature = "no_std"))] + if TypeId::of::() == TypeId::of::() { + return matches!(self.0, Union::TimeStamp(..)); + } + + TypeId::of::() == self.type_id() } /// Get the [`TypeId`] of the value held by this [`Dynamic`]. ///