Skip to content

Commit f45a7d9

Browse files
committed
og_image: Fix clippy warnings
1 parent 814170a commit f45a7d9

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

crates/crates_io_og_image/examples/test_generator.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
2929
Ok(temp_file) => {
3030
let output_path = "test_og_image.png";
3131
std::fs::copy(temp_file.path(), output_path)?;
32-
println!("Successfully generated image at: {}", output_path);
32+
println!("Successfully generated image at: {output_path}");
3333
println!(
3434
"Image file size: {} bytes",
3535
std::fs::metadata(output_path)?.len()
3636
);
3737
}
3838
Err(e) => {
39-
println!("Failed to generate image: {}", e);
39+
println!("Failed to generate image: {e}");
4040
println!("Make sure typst is installed and available in PATH");
4141
}
4242
}

crates/crates_io_og_image/src/formatting.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,18 @@ pub fn format_bytes(bytes: u32) -> String {
3737

3838
// Special case for bytes - no decimal places
3939
if unit_index == 0 {
40-
return format!("{} {}", bytes, unit);
40+
return format!("{bytes} {unit}");
4141
}
4242

4343
// For kB and MB, format with appropriate decimal places
4444

4545
// Determine number of decimal places to keep number under 4 chars
4646
if value < 10.0 {
47-
format!("{:.2} {}", value, unit) // e.g., 1.50 kB, 9.99 MB
47+
format!("{value:.2} {unit}") // e.g., 1.50 kB, 9.99 MB
4848
} else if value < 100.0 {
49-
format!("{:.1} {}", value, unit) // e.g., 10.5 kB, 99.9 MB
49+
format!("{value:.1} {unit}") // e.g., 10.5 kB, 99.9 MB
5050
} else {
51-
format!("{:.0} {}", value, unit) // e.g., 100 kB, 999 MB
51+
format!("{value:.0} {unit}") // e.g., 100 kB, 999 MB
5252
}
5353
}
5454

@@ -88,16 +88,16 @@ pub fn format_number(number: u32) -> String {
8888

8989
// Special case for numbers without suffix - no decimal places
9090
if unit_index == 0 {
91-
return format!("{}", number);
91+
return format!("{number}");
9292
}
9393

9494
// For k and M, format with appropriate decimal places
9595

9696
// Determine number of decimal places to keep number under 4 chars
9797
if value < 10.0 {
98-
format!("{:.1}{}", value, unit)
98+
format!("{value:.1}{unit}")
9999
} else {
100-
format!("{:.0}{}", value, unit)
100+
format!("{value:.0}{unit}")
101101
}
102102
}
103103

crates/crates_io_og_image/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ impl OgImageGenerator {
127127
let client = reqwest::Client::new();
128128
for (index, author) in data.authors.iter().enumerate() {
129129
if let Some(avatar) = &author.avatar {
130-
let filename = format!("avatar_{}.png", index);
130+
let filename = format!("avatar_{index}.png");
131131
let avatar_path = assets_dir.join(&filename);
132132

133133
// Get the bytes either from the included asset or download from URL
@@ -244,9 +244,9 @@ impl OgImageGenerator {
244244
.arg("--format")
245245
.arg("png")
246246
.arg("--input")
247-
.arg(format!("data={}", json_data))
247+
.arg(format!("data={json_data}"))
248248
.arg("--input")
249-
.arg(format!("avatar_map={}", json_avatar_map))
249+
.arg(format!("avatar_map={json_avatar_map}"))
250250
.arg(&typ_file_path)
251251
.arg(output_file.path())
252252
.output()

0 commit comments

Comments
 (0)