Skip to content

Commit a50ea8e

Browse files
src: use "impl trait" syntax for args where possible
This syntax is a bit less verbose than the fully-spelled-out generic form. I'm surprised by how few sites this was possible for... Signed-off-by: Allison Karlitskaya <[email protected]>
1 parent d3f5e8b commit a50ea8e

File tree

6 files changed

+14
-17
lines changed

6 files changed

+14
-17
lines changed

src/dumpfile.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,11 @@ pub fn write_directory(
101101
)
102102
}
103103

104-
pub fn write_leaf<ObjectID: FsVerityHashValue>(
104+
pub fn write_leaf(
105105
writer: &mut impl fmt::Write,
106106
path: &Path,
107107
stat: &Stat,
108-
content: &LeafContent<ObjectID>,
108+
content: &LeafContent<impl FsVerityHashValue>,
109109
nlink: usize,
110110
) -> fmt::Result {
111111
match content {

src/erofs/writer.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ impl<'a, ObjectID: FsVerityHashValue> InodeCollector<'a, ObjectID> {
525525

526526
/// Takes a list of inodes where each inode contains only local xattr values, determines which
527527
/// xattrs (key, value) pairs appear more than once, and shares them.
528-
fn share_xattrs<ObjectID: FsVerityHashValue>(inodes: &mut [Inode<ObjectID>]) -> Vec<XAttr> {
528+
fn share_xattrs(inodes: &mut [Inode<impl FsVerityHashValue>]) -> Vec<XAttr> {
529529
let mut xattrs: BTreeMap<XAttr, usize> = BTreeMap::new();
530530

531531
// Collect all xattrs from the inodes
@@ -563,9 +563,9 @@ fn share_xattrs<ObjectID: FsVerityHashValue>(inodes: &mut [Inode<ObjectID>]) ->
563563
xattrs.into_keys().collect()
564564
}
565565

566-
fn write_erofs<ObjectID: FsVerityHashValue>(
566+
fn write_erofs(
567567
output: &mut impl Output,
568-
inodes: &[Inode<ObjectID>],
568+
inodes: &[Inode<impl FsVerityHashValue>],
569569
xattrs: &[XAttr],
570570
) {
571571
// Write composefs header

src/oci/image.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,7 @@ pub fn compose_filesystem<ObjectID: FsVerityHashValue>(
6868
Ok(filesystem)
6969
}
7070

71-
pub fn create_dumpfile<ObjectID: FsVerityHashValue>(
72-
repo: &Repository<ObjectID>,
73-
layers: &[String],
74-
) -> Result<()> {
71+
pub fn create_dumpfile(repo: &Repository<impl FsVerityHashValue>, layers: &[String]) -> Result<()> {
7572
let filesystem = compose_filesystem(repo, layers)?;
7673
let mut stdout = std::io::stdout();
7774
write_dumpfile(&mut stdout, &filesystem)?;

src/oci/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,8 @@ impl<'repo, ObjectID: FsVerityHashValue> ImageOp<'repo, ObjectID> {
212212

213213
/// Pull the target image, and add the provided tag. If this is a mountable
214214
/// image (i.e. not an artifact), it is *not* unpacked by default.
215-
pub async fn pull<ObjectID: FsVerityHashValue>(
216-
repo: &Repository<ObjectID>,
215+
pub async fn pull(
216+
repo: &Repository<impl FsVerityHashValue>,
217217
imgref: &str,
218218
reference: Option<&str>,
219219
) -> Result<()> {

src/oci/tar.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ async fn read_header_async(reader: &mut (impl AsyncRead + Unpin)) -> Result<Opti
4343
/// Splits the tar file from tar_stream into a Split Stream. The store_data function is
4444
/// responsible for ensuring that "external data" is in the composefs repository and returns the
4545
/// fsverity hash value of that data.
46-
pub fn split<ObjectID: FsVerityHashValue>(
46+
pub fn split(
4747
tar_stream: &mut impl Read,
48-
writer: &mut SplitStreamWriter<ObjectID>,
48+
writer: &mut SplitStreamWriter<impl FsVerityHashValue>,
4949
) -> Result<()> {
5050
while let Some(header) = read_header(tar_stream)? {
5151
// the header always gets stored as inline data
@@ -73,9 +73,9 @@ pub fn split<ObjectID: FsVerityHashValue>(
7373
Ok(())
7474
}
7575

76-
pub async fn split_async<ObjectID: FsVerityHashValue>(
76+
pub async fn split_async(
7777
mut tar_stream: impl AsyncRead + Unpin,
78-
writer: &mut SplitStreamWriter<'_, ObjectID>,
78+
writer: &mut SplitStreamWriter<'_, impl FsVerityHashValue>,
7979
) -> Result<()> {
8080
while let Some(header) = read_header_async(&mut tar_stream).await? {
8181
// the header always gets stored as inline data

tests/mkfs.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ use composefs::{
1717
image::{Directory, FileSystem, Inode, Leaf, LeafContent, RegularFile, Stat},
1818
};
1919

20-
fn debug_fs<ObjectID: FsVerityHashValue>(mut fs: FileSystem<ObjectID>) -> String {
20+
fn debug_fs(mut fs: FileSystem<impl FsVerityHashValue>) -> String {
2121
fs.done();
2222
let image = mkfs_erofs(&fs);
2323
let mut output = vec![];
2424
debug_img(&mut output, &image).unwrap();
2525
String::from_utf8(output).unwrap()
2626
}
2727

28-
fn empty<ObjectID: FsVerityHashValue>(_fs: &mut FileSystem<ObjectID>) {}
28+
fn empty(_fs: &mut FileSystem<impl FsVerityHashValue>) {}
2929

3030
#[test]
3131
fn test_empty() {

0 commit comments

Comments
 (0)