diff --git a/src/any.rs b/src/any.rs index 814e369a..7e7494e8 100644 --- a/src/any.rs +++ b/src/any.rs @@ -92,15 +92,13 @@ impl Any for T { impl Variant { /// Is this `Variant` a specific type? - pub(crate) fn is(&self) -> bool { - let t = TypeId::of::(); - let boxed = ::type_id(self); - - t == boxed + pub fn is(&self) -> bool { + TypeId::of::() == ::type_id(self) } /// Get a reference of a specific type to the `Variant`. - pub(crate) fn downcast_ref(&self) -> Option<&T> { + /// Returns `None` if the cast fails. + pub fn downcast_ref(&self) -> Option<&T> { if self.is::() { unsafe { Some(&*(self as *const Variant as *const T)) } } else { @@ -109,7 +107,8 @@ impl Variant { } /// Get a mutable reference of a specific type to the `Variant`. - pub(crate) fn downcast_mut(&mut self) -> Option<&mut T> { + /// Returns `None` if the cast fails. + pub fn downcast_mut(&mut self) -> Option<&mut T> { if self.is::() { unsafe { Some(&mut *(self as *mut Variant as *mut T)) } } else {