X-Git-Url: https://git.chrismorgan.info/anymap/blobdiff_plain/c52281b376938163f91f351f84877346381cec82..1374cacb410abd763f5ff6d4644b8f01b2330f3c:/src/any.rs?ds=inline diff --git a/src/any.rs b/src/any.rs index 4120e6a..976f768 100644 --- a/src/any.rs +++ b/src/any.rs @@ -22,18 +22,22 @@ pub trait CloneToAny { } impl CloneToAny for T { + #[inline] fn clone_to_any(&self) -> Box { Box::new(self.clone()) } + #[inline] fn clone_to_any_send(&self) -> Box where Self: Send { Box::new(self.clone()) } + #[inline] fn clone_to_any_sync(&self) -> Box where Self: Sync { Box::new(self.clone()) } + #[inline] fn clone_to_any_send_sync(&self) -> Box where Self: Send + Sync { Box::new(self.clone()) } @@ -80,6 +84,7 @@ macro_rules! define { macro_rules! impl_clone { ($t:ty, $method:ident) => { impl Clone for Box<$t> { + #[inline] fn clone(&self) -> Box<$t> { (**self).$method() } @@ -104,26 +109,31 @@ pub trait IntoBox: Any { macro_rules! implement { ($base:ident, $(+ $bounds:ident)*) => { impl fmt::Debug for $base $(+ $bounds)* { + #[inline] fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.pad(stringify!($base $(+ $bounds)*)) } } impl UncheckedAnyExt for $base $(+ $bounds)* { + #[inline] unsafe fn downcast_ref_unchecked(&self) -> &T { &*(self as *const Self as *const T) } + #[inline] unsafe fn downcast_mut_unchecked(&mut self) -> &mut T { &mut *(self as *mut Self as *mut T) } + #[inline] unsafe fn downcast_unchecked(self: Box) -> Box { Box::from_raw(Box::into_raw(self) as *mut T) } } impl IntoBox<$base $(+ $bounds)*> for T { + #[inline] fn into_box(self) -> Box<$base $(+ $bounds)*> { Box::new(self) }