Skip to content

Commit ab6c6a3

Browse files
committed
fixed clippy
1 parent 1d0bcd7 commit ab6c6a3

File tree

2 files changed

+32
-24
lines changed

2 files changed

+32
-24
lines changed

src/ifd.rs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -934,18 +934,18 @@ async fn read_tag_value(
934934

935935
match tag_type {
936936
Type::BYTE | Type::UNDEFINED => {
937-
let mut v = Vec::new();
937+
let mut v = Vec::with_capacity(count as _);
938938
for _ in 0..count {
939939
v.push(Value::Byte(data.read_u8()?));
940940
}
941-
return Ok(Value::List(v));
941+
Ok(Value::List(v))
942942
}
943943
Type::SBYTE => {
944-
let mut v = Vec::new();
944+
let mut v = Vec::with_capacity(count as _);
945945
for _ in 0..count {
946946
v.push(Value::SignedByte(data.read_i8()?));
947947
}
948-
return Ok(Value::List(v));
948+
Ok(Value::List(v))
949949
}
950950
Type::ASCII => {
951951
let mut buf = vec![0; count as usize];
@@ -954,95 +954,95 @@ async fn read_tag_value(
954954
let v = std::str::from_utf8(&buf)
955955
.map_err(|err| AsyncTiffError::General(err.to_string()))?;
956956
let v = v.trim_matches(char::from(0));
957-
return Ok(Value::Ascii(v.into()));
957+
Ok(Value::Ascii(v.into()))
958958
} else {
959959
panic!("Invalid tag");
960960
// return Err(TiffError::FormatError(TiffFormatError::InvalidTag));
961961
}
962962
}
963963
Type::SHORT => {
964-
let mut v = Vec::new();
964+
let mut v = Vec::with_capacity(count as _);
965965
for _ in 0..count {
966966
v.push(Value::Short(data.read_u16()?));
967967
}
968-
return Ok(Value::List(v));
968+
Ok(Value::List(v))
969969
}
970970
Type::SSHORT => {
971-
let mut v = Vec::new();
971+
let mut v = Vec::with_capacity(count as _);
972972
for _ in 0..count {
973973
v.push(Value::Signed(i32::from(data.read_i16()?)));
974974
}
975-
return Ok(Value::List(v));
975+
Ok(Value::List(v))
976976
}
977977
Type::LONG => {
978-
let mut v = Vec::new();
978+
let mut v = Vec::with_capacity(count as _);
979979
for _ in 0..count {
980980
v.push(Value::Unsigned(data.read_u32()?));
981981
}
982-
return Ok(Value::List(v));
982+
Ok(Value::List(v))
983983
}
984984
Type::SLONG => {
985-
let mut v = Vec::new();
985+
let mut v = Vec::with_capacity(count as _);
986986
for _ in 0..count {
987987
v.push(Value::Signed(data.read_i32()?));
988988
}
989-
return Ok(Value::List(v));
989+
Ok(Value::List(v))
990990
}
991991
Type::FLOAT => {
992-
let mut v = Vec::new();
992+
let mut v = Vec::with_capacity(count as _);
993993
for _ in 0..count {
994994
v.push(Value::Float(data.read_f32()?));
995995
}
996-
return Ok(Value::List(v));
996+
Ok(Value::List(v))
997997
}
998998
Type::DOUBLE => {
999999
let mut v = Vec::with_capacity(count as _);
10001000
for _ in 0..count {
10011001
v.push(Value::Double(data.read_f64()?))
10021002
}
1003-
return Ok(Value::List(v));
1003+
Ok(Value::List(v))
10041004
}
10051005
Type::RATIONAL => {
10061006
let mut v = Vec::with_capacity(count as _);
10071007
for _ in 0..count {
10081008
v.push(Value::Rational(data.read_u32()?, data.read_u32()?))
10091009
}
1010-
return Ok(Value::List(v));
1010+
Ok(Value::List(v))
10111011
}
10121012
Type::SRATIONAL => {
10131013
let mut v = Vec::with_capacity(count as _);
10141014
for _ in 0..count {
10151015
v.push(Value::SRational(data.read_i32()?, data.read_i32()?))
10161016
}
1017-
return Ok(Value::List(v));
1017+
Ok(Value::List(v))
10181018
}
10191019
Type::LONG8 => {
10201020
let mut v = Vec::with_capacity(count as _);
10211021
for _ in 0..count {
10221022
v.push(Value::UnsignedBig(data.read_u64()?))
10231023
}
1024-
return Ok(Value::List(v));
1024+
Ok(Value::List(v))
10251025
}
10261026
Type::SLONG8 => {
10271027
let mut v = Vec::with_capacity(count as _);
10281028
for _ in 0..count {
10291029
v.push(Value::SignedBig(data.read_i64()?))
10301030
}
1031-
return Ok(Value::List(v));
1031+
Ok(Value::List(v))
10321032
}
10331033
Type::IFD => {
10341034
let mut v = Vec::with_capacity(count as _);
10351035
for _ in 0..count {
10361036
v.push(Value::Ifd(data.read_u32()?))
10371037
}
1038-
return Ok(Value::List(v));
1038+
Ok(Value::List(v))
10391039
}
10401040
Type::IFD8 => {
10411041
let mut v = Vec::with_capacity(count as _);
10421042
for _ in 0..count {
10431043
v.push(Value::IfdBig(data.read_u64()?))
10441044
}
1045-
return Ok(Value::List(v));
1045+
Ok(Value::List(v))
10461046
}
10471047
}
10481048
}

