Skip to content

Commit f925f5d

Browse files
src: clippy fixes
Signed-off-by: Allison Karlitskaya <[email protected]>
1 parent e332b2c commit f925f5d

File tree

7 files changed

+15
-16
lines changed

7 files changed

+15
-16
lines changed

src/dumpfile.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ fn write_escaped(writer: &mut impl fmt::Write, bytes: &[u8]) -> fmt::Result {
2929
let c = *c;
3030

3131
if c < b'!' || c == b'=' || c == b'\\' || c > b'~' {
32-
write!(writer, "\\x{:02x}", c)?;
32+
write!(writer, "\\x{c:02x}")?;
3333
} else {
3434
writer.write_char(c as char)?;
3535
}
@@ -66,7 +66,7 @@ fn write_entry(
6666
write_escaped(writer, content)?;
6767
write!(writer, " ")?;
6868
if let Some(id) = digest {
69-
write!(writer, "{}", id)?;
69+
write!(writer, "{id}")?;
7070
} else {
7171
write_empty(writer)?;
7272
}
@@ -212,7 +212,7 @@ struct DumpfileWriter<'a, W: Write, ObjectID: FsVerityHashValue> {
212212
fn writeln_fmt(writer: &mut impl Write, f: impl Fn(&mut String) -> fmt::Result) -> Result<()> {
213213
let mut tmp = String::with_capacity(256);
214214
f(&mut tmp)?;
215-
Ok(writeln!(writer, "{}", tmp)?)
215+
Ok(writeln!(writer, "{tmp}")?)
216216
}
217217

218218
impl<'a, W: Write, ObjectID: FsVerityHashValue> DumpfileWriter<'a, W, ObjectID> {

src/dumpfile_parse.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ fn escape<W: std::fmt::Write>(out: &mut W, s: &[u8], mode: EscapeMode) -> std::f
291291
b'\n' => out.write_str(r"\n")?,
292292
b'\t' => out.write_str(r"\t")?,
293293
b'\r' => out.write_str(r"\r")?,
294-
o => write!(out, "\\x{:02x}", o)?,
294+
o => write!(out, "\\x{o:02x}")?,
295295
}
296296
}
297297
}

src/erofs/debug.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ macro_rules! write_fields {
4747

4848
fn utf8_or_hex(data: &[u8]) -> String {
4949
if let Ok(string) = std::str::from_utf8(data) {
50-
format!("{:?}", string)
50+
format!("{string:?}")
5151
} else {
5252
hex::encode(data)
5353
}
@@ -322,8 +322,7 @@ impl<T: fmt::Debug + InodeHeader> fmt::Debug for Inode<T> {
322322
let offset = addr!(dir) - addr!(self);
323323
return write!(
324324
f,
325-
" +{offset:02x} --- inline directory entries ---{:#?}",
326-
dir
325+
" +{offset:02x} --- inline directory entries ---{dir:#?}"
327326
);
328327
}
329328

src/oci/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ pub fn ls_layer<ObjectID: FsVerityHashValue>(
3737
let mut split_stream = repo.open_stream(name, None)?;
3838

3939
while let Some(entry) = get_entry(&mut split_stream)? {
40-
println!("{}", entry);
40+
println!("{entry}");
4141
}
4242

4343
Ok(())
@@ -387,7 +387,7 @@ mod test {
387387
let mut dump = String::new();
388388
let mut split_stream = repo.open_stream("refs/name", Some(&id)).unwrap();
389389
while let Some(entry) = tar::get_entry(&mut split_stream).unwrap() {
390-
writeln!(dump, "{}", entry).unwrap();
390+
writeln!(dump, "{entry}").unwrap();
391391
}
392392
similar_asserts::assert_eq!(dump, "\
393393
/file0 0 100700 1 0 0 0 0.0 - - -

src/repository.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ impl<ObjectID: FsVerityHashValue> Repository<ObjectID> {
324324
name: &str,
325325
verity: Option<&ObjectID>,
326326
) -> Result<SplitStreamReader<File, ObjectID>> {
327-
let filename = format!("streams/{}", name);
327+
let filename = format!("streams/{name}");
328328

329329
let file = File::from(if let Some(verity_hash) = verity {
330330
self.open_with_verity(&filename, verity_hash)?
@@ -365,7 +365,7 @@ impl<ObjectID: FsVerityHashValue> Repository<ObjectID> {
365365
self.ensure_symlink(&image_path, &object_path)?;
366366

367367
if let Some(reference) = name {
368-
let ref_path = format!("images/refs/{}", reference);
368+
let ref_path = format!("images/refs/{reference}");
369369
self.symlink(&ref_path, &image_path)?;
370370
}
371371

@@ -380,7 +380,7 @@ impl<ObjectID: FsVerityHashValue> Repository<ObjectID> {
380380
}
381381

382382
pub fn open_image(&self, name: &str) -> Result<OwnedFd> {
383-
let image = self.openat(&format!("images/{}", name), OFlags::RDONLY)?;
383+
let image = self.openat(&format!("images/{name}"), OFlags::RDONLY)?;
384384

385385
if !name.contains("/") {
386386
// A name with no slashes in it is taken to be a sha256 fs-verity digest

src/splitstream.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ impl<F: Read, ObjectID: FsVerityHashValue> Read for SplitStreamReader<F, ObjectI
392392
Ok(n_bytes)
393393
}
394394
Ok(ChunkType::External(..)) => unreachable!(),
395-
Err(e) => Err(std::io::Error::new(std::io::ErrorKind::Other, e)),
395+
Err(e) => Err(std::io::Error::other(e)),
396396
}
397397
}
398398
}

src/tree.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ mod tests {
587587
}
588588
match dir.get_file(OsStr::new("link.txt")) {
589589
Err(ImageError::IsNotRegular(name)) => assert_eq!(name.to_str().unwrap(), "link.txt"),
590-
res => panic!("Expected IsNotRegular, got {:?}", res),
590+
res => panic!("Expected IsNotRegular, got {res:?}"),
591591
}
592592
}
593593

@@ -600,7 +600,7 @@ mod tests {
600600

601601
dir.remove(OsStr::new("file1.txt"));
602602
assert_eq!(dir.entries.len(), 1);
603-
assert!(dir.entries.get(OsStr::new("file1.txt")).is_none());
603+
assert!(!dir.entries.contains_key(OsStr::new("file1.txt")));
604604

605605
dir.remove(OsStr::new("nonexistent")); // Should be no-op
606606
assert_eq!(dir.entries.len(), 1);
@@ -635,7 +635,7 @@ mod tests {
635635
Some(Inode::Directory(d)) => {
636636
assert_eq!(d.stat.st_mtim_sec, 90); // Stat updated
637637
assert_eq!(d.entries.len(), 1); // Inner file preserved
638-
assert!(d.entries.get(OsStr::new("inner_file")).is_some());
638+
assert!(d.entries.contains_key(OsStr::new("inner_file")));
639639
}
640640
_ => panic!("Expected directory after merge"),
641641
}

0 commit comments

Comments
 (0)