use alloc::string::String;
use core::hash::BuildHasher;
pub trait StmtCmd {
fn cmd(&self) -> Option<&str>;
fn hash(&self, hasher: &mut impl BuildHasher) -> u64;
}
impl<T> StmtCmd for &T
where
T: StmtCmd,
{
#[inline]
fn cmd(&self) -> Option<&str> {
(**self).cmd()
}
#[inline]
fn hash(&self, hasher: &mut impl BuildHasher) -> u64 {
(**self).hash(hasher)
}
}
impl<T> StmtCmd for &mut T
where
T: StmtCmd,
{
#[inline]
fn cmd(&self) -> Option<&str> {
(**self).cmd()
}
#[inline]
fn hash(&self, hasher: &mut impl BuildHasher) -> u64 {
(**self).hash(hasher)
}
}
impl StmtCmd for u64 {
#[inline]
fn cmd(&self) -> Option<&str> {
None
}
#[inline]
fn hash(&self, _: &mut impl BuildHasher) -> u64 {
*self
}
}
impl StmtCmd for &str {
#[inline]
fn cmd(&self) -> Option<&str> {
Some(self)
}
#[inline]
fn hash(&self, hasher: &mut impl BuildHasher) -> u64 {
hasher.hash_one(self)
}
}
impl StmtCmd for String {
#[inline]
fn cmd(&self) -> Option<&str> {
Some(self)
}
#[inline]
fn hash(&self, hasher: &mut impl BuildHasher) -> u64 {
hasher.hash_one(self)
}
}