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