@@ -50,7 +50,11 @@ impl Nine {
5050 ///
5151 /// This returns true if any of the pixels in the set have an alpha value
5252 /// of zero.
53- fn has_invisible ( & self ) -> bool { self . 0 . chunks_exact ( 4 ) . any ( |px| px[ 3 ] == 0 ) }
53+ fn has_invisible ( & self ) -> bool {
54+ self . 0 . as_chunks :: < 4 > ( ) . 0
55+ . iter ( )
56+ . any ( |px| px[ 3 ] == 0 )
57+ }
5458
5559 #[ inline]
5660 /// # Is Semi-Transparent?
@@ -77,7 +81,8 @@ impl Nine {
7781 /// If the result turns out to be identical to the original value, `None`
7882 /// is returned.
7983 fn averaged ( & self ) -> Option < [ u8 ; 4 ] > {
80- let ( r, g, b) = self . 0 . chunks_exact ( 4 )
84+ let ( r, g, b) = self . 0 . as_chunks :: < 4 > ( ) . 0
85+ . iter ( )
8186 . fold ( ( 0_u16 , 0_u16 , 0_u16 ) , |mut acc, px| {
8287 acc. 0 += u16:: from ( px[ 0 ] ) ;
8388 acc. 1 += u16:: from ( px[ 1 ] ) ;
@@ -126,7 +131,8 @@ impl Nine {
126131 /// If no weighting is possible, or if the result winds up identical to the
127132 /// original, `None` is returned.
128133 fn weighted ( & self ) -> Option < [ u8 ; 4 ] > {
129- let ( r, g, b, weight) = self . 0 . chunks_exact ( 4 )
134+ let ( r, g, b, weight) = self . 0 . as_chunks :: < 4 > ( ) . 0
135+ . iter ( )
130136 . fold ( ( 0_u32 , 0_u32 , 0_u32 , 0_u32 ) , |mut acc, px| {
131137 if px[ 3 ] > 0 {
132138 let weight = 256 - u32:: from ( px[ 3 ] ) ;
@@ -166,7 +172,8 @@ impl Nine {
166172pub ( super ) fn clean_alpha ( img : & mut [ u8 ] , width : usize , height : usize ) {
167173 if let Some ( avg) = neutral_pixel ( img, width, height) {
168174 // Set all invisible pixels to said neutral color.
169- img. chunks_exact_mut ( 4 )
175+ img. as_chunks_mut :: < 4 > ( ) . 0
176+ . iter_mut ( )
170177 . filter ( |px| px[ 3 ] == 0 )
171178 . for_each ( |px| { px. copy_from_slice ( & avg) ; } ) ;
172179
@@ -284,7 +291,7 @@ where Cb: FnMut(Nine) {
284291
285292 // Start each row with 0, 0, 1 columns. We know there's always going to
286293 // be a +1 because we refuse images with widths < 3.
287- for ( chunk, k) in nine. 0 . chunks_exact_mut ( 12 ) . zip ( [ top, middle, bottom] ) {
294+ for ( chunk, k) in nine. 0 . as_chunks_mut :: < 12 > ( ) . 0 . iter_mut ( ) . zip ( [ top, middle, bottom] ) {
288295 chunk[ ..4 ] . copy_from_slice ( & img[ k..k + 4 ] ) ;
289296 chunk[ 4 ..] . copy_from_slice ( & img[ k..k + 8 ] ) ;
290297 }
@@ -295,14 +302,14 @@ where Cb: FnMut(Nine) {
295302 // Loop the columns.
296303 for x in 1 ..width {
297304 // Shift the old middle and right positions down for each row.
298- for chunk in nine. 0 . chunks_exact_mut ( 12 ) {
305+ for chunk in nine. 0 . as_chunks_mut :: < 12 > ( ) . 0 {
299306 chunk. copy_within ( 4 .., 0 ) ;
300307 }
301308
302309 // Copy in the new right positions, if any.
303310 if x + 1 < width {
304311 let right = ( x + 1 ) * 4 ;
305- for ( chunk, k) in nine. 0 . chunks_exact_mut ( 12 ) . zip ( [ top, middle, bottom] ) {
312+ for ( chunk, k) in nine. 0 . as_chunks_mut :: < 12 > ( ) . 0 . iter_mut ( ) . zip ( [ top, middle, bottom] ) {
306313 chunk[ 8 ..] . copy_from_slice ( & img[ k + right..k + right + 4 ] ) ;
307314 }
308315 }
0 commit comments