use core::hash::{Hash, Hasher};
use crate::canonical::ToCanonicalBits;
use crate::primitive::Primitive;
use crate::Float;
pub trait FloatHash {
#[deprecated(since = "0.3.1", note = "use `FloatHash::float_hash` instead")]
fn hash<H>(&self, state: &mut H)
where
H: Hasher;
fn float_hash<H>(&self, state: &mut H)
where
H: Hasher,
{
#[allow(deprecated)]
self.hash(state)
}
}
impl<T> FloatHash for T
where
T: Float + Primitive,
{
fn hash<H>(&self, state: &mut H)
where
H: Hasher,
{
self.to_canonical_bits().hash(state);
}
}
impl<T> FloatHash for [T]
where
T: Float + Primitive,
{
fn hash<H>(&self, state: &mut H)
where
H: Hasher,
{
for item in self.iter() {
item.float_hash(state);
}
}
}