@@ -74,7 +74,7 @@ struct Ifd<'a> {
7474 jpeg : Option < & ' a [ u8 ] > ,
7575}
7676
77- impl < ' a > Ifd < ' a > {
77+ impl Ifd < ' _ > {
7878 fn is_empty ( & self ) -> bool {
7979 self . tiff_fields . is_empty ( ) &&
8080 self . exif_fields . is_empty ( ) &&
@@ -191,7 +191,7 @@ impl<'a> Writer<'a> {
191191 ifd_num_ck. ok_or ( Error :: InvalidFormat ( "Too many IFDs" ) ) ?;
192192 if ifd_num > 0 {
193193 let next_ifd_offset = pad_and_get_offset ( w) ?;
194- let origpos = w. seek ( SeekFrom :: Current ( 0 ) ) ?;
194+ let origpos = w. stream_position ( ) ?;
195195 w. seek ( SeekFrom :: Start ( next_ifd_offset_offset as u64 ) ) ?;
196196 match little_endian {
197197 false => BigEndian :: writeu32 ( w, next_ifd_offset) ?,
@@ -342,15 +342,15 @@ fn write_image<W, E>(w: &mut W, ws: &WriterState, ifd: &Ifd)
342342 strip_offsets_offset, tile_offsets_offset, jpeg_offset) =
343343 write_ifd_and_fields :: < _ , E > (
344344 w, & ws. tiff_fields , ws. tiff_ifd_offset ) ?;
345- if ws. exif_fields . len ( ) > 0 {
345+ if ! ws. exif_fields . is_empty ( ) {
346346 write_ifd_and_fields :: < _ , E > (
347347 w, & ws. exif_fields , ws. exif_ifd_offset ) ?;
348348 }
349- if ws. gps_fields . len ( ) > 0 {
349+ if ! ws. gps_fields . is_empty ( ) {
350350 write_ifd_and_fields :: < _ , E > (
351351 w, & ws. gps_fields , ws. gps_ifd_offset ) ?;
352352 }
353- if ws. interop_fields . len ( ) > 0 {
353+ if ! ws. interop_fields . is_empty ( ) {
354354 write_ifd_and_fields :: < _ , E > (
355355 w, & ws. interop_fields , ws. interop_ifd_offset ) ?;
356356 }
@@ -361,7 +361,7 @@ fn write_image<W, E>(w: &mut W, ws: &WriterState, ifd: &Ifd)
361361 strip_offsets. push ( get_offset ( w) ?) ;
362362 w. write_all ( strip) ?;
363363 }
364- let origpos = w. seek ( SeekFrom :: Current ( 0 ) ) ?;
364+ let origpos = w. stream_position ( ) ?;
365365 w. seek ( SeekFrom :: Start ( strip_offsets_offset as u64 ) ) ?;
366366 for ofs in strip_offsets {
367367 E :: writeu32 ( w, ofs) ?;
@@ -374,7 +374,7 @@ fn write_image<W, E>(w: &mut W, ws: &WriterState, ifd: &Ifd)
374374 tile_offsets. push ( get_offset ( w) ?) ;
375375 w. write_all ( tile) ?;
376376 }
377- let origpos = w. seek ( SeekFrom :: Current ( 0 ) ) ?;
377+ let origpos = w. stream_position ( ) ?;
378378 w. seek ( SeekFrom :: Start ( tile_offsets_offset as u64 ) ) ?;
379379 for ofs in tile_offsets {
380380 E :: writeu32 ( w, ofs) ?;
@@ -384,7 +384,7 @@ fn write_image<W, E>(w: &mut W, ws: &WriterState, ifd: &Ifd)
384384 if let Some ( jpeg) = ifd. jpeg {
385385 let offset = get_offset ( w) ?;
386386 w. write_all ( jpeg) ?;
387- let origpos = w. seek ( SeekFrom :: Current ( 0 ) ) ?;
387+ let origpos = w. stream_position ( ) ?;
388388 w. seek ( SeekFrom :: Start ( jpeg_offset as u64 ) ) ?;
389389 E :: writeu32 ( w, offset) ?;
390390 w. seek ( SeekFrom :: Start ( origpos) ) ?;
@@ -552,7 +552,7 @@ fn compose_value<E>(value: &Value)
552552
553553fn write_at < W > ( w : & mut W , buf : & [ u8 ] , offset : u32 )
554554 -> io:: Result < ( ) > where W : Write + Seek {
555- let orig = w. seek ( SeekFrom :: Current ( 0 ) ) ?;
555+ let orig = w. stream_position ( ) ?;
556556 w. seek ( SeekFrom :: Start ( offset as u64 ) ) ?;
557557 w. write_all ( buf) ?;
558558 w. seek ( SeekFrom :: Start ( orig) ) ?;
@@ -562,7 +562,7 @@ fn write_at<W>(w: &mut W, buf: &[u8], offset: u32)
562562// Aligns `w` to the two-byte (word) boundary and returns the new offset.
563563fn pad_and_get_offset < W > ( w : & mut W )
564564 -> Result < u32 , Error > where W : Write + Seek {
565- let mut pos = w. seek ( SeekFrom :: Current ( 0 ) ) ?;
565+ let mut pos = w. stream_position ( ) ?;
566566 if pos >= ( 1 << 32 ) - 1 {
567567 return Err ( Error :: TooBig ( "Offset too large" ) ) ;
568568 }
@@ -575,7 +575,7 @@ fn pad_and_get_offset<W>(w: &mut W)
575575
576576fn get_offset < W > ( w : & mut W )
577577 -> Result < u32 , Error > where W : Write + Seek {
578- let pos = w. seek ( SeekFrom :: Current ( 0 ) ) ?;
578+ let pos = w. stream_position ( ) ?;
579579 if pos as u32 as u64 != pos {
580580 return Err ( Error :: TooBig ( "Offset too large" ) ) ;
581581 }
0 commit comments