fn next(&mut self) -> Option<Self::Item> {
        //  Loop over all Pixel Rows until we have composed a Pixel Block, or we have run out of Pixel Rows.
        loop {
            //  Get the next Pixel Row.
            let next_row = self.rows.next();
            match next_row {
                None => {
                    //  If no more Pixel Rows...
                    if self.first_row {
                        return None; //  No rows to group
                    }
                    //  Else return previous rows as block.
                    let row = PixelBlock {
                        x_left: self.x_left,
                        x_right: self.x_right,
                        y_top: self.y_top,
                        y_bottom: self.y_bottom,
                        colors: self.colors.clone(),
                    };
                    self.colors.clear();
                    self.first_row = true;
                    return Some(row);
                }
                Some(PixelRow {
                    x_left,
                    x_right,
                    y,
                    colors,
                    ..
                }) => {
                    //  If there is a Pixel Row...
                    //  Save the first row as the block start and handle next block.
                    if self.first_row {
                        self.first_row = false;
                        self.x_left = x_left;
                        self.x_right = x_right;
                        self.y_top = y;
                        self.y_bottom = y;
                        self.colors.clear();
                        self.colors.extend_from_slice(&colors).expect("never");
                        continue;
                    }
                    //  If this row is adjacent to the previous row and same size, add to the block.
                    if y == self.y_bottom + 1 && x_left == self.x_left && x_right == self.x_right {
                        //  Don't add row if too many pixels in the block.
                        if self.colors.extend_from_slice(&colors).is_ok() {
                            self.y_bottom = y;
                            continue;
                        }
                    }
                    //  Else return previous rows as block.
                    let row = PixelBlock {
                        x_left: self.x_left,
                        x_right: self.x_right,
                        y_top: self.y_top,
                        y_bottom: self.y_bottom,
                        colors: self.colors.clone(),
                    };
                    self.x_left = x_left;
                    self.x_right = x_right;
                    self.y_top = y;
                    self.y_bottom = y;
                    self.colors.clear();
                    self.colors.extend_from_slice(&colors).expect("never");
                    return Some(row);
                }
            }
        }
    }
/// Return the next Pixel Block of contiguous Pixel Rows with the same start and end column number
Return the next Pixel Block of contiguous Pixel Rows with the same start and end column number
Return the next Pixel Block of contiguous Pixel Rows with the same start and end column number
fn next(&mut self) -> Option<Self::Item> {
        //  Loop over all Pixel Rows until we have composed a Pixel Block, or we have run out of Pixel Rows.
        loop {
            //  Get the next Pixel Row.
            let next_row = self.rows.next();
            match next_row {
                None => {
                    //  If no more Pixel Rows...
                    if self.first_row {
                        return None; //  No rows to group
                    }
                    //  Else return previous rows as block.
                    let row = PixelBlock {
                        x_left: self.x_left,
                        x_right: self.x_right,
                        y_top: self.y_top,
                        y_bottom: self.y_bottom,
                        colors: self.colors.clone(),
                    };
                    self.colors.clear();
                    self.first_row = true;
                    return Some(row);
                }
                Some(PixelRow {
                    x_left,
                    x_right,
                    y,
                    colors,
                    ..
                }) => {
                    //  If there is a Pixel Row...
                    //  Save the first row as the block start and handle next block.
                    if self.first_row {
                        self.first_row = false;
                        self.x_left = x_left;
                        self.x_right = x_right;
                        self.y_top = y;
                        self.y_bottom = y;
                        self.colors.clear();
                        self.colors.extend_from_slice(&colors).expect("never");
                        continue;
                    }
                    //  If this row is adjacent to the previous row and same size, add to the block.
                    if y == self.y_bottom + 1 && x_left == self.x_left && x_right == self.x_right {
                        //  Don't add row if too many pixels in the block.
                        if self.colors.extend_from_slice(&colors).is_ok() {
                            self.y_bottom = y;
                            continue;
                        }
                    }
                    //  Else return previous rows as block.
                    let row = PixelBlock {
                        x_left: self.x_left,
                        x_right: self.x_right,
                        y_top: self.y_top,
                        y_bottom: self.y_bottom,
                        colors: self.colors.clone(),
                    };
                    self.x_left = x_left;
                    self.x_right = x_right;
                    self.y_top = y;
                    self.y_bottom = y;
                    self.colors.clear();
                    self.colors.extend_from_slice(&colors).expect("never");
                    return Some(row);
                }
            }
        }
    }
fn next ( & mut self ) -> Option < Self :: Item > { //  Loop over all Pixel Rows until we have composed a Pixel Block, or we have run out of Pixel Rows. loop { //  Get the next Pixel Row. let next_row = self . rows . next ( ) ; match next_row { None => { //  If no more Pixel Rows... if self . first_row { return None ; //  No rows to group } //  Else return previous rows as block. let row = PixelBlock { x_left : self . x_left , x_right : self . x_right , y_top : self . y_top , y_bottom : self . y_bottom , colors : self . colors . clone ( ) , } ; self . colors . clear ( ) ; self . first_row = true ; return Some ( row ) ; } Some ( PixelRow { x_left , x_right , y , colors , .. } ) => { //  If there is a Pixel Row... //  Save the first row as the block start and handle next block. if self . first_row { self . first_row = false ; self . x_left = x_left ; self . x_right = x_right ; self . y_top = y ; self . y_bottom = y ; self . colors . clear ( ) ; self . colors . extend_from_slice ( & colors ) . expect ( " " ) ; continue ; } //  If this row is adjacent to the previous row and same size, add to the block. if y == self . y_bottom + 1 && x_left == self . x_left && x_right == self . x_right { //  Don't add row if too many pixels in the block. if self . colors . extend_from_slice ( & colors ) . is_ok ( ) { self . y_bottom = y ; continue ; } } //  Else return previous rows as block. let row = PixelBlock { x_left : self . x_left , x_right : self . x_right , y_top : self . y_top , y_bottom : self . y_bottom , colors : self . colors . clone ( ) , } ; self . x_left = x_left ; self . x_right = x_right ; self . y_top = y ; self . y_bottom = y ; self . colors . clear ( ) ; self . colors . extend_from_slice ( & colors ) . expect ( " " ) ; return Some ( row ) ; } } } }
Return the next Pixel Block of contiguous Pixel Rows with the same start and end column number
Return the next Pixel Block of contiguous Pixel Rows with the same start and end column number
&mut self
&mut self