src/reader.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,31 +272,37 @@ impl AsyncCursor {
272272
}
273273

274274
/// Read a u8 from the cursor, advancing the internal state by 1 byte.
275+
#[allow(dead_code)]
275276
pub(crate) async fn read_u8(&mut self) -> AsyncTiffResult<u8> {
276277
self.read(1).await?.read_u8()
277278
}
278279

279280
/// Read a i8 from the cursor, advancing the internal state by 1 byte.
281+
#[allow(dead_code)]
280282
pub(crate) async fn read_i8(&mut self) -> AsyncTiffResult<i8> {
281283
self.read(1).await?.read_i8()
282284
}
283285

284286
/// Read a u16 from the cursor, advancing the internal state by 2 bytes.
287+
#[allow(dead_code)]
285288
pub(crate) async fn read_u16(&mut self) -> AsyncTiffResult<u16> {
286289
self.read(2).await?.read_u16()
287290
}
288291

289292
/// Read a i16 from the cursor, advancing the internal state by 2 bytes.
293+
#[allow(dead_code)]
290294
pub(crate) async fn read_i16(&mut self) -> AsyncTiffResult<i16> {
291295
self.read(2).await?.read_i16()
292296
}
293297

294298
/// Read a u32 from the cursor, advancing the internal state by 4 bytes.
299+
#[allow(dead_code)]
295300
pub(crate) async fn read_u32(&mut self) -> AsyncTiffResult<u32> {
296301
self.read(4).await?.read_u32()
297302
}
298303

299304
/// Read a i32 from the cursor, advancing the internal state by 4 bytes.
305+
#[allow(dead_code)]
300306
pub(crate) async fn read_i32(&mut self) -> AsyncTiffResult<i32> {
301307
self.read(4).await?.read_i32()
302308
}
@@ -307,24 +313,25 @@ impl AsyncCursor {
307313
}
308314

309315
/// Read a i64 from the cursor, advancing the internal state by 8 bytes.
316+
#[allow(dead_code)]
310317
pub(crate) async fn read_i64(&mut self) -> AsyncTiffResult<i64> {
311318
self.read(8).await?.read_i64()
312319
}
313320

321+
#[allow(dead_code)]
314322
pub(crate) async fn read_f32(&mut self) -> AsyncTiffResult<f32> {
315323
self.read(4).await?.read_f32()
316324
}
317325

326+
#[allow(dead_code)]
318327
pub(crate) async fn read_f64(&mut self) -> AsyncTiffResult<f64> {
319328
self.read(8).await?.read_f64()
320329
}
321330

322-
#[allow(dead_code)]
323331
pub(crate) fn reader(&self) -> &Arc<dyn AsyncFileReader> {
324332
&self.reader
325333
}
326334

327-
#[allow(dead_code)]
328335
pub(crate) fn endianness(&self) -> Endianness {
329336
self.endianness
330337
}
@@ -338,6 +345,7 @@ impl AsyncCursor {
338345
self.offset = offset;
339346
}
340347

348+
#[allow(dead_code)]
341349
pub(crate) fn position(&self) -> u64 {
342350
self.offset
343351
}

0 commit comments

Comments
 (0)