use std::io::Result;
use crate::Input;
pub(crate) struct BoxedDynInput<'a, T> {
input: Box<dyn Input<Item = T> + 'a>,
}
impl<'a, T> BoxedDynInput<'a, T> {
#[inline(always)]
pub(crate) const fn new(input: Box<dyn Input<Item = T> + 'a>) -> Self {
Self { input }
}
}
impl<T> Input for BoxedDynInput<'_, T> {
type Item = T;
#[inline(always)]
unsafe fn read_unchecked(
&mut self,
output: &mut [Self::Item],
index: usize,
count: usize,
) -> Result<usize> {
unsafe { self.input.read_unchecked(output, index, count) }
}
}