Skip to content
Snippets Groups Projects
Commit 328c5153 authored by Éloïs's avatar Éloïs
Browse files

feat(kv_typed): impl AsBytes for all SmallVec (use const generics)

parent 6bfb4921
No related branches found
No related tags found
No related merge requests found
...@@ -26,20 +26,16 @@ where ...@@ -26,20 +26,16 @@ where
} }
} }
macro_rules! impl_as_bytes_for_smallvec { impl<T, const N: usize> AsBytes for SmallVec<[T; N]>
($($N:literal),*) => {$(
impl<T> AsBytes for SmallVec<[T; $N]>
where where
T: zerocopy::AsBytes, T: zerocopy::AsBytes,
[T; N]: smallvec::Array<Item = T>,
{ {
fn as_bytes<D, F: FnMut(&[u8]) -> D>(&self, mut f: F) -> D { fn as_bytes<D, F: FnMut(&[u8]) -> D>(&self, mut f: F) -> D {
use zerocopy::AsBytes as _; use zerocopy::AsBytes as _;
f((&self[..]).as_bytes()) f((&self[..]).as_bytes())
} }
} }
)*};
}
impl_as_bytes_for_smallvec!(1, 2, 4, 8, 16, 32, 64);
impl<T> AsBytes for BTreeSet<T> impl<T> AsBytes for BTreeSet<T>
where where
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment