buffered 0.1.0

Implement SOA for independently buffered streams
Documentation
pub trait Buffered {
    type Fields;
    fn push_field(&mut self, field: Self::Fields) -> Result<(), Self::Fields>;
}

#[cfg(test)]
mod test {
    use super::*;
    use buffered_derive::buffered;

    #[derive(Debug)]
    #[buffered]
    struct Josh {
        x: u32,
        y: u8,
        z: f32
    }

    #[test]
    fn push_1() {
        let mut x = JoshBuffered::new();

        x.push_field(JoshFields::X(1)).expect("Failed to push X");
        x.push_field(JoshFields::Y(100)).expect("Failed to push Y");
        x.push_field(JoshFields::Z(10.0)).expect("Failed to push Y");

        assert_eq!(x.x, vec![1]);
        assert_eq!(x.y, vec![100]);
        assert_eq!(x.z, vec![10.0]);
    }

    #[test]
    fn push_100() {
        let mut buf = JoshBuffered::new();

        let xs: Vec<_> = (0..100).map(|x| x * x).collect();
        let ys: Vec<_> = (0..100).map(|x| x + x).collect();

        xs.iter()
            .for_each(|x| buf.push_field(JoshFields::X(*x)).expect("Failed to push X"));
        ys.iter()
            .for_each(|x| buf.push_field(JoshFields::Y(*x)).expect("Failed to push Y"));

        assert_eq!(buf.x, xs);
        assert_eq!(buf.y, ys);
    }
}