AnyHash

Trait AnyHash 

Source
pub trait AnyHash: Any {
    // Required methods
    fn debug(&self, f: &mut Formatter<'_>) -> Result;
    fn eq(&self, other: &dyn AnyHash) -> bool;
    fn hash(&self, hasher: &mut dyn Hasher);
}
Expand description

Object-safe trait for dynamically typed hashable keys.

All Eq + Hash + 'static types automatically implement this trait.

On nightly, if the inner value implements Debug, then Debug for AnyHash will use that implementation. Otherwise, it will only show a generic message.

Required Methods§

Source

fn debug(&self, f: &mut Formatter<'_>) -> Result

Source

fn eq(&self, other: &dyn AnyHash) -> bool

Source

fn hash(&self, hasher: &mut dyn Hasher)

Implementations§

Source§

impl dyn AnyHash

Source

pub fn is<T: AnyHash>(&self) -> bool

Returns true if the boxed type is the same as T

Source

pub fn downcast_ref<T: AnyHash>(&self) -> Option<&T>

Returns some reference to the boxed value if it is of type T, or None if it isn’t.

Source

pub unsafe fn downcast_ref_unchecked<T: AnyHash>(&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.

Source

pub fn downcast_mut<T: AnyHash>(&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.

Source

pub unsafe fn downcast_mut_unchecked<T: AnyHash>(&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 AnyHash

Source

pub fn downcast<T: AnyHash>(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.

Source

pub unsafe fn downcast_unchecked<T: AnyHash>(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.

Trait Implementations§

Source§

impl Debug for dyn AnyHash

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Debug for dyn AnyHash + Send

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Debug for dyn AnyHash + Send + Sync

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Hash for dyn AnyHash

Source§

fn hash<H: Hasher>(&self, hasher: &mut H)

Feeds this value into the given Hasher. Read more
Source§

impl Hash for dyn AnyHash + Send

Source§

fn hash<H: Hasher>(&self, hasher: &mut H)

Feeds this value into the given Hasher. Read more
Source§

impl Hash for dyn AnyHash + Send + Sync

Source§

fn hash<H: Hasher>(&self, hasher: &mut H)

Feeds this value into the given Hasher. Read more
Source§

impl PartialEq for dyn AnyHash

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq for dyn AnyHash + Send

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq for dyn AnyHash + Send + Sync

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for dyn AnyHash

Source§

impl Eq for dyn AnyHash + Send

Source§

impl Eq for dyn AnyHash + Send + Sync

Implementors§

Source§

impl<T: Eq + Hash + 'static> AnyHash for T