diff options
Diffstat (limited to 'src/libcore/any.rs')
| -rw-r--r-- | src/libcore/any.rs | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/src/libcore/any.rs b/src/libcore/any.rs index 5126fe01a3f..4afea12a362 100644 --- a/src/libcore/any.rs +++ b/src/libcore/any.rs @@ -105,8 +105,10 @@ pub trait Any: 'static { } #[stable(feature = "rust1", since = "1.0.0")] -impl<T: 'static + ?Sized > Any for T { - fn type_id(&self) -> TypeId { TypeId::of::<T>() } +impl<T: 'static + ?Sized> Any for T { + fn type_id(&self) -> TypeId { + TypeId::of::<T>() + } } /////////////////////////////////////////////////////////////////////////////// @@ -193,9 +195,7 @@ impl dyn Any { pub fn downcast_ref<T: Any>(&self) -> Option<&T> { if self.is::<T>() { // SAFETY: just checked whether we are pointing to the correct type - unsafe { - Some(&*(self as *const dyn Any as *const T)) - } + unsafe { Some(&*(self as *const dyn Any as *const T)) } } else { None } @@ -229,16 +229,14 @@ impl dyn Any { pub fn downcast_mut<T: Any>(&mut self) -> Option<&mut T> { if self.is::<T>() { // SAFETY: just checked whether we are pointing to the correct type - unsafe { - Some(&mut *(self as *mut dyn Any as *mut T)) - } + unsafe { Some(&mut *(self as *mut dyn Any as *mut T)) } } else { None } } } -impl dyn Any+Send { +impl dyn Any + Send { /// Forwards to the method defined on the type `Any`. /// /// # Examples @@ -316,7 +314,7 @@ impl dyn Any+Send { } } -impl dyn Any+Send+Sync { +impl dyn Any + Send + Sync { /// Forwards to the method defined on the type `Any`. /// /// # Examples @@ -433,11 +431,9 @@ impl TypeId { /// assert_eq!(is_string(&"cookie monster".to_string()), true); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_const_unstable(feature="const_type_id", issue = "41875")] + #[rustc_const_unstable(feature = "const_type_id", issue = "41875")] pub const fn of<T: ?Sized + 'static>() -> TypeId { - TypeId { - t: intrinsics::type_id::<T>(), - } + TypeId { t: intrinsics::type_id::<T>() } } } |
