use super::Encode;
impl<T: Encode, const N: usize> Encode for [T; N] {
type Context = T::Context;
#[inline]
fn encode<E: super::EntropyCoder>(&self, writer: &mut E, ctx: &mut Self::Context) {
for v in self {
v.encode(writer, ctx);
}
}
#[inline]
fn decode<D: super::EntropyDecoder>(
reader: &mut D,
ctx: &mut Self::Context,
) -> Result<Self, std::io::Error> {
let mut x = Vec::with_capacity(N);
for _ in 0..N {
x.push(T::decode(reader, ctx)?);
}
x.try_into()
.map_err(|_| std::io::Error::other("impossible: x should have N values"))
}
}