use crate::Result;
pub trait Read<'l>: Sized {
type Parameter;
fn read<T: crate::tape::Read>(_: &mut T, _: Self::Parameter) -> Result<Self>;
}
pub trait Write<'l> {
type Parameter;
fn write<T: crate::tape::Write>(&self, _: &mut T, _: Self::Parameter) -> Result<()>;
}
impl<V> Read<'static> for Vec<V>
where
V: crate::value::Read,
{
type Parameter = usize;
fn read<T: crate::tape::Read>(tape: &mut T, count: usize) -> Result<Self> {
let mut values = Vec::with_capacity(count);
for _ in 0..count {
values.push(crate::value::Read::read(tape)?);
}
Ok(values)
}
}