fn bins_for_cells(bound_cell_offsets: &[i32], face_width: u32) -> Vec<Option<i32>> {
    let bound_cells = bound_cell_offsets;

    let bin_width_in_cells = bound_cells.pairwise().map(|(&a, &b)| b - a);
    let bins_cell_offset = bound_cells.first().unwrap();

    let mut cell_bins: Vec<Option<i32>> = vec![None]; // start with a prepended negative null
    for (bin, width) in bin_width_in_cells.enumerate() {
        // repeat bin, width times
        for _ in 0..width {
            cell_bins.push(Some(bin as i32));
        }
    }
    cell_bins.push(None); // end with an appended positive null

    if *bins_cell_offset <= 0 {
        cell_bins = cell_bins
            .iter()
            .skip(bins_cell_offset.wrapping_abs() as usize)
            .cloned()
            .collect();
    } else {
        let mut new_bins = vec![None; (*bins_cell_offset) as usize];
        new_bins.extend(cell_bins.iter());
        cell_bins = new_bins;
    }

    if cell_bins.len() <= face_width as usize + 2 {
        let deficit = face_width as usize + 2 - cell_bins.len();
        let mut new_bins = cell_bins;
        new_bins.extend(vec![None; deficit].iter());
        cell_bins = new_bins;
    } else {
        let new_bins = cell_bins;
        cell_bins = new_bins
            .iter()
            .take(face_width as usize + 2)
            .cloned()
            .collect();
    }

    cell_bins
}
/// calculate for each cell which bin it is representing
/// Cells which straddle bins will return the bin just on the lower side of the centre of the cell
/// Will return a vector with (`face_width + 2`) entries to represent underflow and overflow cells
/// cells which do not map to a bin will return `None`.
calculate for each cell which bin it is representing
Cells which straddle bins will return the bin just on the lower side of the centre of the cell
Will return a vector with (`face_width + 2`) entries to represent underflow and overflow cells
cells which do not map to a bin will return `None`.
calculate for each cell which bin it is representing Cells which straddle bins will return the bin just on the lower side of the centre of the cell Will return a vector with ( ` face_width + 2 ` ) entries to represent underflow and overflow cells cells which do not map to a bin will return ` None ` .
fn bins_for_cells(bound_cell_offsets: &[i32], face_width: u32) -> Vec<Option<i32>> {
    let bound_cells = bound_cell_offsets;
    let bin_width_in_cells = bound_cells.pairwise().map(|(&a, &b)| b - a);
    let bins_cell_offset = bound_cells.first().unwrap();
    let mut cell_bins: Vec<Option<i32>> = vec![None]; // start with a prepended negative null
    for (bin, width) in bin_width_in_cells.enumerate() {
        // repeat bin, width times
        for _ in 0..width {
            cell_bins.push(Some(bin as i32));
        }
    }
    cell_bins.push(None); // end with an appended positive null
    if *bins_cell_offset <= 0 {
        cell_bins = cell_bins
            .iter()
            .skip(bins_cell_offset.wrapping_abs() as usize)
            .cloned()
            .collect();
    } else {
        let mut new_bins = vec![None; (*bins_cell_offset) as usize];
        new_bins.extend(cell_bins.iter());
        cell_bins = new_bins;
    }
    if cell_bins.len() <= face_width as usize + 2 {
        let deficit = face_width as usize + 2 - cell_bins.len();
        let mut new_bins = cell_bins;
        new_bins.extend(vec![None; deficit].iter());
        cell_bins = new_bins;
    } else {
        let new_bins = cell_bins;
        cell_bins = new_bins
            .iter()
            .take(face_width as usize + 2)
            .cloned()
            .collect();
    }
    cell_bins
}
fn bins_for_cells ( bound_cell_offsets : & [ i32 ] , face_width : u32 ) -> Vec < Option < i32 > > { let bound_cells = bound_cell_offsets ; let bin_width_in_cells = bound_cells . pairwise ( ) . map ( | ( & a , & b ) | b - a ) ; let bins_cell_offset = bound_cells . first ( ) . unwrap ( ) ; let mut cell_bins : Vec < Option < i32 > > = vec ! [ None ] ; // start with a prepended negative null for ( bin , width ) in bin_width_in_cells . enumerate ( ) { // repeat bin, width times for _ in 0 .. width { cell_bins . push ( Some ( bin as i32 ) ) ; } } cell_bins . push ( None ) ; // end with an appended positive null if * bins_cell_offset <= 0 { cell_bins = cell_bins . iter ( ) . skip ( bins_cell_offset . wrapping_abs ( ) as usize ) . cloned ( ) . collect ( ) ; } else { let mut new_bins = vec ! [ None ( bins_cell_offset ) as usize ] ; new_bins . extend ( cell_bins . iter ( ) ) ; cell_bins = new_bins ; } if cell_bins . len ( ) <= face_width as usize + 2 { let deficit = face_width as usize + 2 - cell_bins . len ( ) ; let mut new_bins = cell_bins ; new_bins . extend ( vec ! [ None deficit ] . iter ( ) ) ; cell_bins = new_bins ; } else { let new_bins = cell_bins ; cell_bins = new_bins . iter ( ) . take ( face_width as usize + 2 ) . cloned ( ) . collect ( ) ; } cell_bins }
calculate for each cell which bin it is representing
Cells which straddle bins will return the bin just on the lower side of the centre of the cell
Will return a vector with (`face_width + 2`) entries to represent underflow and overflow cells
cells which do not map to a bin will return `None`.
calculate for each cell which bin it is representing Cells which straddle bins will return the bin just on the lower side of the centre of the cell Will return a vector with ( ` face_width + 2 ` ) entries to represent underflow and overflow cells cells which do not map to a bin will return ` None ` .
bound_cell_offsets
&[i32]
face_width
u32
bound_cell_offsets
&[i32]
face_width
u32