Skip to content

Commit dcad763

Browse files
Clippy
1 parent 9ee02d5 commit dcad763

4 files changed

Lines changed: 16 additions & 22 deletions

File tree

src/bin/lato_glyphs.rs

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,9 @@ use std::{
1717

1818
fn dom_new_canvas(i: usize, width: usize, height: usize) -> String {
1919
let mut out = String::new();
20-
out += &format!(
21-
"const newCanvas{} = document.createElement(\"canvas\");\n",
22-
i
23-
);
24-
out += &format!("newCanvas{}.width = {};\n", i, width);
25-
out += &format!("newCanvas{}.height = {};\n", i, height);
20+
out += &format!("const newCanvas{i} = document.createElement(\"canvas\");\n",);
21+
out += &format!("newCanvas{i}.width = {width};\n");
22+
out += &format!("newCanvas{i}.height = {height};\n");
2623

2724
out
2825
}
@@ -94,17 +91,14 @@ fn draw_glyph_to_canvas(glyph: &Glyph, key: usize) -> Result<String> {
9491
while i < points.len() - 2 {
9592
if i == 0 {
9693
let ((x, y), on_curve) = points[0];
97-
out += &format!("ctx{key}.moveTo({}, {});\n", x, y);
94+
out += &format!("ctx{key}.moveTo({x}, {y});\n");
9895
assert!(on_curve, "First point should always be on curve.");
9996
}
10097

10198
let (mid_x, mid_y) = points[i + 1].0;
10299
let (next_x, next_y) = points[i + 2].0;
103100

104-
out += &format!(
105-
"ctx{key}.quadraticCurveTo({}, {}, {}, {});\n",
106-
mid_x, mid_y, next_x, next_y,
107-
);
101+
out += &format!("ctx{key}.quadraticCurveTo({mid_x}, {mid_y}, {next_x}, {next_y});\n",);
108102

109103
i += 2;
110104
}
@@ -162,9 +156,9 @@ fn main() -> Result<()> {
162156
}
163157

164158
render_js_code += &dom_new_canvas(i, glyph.description.width(), glyph.description.height());
165-
render_js_code += &format!("const ctx{} = newCanvas{}.getContext(\"2d\");\n", i, i);
159+
render_js_code += &format!("const ctx{i} = newCanvas{i}.getContext(\"2d\");\n");
166160
render_js_code += &draw_glyph_to_canvas(glyph, i)?;
167-
render_js_code += &format!("contentDiv.appendChild(newCanvas{});\n\n", i);
161+
render_js_code += &format!("contentDiv.appendChild(newCanvas{i});\n\n");
168162
}
169163

170164
let dir_path = Path::new("glyph_playground");

src/bin/test_suite.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ impl fmt::Display for TestStatus<'_> {
5252
TestStatus::Passed => write!(f, "Passed"),
5353
TestStatus::Incorrect => write!(f, "Incorrect"),
5454
TestStatus::Unsupported => write!(f, "Unsupported"),
55-
TestStatus::Panic(msg) => write!(f, "Panic: {:?}", msg),
56-
TestStatus::Error(error) => write!(f, "Error: {:?}", error),
55+
TestStatus::Panic(msg) => write!(f, "Panic: {msg:?}"),
56+
TestStatus::Error(error) => write!(f, "Error: {error:?}"),
5757
}
5858
}
5959
}

src/png/chunk.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,12 @@ impl PngChunk for IHDRChunk<'_> {
7272
}
7373
}
7474

75-
#[derive(Debug)]
76-
pub struct PLTEChunk; // todo!, how does the palette chunk serialize?
75+
// #[derive(Debug)]
76+
// pub struct PLTEChunk; // todo!, how does the palette chunk serialize?
7777

78-
impl PngChunk for PLTEChunk {
79-
const NAME: [u8; 4] = *b"PLTE";
80-
}
78+
// impl PngChunk for PLTEChunk {
79+
// const NAME: [u8; 4] = *b"PLTE";
80+
// }
8181

8282
#[derive(Debug)]
8383
pub struct IDATChunk<'a> {

src/png/decoder.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ impl<'a> PngDecoder<'a> {
136136
expected_crc == compute_crc(chunk_type, chunk_data)
137137
}
138138

139-
fn parse_chunks(&mut self) -> Result<Vec<Chunk>> {
139+
fn parse_chunks(&mut self) -> Result<Vec<Chunk<'_>>> {
140140
let mut chunks = Vec::new();
141141

142142
let mut text_map = BTreeMap::new();
@@ -176,7 +176,7 @@ impl<'a> PngDecoder<'a> {
176176
})
177177
}
178178
b"PLTE" => {
179-
ensure!(length % 3 == 0, "Chunk length not divisible by 3.");
179+
ensure!(length.is_multiple_of(3), "Chunk length not divisible by 3.");
180180
ensure!(
181181
!chunks.is_empty(),
182182
"Empty chunks. Expected ImageHeader chunk."

0 commit comments

Comments
 (0)