Skip to content

Commit

Permalink
Fix various unused warnings (#10)
Browse files Browse the repository at this point in the history
* Fix unused imports

* Fix unused_variable warnings

* Fix unused borrow that must be used warning

* Fix unreachable pattern warnings
  • Loading branch information
weiji14 authored May 10, 2024
1 parent ac83b4a commit 56f30de
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 14 deletions.
8 changes: 1 addition & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,13 @@ extern crate byteorder;
extern crate enum_primitive;
extern crate num;

use num::FromPrimitive;

use byteorder::{ReadBytesExt, WriteBytesExt, BigEndian, LittleEndian};
use std::io::{Read, Seek};
use std::collections::{HashMap, HashSet};
use std::io::Result;
use std::fmt;
use std::io::Result;

mod lowlevel;
mod reader;
pub mod tiff;

use tiff::*;
use reader::*;
pub use tiff::TIFF;

Expand Down
1 change: 0 additions & 1 deletion src/lowlevel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ pub fn tag_size(t: &TagType) -> u32 {
TagType::SignedRationalTag => 8,
TagType::FloatTag => 4,
TagType::DoubleTag => 8,
_ => 0,
}
}

Expand Down
11 changes: 5 additions & 6 deletions src/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ impl TIFFReader {
&TagType::FloatTag => TagValue::FloatValue(Endian::read_f32(&vec[..])),
&TagType::DoubleTag => TagValue::DoubleValue(Endian::read_f64(&vec[..])),
&TagType::UndefinedTag => TagValue::ByteValue(0),
_ => panic!("Tag not found!"),
}
}

Expand Down Expand Up @@ -270,14 +269,14 @@ impl TIFFReader {
// TODO The img Vec should optimally not be of usize, but of size "image_depth".
let mut img: Vec<Vec<Vec<usize>>> = Vec::with_capacity(image_length as usize);
for i in 0..image_length {
&img.push(Vec::with_capacity(image_width as usize));
for j in 0..image_width {
&img[i as usize].push(vec![0; 1]); // TODO To be changed to take into account SamplesPerPixel!
img.push(Vec::with_capacity(image_width as usize));
for _ in 0..image_width {
img[i as usize].push(vec![0; 1]); // TODO To be changed to take into account SamplesPerPixel!
}
}

// Read strip after strip, and copy it into the output Vec.
let rows_per_strip = match rows_per_strip.value[0] {
let _rows_per_strip = match rows_per_strip.value[0] {
TagValue::ShortValue(v) => v,
_ => 0 as u16,
};
Expand All @@ -301,7 +300,7 @@ impl TIFFReader {
let mut curr_z = 0;
for (offset, byte_count) in offsets.iter().zip(byte_counts.iter()) {
reader.seek(SeekFrom::Start(*offset as u64))?;
for i in 0..(*byte_count / image_depth as u32) {
for _ in 0..(*byte_count / image_depth as u32) {
let v = self.read_n(reader, image_depth as u64);
// println!("x {:?} len {:?}", curr_x, img.len());
// println!("y {:?} wid {:?}", curr_y, img[0].len());
Expand Down

0 comments on commit 56f30de

Please sign in to comment.