pub trait MagicAny:
Any
+ Send
+ Sync {
// Required methods
fn magic_any_arc(self: Arc<Self>) -> Arc<dyn Any + Sync + Send>;
fn magic_debug(&self, f: &mut Formatter<'_>) -> Result;
fn magic_eq(&self, other: &dyn MagicAny) -> bool;
fn magic_hash(&self, hasher: &mut dyn Hasher);
fn magic_trace_raw_vcs(&self, trace_context: &mut TraceRawVcsContext);
fn magic_type_name(&self) -> &'static str;
}
Required Methods§
fn magic_any_arc(self: Arc<Self>) -> Arc<dyn Any + Sync + Send>
fn magic_debug(&self, f: &mut Formatter<'_>) -> Result
fn magic_eq(&self, other: &dyn MagicAny) -> bool
fn magic_hash(&self, hasher: &mut dyn Hasher)
fn magic_trace_raw_vcs(&self, trace_context: &mut TraceRawVcsContext)
fn magic_type_name(&self) -> &'static str
Implementations§
Source§impl dyn MagicAny
impl dyn MagicAny
Sourcepub fn downcast_ref<T: MagicAny>(&self) -> Option<&T>
pub fn downcast_ref<T: MagicAny>(&self) -> Option<&T>
Returns some reference to the boxed value if it is of type T
, or
None
if it isn’t.
Sourcepub unsafe fn downcast_ref_unchecked<T: MagicAny>(&self) -> &T
pub unsafe fn downcast_ref_unchecked<T: MagicAny>(&self) -> &T
Returns a reference to the boxed value, blindly assuming it to be of type T
.
If you are not absolutely certain of T
, you must not call this.
Sourcepub fn downcast_mut<T: MagicAny>(&mut self) -> Option<&mut T>
pub fn downcast_mut<T: MagicAny>(&mut self) -> Option<&mut T>
Returns some mutable reference to the boxed value if it is of type T
, or
None
if it isn’t.
Sourcepub unsafe fn downcast_mut_unchecked<T: MagicAny>(&mut self) -> &mut T
pub unsafe fn downcast_mut_unchecked<T: MagicAny>(&mut self) -> &mut T
Returns a mutable reference to the boxed value, blindly assuming it to be of type T
.
If you are not absolutely certain of T
, you must not call this.
Source§impl dyn MagicAny
impl dyn MagicAny
Sourcepub fn downcast<T: MagicAny>(self: Box<Self>) -> Result<Box<T>, Box<Self>>
pub fn downcast<T: MagicAny>(self: Box<Self>) -> Result<Box<T>, Box<Self>>
Returns the boxed value if it is of type T
, or Err(Self)
if it isn’t.
Sourcepub unsafe fn downcast_unchecked<T: MagicAny>(self: Box<Self>) -> Box<T>
pub unsafe fn downcast_unchecked<T: MagicAny>(self: Box<Self>) -> Box<T>
Returns the boxed value, blindly assuming it to be of type T
.
If you are not absolutely certain of T
, you must not call this.