Fix straightforward cast/borrow lints
This commit is contained in:
1 parent
2942f9de97
commit
ca74c03520
4 files changed
+8
-12
No files matched your search
+1
-1
@@ -445,7 +445,7 @@ impl Entry {
|
|||||||
// 2b: the value is at most 4 bytes or doesn't fit in the offset field.
|
// 2b: the value is at most 4 bytes or doesn't fit in the offset field.
|
||||||
return Ok(match self.type_ {
|
return Ok(match self.type_ {
|
||||||
Type::BYTE => Byte(self.offset[0]),
|
Type::BYTE => Byte(self.offset[0]),
|
||||||
Type::SBYTE => SignedByte(i8::from(self.offset[0] as i8)),
|
Type::SBYTE => SignedByte(self.offset[0] as i8),
|
||||||
Type::UNDEFINED => Byte(self.offset[0]),
|
Type::UNDEFINED => Byte(self.offset[0]),
|
||||||
Type::SHORT => Short(self.r(bo).read_u16()?),
|
Type::SHORT => Short(self.r(bo).read_u16()?),
|
||||||
Type::SSHORT => SignedShort(self.r(bo).read_i16()?),
|
Type::SSHORT => SignedShort(self.r(bo).read_i16()?),
|
||||||
|
|||||||
@@ -643,11 +643,11 @@ impl Image {
|
|||||||
self.jpeg_tables.as_deref().map(|a| &**a),
|
self.jpeg_tables.as_deref().map(|a| &**a),
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
if output_row_stride == chunk_row_bytes as usize {
|
if output_row_stride == chunk_row_bytes {
|
||||||
let tile = &mut buf[..chunk_row_bytes * data_dims.1 as usize];
|
let tile = &mut buf[..chunk_row_bytes * data_dims.1 as usize];
|
||||||
reader.read_exact(tile)?;
|
reader.read_exact(tile)?;
|
||||||
|
|
||||||
for row in tile.chunks_mut(chunk_row_bytes as usize) {
|
for row in tile.chunks_mut(chunk_row_bytes) {
|
||||||
super::fix_endianness_and_predict(
|
super::fix_endianness_and_predict(
|
||||||
row,
|
row,
|
||||||
color_type.bit_depth(),
|
color_type.bit_depth(),
|
||||||
@@ -678,11 +678,7 @@ impl Image {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (_i, row) in buf
|
for row in buf.chunks_mut(output_row_stride).take(data_dims.1 as usize) {
|
||||||
.chunks_mut(output_row_stride)
|
|
||||||
.take(data_dims.1 as usize)
|
|
||||||
.enumerate()
|
|
||||||
{
|
|
||||||
let row = &mut row[..data_row_bytes];
|
let row = &mut row[..data_row_bytes];
|
||||||
reader.read_exact(row)?;
|
reader.read_exact(row)?;
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -296,7 +296,7 @@ impl<'a, W: 'a + Write + Seek, K: TiffKind> DirectoryEncoder<'a, W, K> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let entry = Self::write_value(
|
let entry = Self::write_value(
|
||||||
&mut self.writer,
|
self.writer,
|
||||||
&DirectoryEntry {
|
&DirectoryEntry {
|
||||||
data_type: <T>::FIELD_TYPE,
|
data_type: <T>::FIELD_TYPE,
|
||||||
count: value.count().try_into()?,
|
count: value.count().try_into()?,
|
||||||
@@ -370,14 +370,14 @@ impl<'a, W: 'a + Write + Seek, K: TiffKind> DirectoryEncoder<'a, W, K> {
|
|||||||
|
|
||||||
if bytes.len() > in_entry_bytes {
|
if bytes.len() > in_entry_bytes {
|
||||||
let offset = writer.offset();
|
let offset = writer.offset();
|
||||||
writer.write_bytes(&bytes)?;
|
writer.write_bytes(bytes)?;
|
||||||
|
|
||||||
let offset = K::convert_offset(offset)?;
|
let offset = K::convert_offset(offset)?;
|
||||||
offset_bytes[..offset.bytes()].copy_from_slice(&offset.data());
|
offset_bytes[..offset.bytes()].copy_from_slice(&offset.data());
|
||||||
} else {
|
} else {
|
||||||
// Note: we have indicated our native byte order in the header, hence this
|
// Note: we have indicated our native byte order in the header, hence this
|
||||||
// corresponds to our byte order no matter the value type.
|
// corresponds to our byte order no matter the value type.
|
||||||
offset_bytes[..bytes.len()].copy_from_slice(&bytes);
|
offset_bytes[..bytes.len()].copy_from_slice(bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Undoing some hidden type. Offset is either u32 or u64. Due to the trait API being public
|
// Undoing some hidden type. Offset is either u32 or u64. Due to the trait API being public
|
||||||
|
|||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
extern crate tiff;
|
extern crate tiff;
|
||||||
|
|
||||||
use tiff::decoder::{Decoder, DecodingResult};
|
use tiff::decoder::{Decoder, DecodingResult};
|
||||||
use tiff::encoder::{colortype, Compression, Predictor, TiffEncoder};
|
use tiff::encoder::{colortype, Predictor, TiffEncoder};
|
||||||
use tiff::ColorType;
|
use tiff::ColorType;
|
||||||
|
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
|
|||||||
Reference in new issue
Block a user