fn next(&mut self) -> Option<Self::Item> {
        //  Loop over all pixels until we have composed a Pixel Row, or we have run out of pixels.
        loop {
            //  Get the next pixel.
            let next_pixel = self.pixels.next();
            match next_pixel {
                None => {
                    //  If no more pixels...
                    if self.first_pixel {
                        return None; //  No pixels to group
                    }
                    //  Else return previous pixels as row.
                    let row = PixelRow {
                        x_left: self.x_left,
                        x_right: self.x_right,
                        y: self.y,
                        colors: self.colors.clone(),
                    };
                    self.colors.clear();
                    self.first_pixel = true;
                    return Some(row);
                }
                Some(Pixel(coord, color)) => {
                    //  If there is a pixel...
                    let x = coord.x as u16;
                    let y = coord.y as u16;
                    let color = RawU16::from(color).into_inner();
                    //  Save the first pixel as the row start and handle next pixel.
                    if self.first_pixel {
                        self.first_pixel = false;
                        self.x_left = x;
                        self.x_right = x;
                        self.y = y;
                        self.colors.clear();
                        self.colors.push(color).expect("never");
                        continue;
                    }
                    //  If this pixel is adjacent to the previous pixel, add to the row.
                    if x == self.x_right.wrapping_add(1)
                        && y == self.y
                        && self.colors.push(color).is_ok()
                    {
                        // Don't add pixel if too many pixels in the row.
                        self.x_right = x;
                        continue;
                    }
                    //  Else return previous pixels as row.
                    let row = PixelRow {
                        x_left: self.x_left,
                        x_right: self.x_right,
                        y: self.y,
                        colors: self.colors.clone(),
                    };
                    self.x_left = x;
                    self.x_right = x;
                    self.y = y;
                    self.colors.clear();
                    self.colors.push(color).expect("never");
                    return Some(row);
                }
            }
        }
    }
/// Return the next Pixel Row of contiguous pixels on the same row
Return the next Pixel Row of contiguous pixels on the same row
Return the next Pixel Row of contiguous pixels on the same row
fn next(&mut self) -> Option<Self::Item> {
        //  Loop over all pixels until we have composed a Pixel Row, or we have run out of pixels.
        loop {
            //  Get the next pixel.
            let next_pixel = self.pixels.next();
            match next_pixel {
                None => {
                    //  If no more pixels...
                    if self.first_pixel {
                        return None; //  No pixels to group
                    }
                    //  Else return previous pixels as row.
                    let row = PixelRow {
                        x_left: self.x_left,
                        x_right: self.x_right,
                        y: self.y,
                        colors: self.colors.clone(),
                    };
                    self.colors.clear();
                    self.first_pixel = true;
                    return Some(row);
                }
                Some(Pixel(coord, color)) => {
                    //  If there is a pixel...
                    let x = coord.x as u16;
                    let y = coord.y as u16;
                    let color = RawU16::from(color).into_inner();
                    //  Save the first pixel as the row start and handle next pixel.
                    if self.first_pixel {
                        self.first_pixel = false;
                        self.x_left = x;
                        self.x_right = x;
                        self.y = y;
                        self.colors.clear();
                        self.colors.push(color).expect("never");
                        continue;
                    }
                    //  If this pixel is adjacent to the previous pixel, add to the row.
                    if x == self.x_right.wrapping_add(1)
                        && y == self.y
                        && self.colors.push(color).is_ok()
                    {
                        // Don't add pixel if too many pixels in the row.
                        self.x_right = x;
                        continue;
                    }
                    //  Else return previous pixels as row.
                    let row = PixelRow {
                        x_left: self.x_left,
                        x_right: self.x_right,
                        y: self.y,
                        colors: self.colors.clone(),
                    };
                    self.x_left = x;
                    self.x_right = x;
                    self.y = y;
                    self.colors.clear();
                    self.colors.push(color).expect("never");
                    return Some(row);
                }
            }
        }
    }
fn next ( & mut self ) -> Option < Self :: Item > { //  Loop over all pixels until we have composed a Pixel Row, or we have run out of pixels. loop { //  Get the next pixel. let next_pixel = self . pixels . next ( ) ; match next_pixel { None => { //  If no more pixels... if self . first_pixel { return None ; //  No pixels to group } //  Else return previous pixels as row. let row = PixelRow { x_left : self . x_left , x_right : self . x_right , y : self . y , colors : self . colors . clone ( ) , } ; self . colors . clear ( ) ; self . first_pixel = true ; return Some ( row ) ; } Some ( Pixel ( coord , color ) ) => { //  If there is a pixel... let x = coord . x as u16 ; let y = coord . y as u16 ; let color = RawU16 :: from ( color ) . into_inner ( ) ; //  Save the first pixel as the row start and handle next pixel. if self . first_pixel { self . first_pixel = false ; self . x_left = x ; self . x_right = x ; self . y = y ; self . colors . clear ( ) ; self . colors . push ( color ) . expect ( " " ) ; continue ; } //  If this pixel is adjacent to the previous pixel, add to the row. if x == self . x_right . wrapping_add ( 1 ) && y == self . y && self . colors . push ( color ) . is_ok ( ) { // Don't add pixel if too many pixels in the row. self . x_right = x ; continue ; } //  Else return previous pixels as row. let row = PixelRow { x_left : self . x_left , x_right : self . x_right , y : self . y , colors : self . colors . clone ( ) , } ; self . x_left = x ; self . x_right = x ; self . y = y ; self . colors . clear ( ) ; self . colors . push ( color ) . expect ( " " ) ; return Some ( row ) ; } } } }
Return the next Pixel Row of contiguous pixels on the same row
Return the next Pixel Row of contiguous pixels on the same row
&mut self
&mut self