Skip to content

Commit 51028b8

Browse files
committed
Last of clippy warnings
1 parent 043f57f commit 51028b8

File tree

4 files changed

+54
-43
lines changed

4 files changed

+54
-43
lines changed

.github/workflows/ci.yml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,18 @@ jobs:
3333
command: fmt
3434
args: --all -- --check
3535

36-
# clippy:
37-
# name: Clippy
38-
# runs-on: ubuntu-latest
39-
# steps:
40-
# - uses: actions/checkout@v2
41-
# - uses: actions-rs/toolchain@v1
42-
# with:
43-
# profile: minimal
44-
# toolchain: stable
45-
# override: true
46-
# - run: rustup component add clippy
47-
# - uses: actions-rs/cargo@v1
48-
# with:
49-
# command: clippy
50-
# args: -- -D warnings
36+
clippy:
37+
name: Clippy
38+
runs-on: ubuntu-latest
39+
steps:
40+
- uses: actions/checkout@v2
41+
- uses: actions-rs/toolchain@v1
42+
with:
43+
profile: minimal
44+
toolchain: stable
45+
override: true
46+
- run: rustup component add clippy
47+
- uses: actions-rs/cargo@v1
48+
with:
49+
command: clippy
50+
args: -- -D warnings

src/dmi.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,14 @@ impl RawDmi {
9494
}
9595
}
9696
if chunk_ihdr == None {
97-
return Err(error::DmiError::Generic("Failed to load DMI. Buffer end reached without finding an IHDR chunk.".to_string()));
97+
return Err(error::DmiError::Generic(
98+
"Failed to load DMI. Buffer end reached without finding an IHDR chunk.".to_string(),
99+
));
98100
};
99101
if chunks_idat.is_empty() {
100-
return Err(error::DmiError::Generic("Failed to load DMI. Buffer end reached without finding an IDAT chunk.".to_string()));
102+
return Err(error::DmiError::Generic(
103+
"Failed to load DMI. Buffer end reached without finding an IDAT chunk.".to_string(),
104+
));
101105
}
102106
let other_chunks = match other_chunks.len() {
103107
0 => None,

src/dmi/icon.rs

Lines changed: 33 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ impl Icon {
2121
let chunk_ztxt = match &raw_dmi.chunk_ztxt {
2222
Some(chunk) => chunk.clone(),
2323
None => {
24-
return Err(error::DmiError::Generic("Error loading icon: no zTXt chunk found.".to_string()))
24+
return Err(error::DmiError::Generic(
25+
"Error loading icon: no zTXt chunk found.".to_string(),
26+
))
2527
}
2628
};
2729
let decompressed_text = chunk_ztxt.data.decode()?;
@@ -39,7 +41,9 @@ impl Icon {
3941
let current_line = match decompressed_text.next() {
4042
Some(thing) => thing,
4143
None => {
42-
return Err(error::DmiError::Generic("Error loading icon: no version header found.".to_string()))
44+
return Err(error::DmiError::Generic(
45+
"Error loading icon: no version header found.".to_string(),
46+
))
4347
}
4448
};
4549
let split_version: Vec<&str> = current_line.split_terminator(" = ").collect();
@@ -54,7 +58,9 @@ impl Icon {
5458
let current_line = match decompressed_text.next() {
5559
Some(thing) => thing,
5660
None => {
57-
return Err(error::DmiError::Generic("Error loading icon: no width found.".to_string()))
61+
return Err(error::DmiError::Generic(
62+
"Error loading icon: no width found.".to_string(),
63+
))
5864
}
5965
};
6066
let split_version: Vec<&str> = current_line.split_terminator(" = ").collect();
@@ -69,7 +75,9 @@ impl Icon {
6975
let current_line = match decompressed_text.next() {
7076
Some(thing) => thing,
7177
None => {
72-
return Err(error::DmiError::Generic("Error loading icon: no height found.".to_string()))
78+
return Err(error::DmiError::Generic(
79+
"Error loading icon: no height found.".to_string(),
80+
))
7381
}
7482
};
7583
let split_version: Vec<&str> = current_line.split_terminator(" = ").collect();
@@ -110,7 +118,9 @@ impl Icon {
110118
let mut current_line = match decompressed_text.next() {
111119
Some(thing) => thing,
112120
None => {
113-
return Err(error::DmiError::Generic("Error loading icon: no DMI trailer nor states found.".to_string()))
121+
return Err(error::DmiError::Generic(
122+
"Error loading icon: no DMI trailer nor states found.".to_string(),
123+
))
114124
}
115125
};
116126

@@ -157,7 +167,9 @@ impl Icon {
157167
current_line = match decompressed_text.next() {
158168
Some(thing) => thing,
159169
None => {
160-
return Err(error::DmiError::Generic("Error loading icon: no DMI trailer found.".to_string()))
170+
return Err(error::DmiError::Generic(
171+
"Error loading icon: no DMI trailer found.".to_string(),
172+
))
161173
}
162174
};
163175

@@ -291,26 +303,22 @@ impl Icon {
291303
},
292304
None => return Err(error::DmiError::Generic(format!("Error saving Icon: number of frames ({}) larger than one without a delay entry in icon state of name \"{}\".", icon_state.frames, icon_state.name)))
293305
};
294-
match icon_state.loop_flag {
295-
Some(flag) => signature.push_str(&format!("\tloop = {}\n", flag)),
296-
None => (),
297-
};
298-
match icon_state.rewind {
299-
Some(flag) => signature.push_str(&format!("\trewind = {}\n", flag)),
300-
None => (),
301-
};
302-
match icon_state.movement {
303-
Some(flag) => signature.push_str(&format!("\trewind = {}\n", flag)),
304-
None => (),
305-
};
306+
if let Some(flag) = icon_state.loop_flag {
307+
signature.push_str(&format!("\tloop = {}\n", flag))
308+
}
309+
if let Some(flag) = icon_state.rewind {
310+
signature.push_str(&format!("\trewind = {}\n", flag))
311+
}
312+
if let Some(flag) = icon_state.movement {
313+
signature.push_str(&format!("\trewind = {}\n", flag))
314+
}
306315
};
307316

308-
match icon_state.hotspot {
309-
Some(array) => signature.push_str(&format!(
317+
if let Some(array) = icon_state.hotspot {
318+
signature.push_str(&format!(
310319
"\tarray = {},{},{}\n",
311320
array[0], array[1], array[2]
312-
)),
313-
None => (),
321+
))
314322
};
315323

316324
match &icon_state.unknown_settings {
@@ -331,15 +339,15 @@ impl Icon {
331339
let mut new_png =
332340
image::DynamicImage::new_rgba8(max_index * self.width, max_index * self.height);
333341

334-
let mut index = 0;
335-
for image in sprites.iter() {
342+
for image in sprites.iter().enumerate() {
343+
let index = image.0 as u32;
344+
let image = image.1;
336345
imageops::replace(
337346
&mut new_png,
338347
*image,
339348
self.width * (index % max_index),
340349
self.height * (index / max_index),
341350
);
342-
index += 1;
343351
}
344352

345353
let mut new_dmi = vec![];

src/dmi/ztxt.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use super::chunk;
22
use super::crc;
33
use super::error;
44

5-
65
use std::convert::TryFrom;
76
use std::fmt;
87
use std::io::prelude::*;

0 commit comments

Comments
 (0)