Skip to content

Commit

Permalink
Use S for the BuildHasher parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
cuviper authored and sug0 committed Feb 29, 2024
1 parent 32793f1 commit b81a4d2
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/borsh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use borsh::{BorshDeserialize, BorshSerialize};
use crate::map::IndexMap;
use crate::set::IndexSet;

impl<K, V, H> BorshSerialize for IndexMap<K, V, H>
impl<K, V, S> BorshSerialize for IndexMap<K, V, S>
where
K: BorshSerialize,
V: BorshSerialize,
Expand All @@ -37,21 +37,21 @@ where
}
}

impl<K, V, H> BorshDeserialize for IndexMap<K, V, H>
impl<K, V, S> BorshDeserialize for IndexMap<K, V, S>
where
K: BorshDeserialize + Eq + Hash,
V: BorshDeserialize,
H: BuildHasher + Default,
S: BuildHasher + Default,
{
#[inline]
fn deserialize_reader<R: Read>(reader: &mut R) -> Result<Self> {
check_zst::<K>()?;
let vec = <Vec<(K, V)>>::deserialize_reader(reader)?;
Ok(vec.into_iter().collect::<IndexMap<K, V, H>>())
Ok(vec.into_iter().collect::<IndexMap<K, V, S>>())
}
}

impl<T, H> BorshSerialize for IndexSet<T, H>
impl<T, S> BorshSerialize for IndexSet<T, S>
where
T: BorshSerialize,
{
Expand All @@ -73,16 +73,16 @@ where
}
}

impl<T, H> BorshDeserialize for IndexSet<T, H>
impl<T, S> BorshDeserialize for IndexSet<T, S>
where
T: BorshDeserialize + Eq + Hash,
H: BuildHasher + Default,
S: BuildHasher + Default,
{
#[inline]
fn deserialize_reader<R: Read>(reader: &mut R) -> Result<Self> {
check_zst::<T>()?;
let vec = <Vec<T>>::deserialize_reader(reader)?;
Ok(vec.into_iter().collect::<IndexSet<T, H>>())
Ok(vec.into_iter().collect::<IndexSet<T, S>>())
}
}

Expand Down

0 comments on commit b81a4d2

Please sign in to comment.