Skip to content

Commit 8476c8a

Browse files
authored
fix(ci): use variables directly in formatting for clippy (#103)
1 parent 5051854 commit 8476c8a

File tree

3 files changed

+7
-11
lines changed

3 files changed

+7
-11
lines changed

src/display.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -298,8 +298,8 @@ mod tests {
298298
#[test]
299299
fn precision() {
300300
let size = ByteSize::mib(1908);
301-
assert_eq!("1.9 GiB".to_string(), format!("{}", size));
302-
assert_eq!("2 GiB".to_string(), format!("{:.0}", size));
303-
assert_eq!("1.86328 GiB".to_string(), format!("{:.5}", size));
301+
assert_eq!("1.9 GiB".to_string(), format!("{size}"));
302+
assert_eq!("2 GiB".to_string(), format!("{size:.0}"));
303+
assert_eq!("1.86328 GiB".to_string(), format!("{size:.5}"));
304304
}
305305
}

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ mod tests {
463463

464464
#[track_caller]
465465
fn assert_display(expected: &str, b: ByteSize) {
466-
assert_eq!(expected, format!("{}", b));
466+
assert_eq!(expected, format!("{b}"));
467467
}
468468

469469
#[test]

src/parse.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,11 @@ impl str::FromStr for ByteSize {
1717
match suffix.parse::<Unit>() {
1818
Ok(u) => Ok(Self((v * u) as u64)),
1919
Err(error) => Err(format!(
20-
"couldn't parse {:?} into a known SI unit, {}",
21-
suffix, error
20+
"couldn't parse {suffix:?} into a known SI unit, {error}"
2221
)),
2322
}
2423
}
25-
Err(error) => Err(format!(
26-
"couldn't parse {:?} into a ByteSize, {}",
27-
value, error
28-
)),
24+
Err(error) => Err(format!("couldn't parse {value:?} into a ByteSize, {error}")),
2925
}
3026
}
3127
}
@@ -177,7 +173,7 @@ impl str::FromStr for Unit {
177173
"gi" | "gib" => Ok(Self::GibiByte),
178174
"ti" | "tib" => Ok(Self::TebiByte),
179175
"pi" | "pib" => Ok(Self::PebiByte),
180-
_ => Err(format!("couldn't parse unit of {:?}", unit)),
176+
_ => Err(format!("couldn't parse unit of {unit:?}")),
181177
}
182178
}
183179
}

0 commit comments

Comments
 (0)