Tue Feb 3 13:59:49 EST 2015

still running into corner cases with iterator

    It's not possible to type ther return value as an Iterator
    because that's a trait so would either require trait objects
    (which seem to cause lifetime problems) or implement the
    Iterator trait using a struct which requires a lot of boiler
    plate.  It seems easier to just type the functions with the
    concrete return type (that implements the Iterator trait).
    use std::iter::{Counter,Take,Map,count};
    use std::ops::{Range};
    //use core::ops::{Fn};
    extern crate core;
    fn bits_bit(c: &Config, v: usize) -> Take<Counter<usize>> { count(v,0).take(c.period) }
    fn bits_frame(c: &Config, v: usize) -> Map<usize,usize,Range<usize>,Fn(usize)->usize> {
        (0us..c.nb_bits+2).map(|&:bit:usize| (((v | (1 << c.nb_bits)) << 1) >> bit) & 1)
    fn bits_samples(c: &Config, data: &Vec<usize>) -> Vec<usize> {
        data.iter().flat_map(|&x| bits_frame(c, x)).collect()