use std::collections::hash_map::DefaultHasher;
use std::hash::Hash;
use std::hash::Hasher;
pub(super) enum HashDestination<'a, H> {
Root(
&'a mut H,
),
ObjectEntry(
DefaultHasher,
),
}
impl<H> HashDestination<'_, H>
where
H: Hasher,
{
#[inline(always)]
pub(super) fn hash<T>(&mut self, value: &T)
where
T: Hash + ?Sized,
{
match self {
Self::Root(state) => value.hash(*state),
Self::ObjectEntry(state) => value.hash(state),
}
}
#[must_use]
#[inline(always)]
pub(super) fn finish_object_entry(self) -> Option<u64> {
match self {
Self::ObjectEntry(state) => Some(state.finish()),
Self::Root(_) => None,
}
}
}