@@ -644,7 +644,7 @@ where
644
644
/// image::imageops::overlay(&mut img, &on_top, 128, 128);
645
645
/// ```
646
646
///
647
- /// Convert an RgbaImage to a GrayImage.
647
+ /// Convert an ` RgbaImage` to a ` GrayImage` .
648
648
///
649
649
/// ```no_run
650
650
/// use image::{open, DynamicImage};
@@ -801,7 +801,7 @@ where
801
801
/// the bounds will not overflow.
802
802
fn check_image_fits ( width : u32 , height : u32 , len : usize ) -> bool {
803
803
let checked_len = Self :: image_buffer_len ( width, height) ;
804
- checked_len. map ( |min_len| min_len <= len) . unwrap_or ( false )
804
+ checked_len. map_or ( false , |min_len| min_len <= len)
805
805
}
806
806
807
807
fn image_buffer_len ( width : u32 , height : u32 ) -> Option < usize > {
@@ -980,7 +980,7 @@ where
980
980
#[ inline]
981
981
#[ track_caller]
982
982
pub fn put_pixel ( & mut self , x : u32 , y : u32 , pixel : P ) {
983
- * self . get_pixel_mut ( x, y) = pixel
983
+ * self . get_pixel_mut ( x, y) = pixel;
984
984
}
985
985
}
986
986
@@ -1198,22 +1198,22 @@ where
1198
1198
}
1199
1199
1200
1200
fn put_pixel ( & mut self , x : u32 , y : u32 , pixel : P ) {
1201
- * self . get_pixel_mut ( x, y) = pixel
1201
+ * self . get_pixel_mut ( x, y) = pixel;
1202
1202
}
1203
1203
1204
1204
/// Puts a pixel at location (x, y), ignoring bounds checking.
1205
1205
#[ inline( always) ]
1206
1206
unsafe fn unsafe_put_pixel ( & mut self , x : u32 , y : u32 , pixel : P ) {
1207
1207
let indices = self . pixel_indices_unchecked ( x, y) ;
1208
1208
let p = <P as Pixel >:: from_slice_mut ( self . data . get_unchecked_mut ( indices) ) ;
1209
- * p = pixel
1209
+ * p = pixel;
1210
1210
}
1211
1211
1212
1212
/// Put a pixel at location (x, y), taking into account alpha channels
1213
1213
///
1214
1214
/// DEPRECATED: This method will be removed. Blend the pixel directly instead.
1215
1215
fn blend_pixel ( & mut self , x : u32 , y : u32 , p : P ) {
1216
- self . get_pixel_mut ( x, y) . blend ( & p)
1216
+ self . get_pixel_mut ( x, y) . blend ( & p) ;
1217
1217
}
1218
1218
1219
1219
fn copy_within ( & mut self , source : Rect , x : u32 , y : u32 ) -> bool {
@@ -1268,6 +1268,7 @@ impl<P: Pixel> ImageBuffer<P, Vec<P::Subpixel>> {
1268
1268
/// # Panics
1269
1269
///
1270
1270
/// Panics when the resulting image is larger than the maximum size of a vector.
1271
+ #[ must_use]
1271
1272
pub fn new ( width : u32 , height : u32 ) -> ImageBuffer < P , Vec < P :: Subpixel > > {
1272
1273
let size = Self :: image_buffer_len ( width, height)
1273
1274
. expect ( "Buffer length in `ImageBuffer::new` overflows usize" ) ;
@@ -1279,20 +1280,20 @@ impl<P: Pixel> ImageBuffer<P, Vec<P::Subpixel>> {
1279
1280
}
1280
1281
}
1281
1282
1282
- /// Constructs a new ImageBuffer by copying a pixel
1283
+ /// Constructs a new ` ImageBuffer` by copying a pixel
1283
1284
///
1284
1285
/// # Panics
1285
1286
///
1286
1287
/// Panics when the resulting image is larger the the maximum size of a vector.
1287
1288
pub fn from_pixel ( width : u32 , height : u32 , pixel : P ) -> ImageBuffer < P , Vec < P :: Subpixel > > {
1288
1289
let mut buf = ImageBuffer :: new ( width, height) ;
1289
1290
for p in buf. pixels_mut ( ) {
1290
- * p = pixel
1291
+ * p = pixel;
1291
1292
}
1292
1293
buf
1293
1294
}
1294
1295
1295
- /// Constructs a new ImageBuffer by repeated application of the supplied function.
1296
+ /// Constructs a new ` ImageBuffer` by repeated application of the supplied function.
1296
1297
///
1297
1298
/// The arguments to the function are the pixel's x and y coordinates.
1298
1299
///
@@ -1305,13 +1306,14 @@ impl<P: Pixel> ImageBuffer<P, Vec<P::Subpixel>> {
1305
1306
{
1306
1307
let mut buf = ImageBuffer :: new ( width, height) ;
1307
1308
for ( x, y, p) in buf. enumerate_pixels_mut ( ) {
1308
- * p = f ( x, y)
1309
+ * p = f ( x, y) ;
1309
1310
}
1310
1311
buf
1311
1312
}
1312
1313
1313
1314
/// Creates an image buffer out of an existing buffer.
1314
1315
/// Returns None if the buffer is not big enough.
1316
+ #[ must_use]
1315
1317
pub fn from_vec (
1316
1318
width : u32 ,
1317
1319
height : u32 ,
@@ -1322,6 +1324,7 @@ impl<P: Pixel> ImageBuffer<P, Vec<P::Subpixel>> {
1322
1324
1323
1325
/// Consumes the image buffer and returns the underlying data
1324
1326
/// as an owned buffer
1327
+ #[ must_use]
1325
1328
pub fn into_vec ( self ) -> Vec < P :: Subpixel > {
1326
1329
self . into_raw ( )
1327
1330
}
@@ -1341,6 +1344,7 @@ impl GrayImage {
1341
1344
/// Expands a color palette by re-using the existing buffer.
1342
1345
/// Assumes 8 bit per pixel. Uses an optionally transparent index to
1343
1346
/// adjust it's alpha value accordingly.
1347
+ #[ must_use]
1344
1348
pub fn expand_palette (
1345
1349
self ,
1346
1350
palette : & [ ( u8 , u8 , u8 ) ] ,
@@ -1397,7 +1401,7 @@ where
1397
1401
let mut buffer: ImageBuffer < ToType , Vec < ToType :: Subpixel > > =
1398
1402
ImageBuffer :: new ( self . width , self . height ) ;
1399
1403
for ( to, from) in buffer. pixels_mut ( ) . zip ( self . pixels ( ) ) {
1400
- to. from_color ( from)
1404
+ to. from_color ( from) ;
1401
1405
}
1402
1406
buffer
1403
1407
}
0 commit comments