From 1834827aa6e8cb81ab1d7f9904b095c842c99a3c Mon Sep 17 00:00:00 2001 From: Christoph Herzog Date: Thu, 26 Sep 2024 09:29:42 +0200 Subject: [PATCH] chore: Formatting/linting fixes --- lib/wasix/src/runners/wasi.rs | 6 +++--- lib/wasix/src/runtime/package_loader/builtin_loader.rs | 2 +- lib/wasix/src/runtime/resolver/in_memory_source.rs | 6 +++--- lib/wasix/src/runtime/resolver/multi_source.rs | 6 ++++++ lib/wasix/tests/runners.rs | 3 +-- 5 files changed, 14 insertions(+), 9 deletions(-) diff --git a/lib/wasix/src/runners/wasi.rs b/lib/wasix/src/runners/wasi.rs index f69f7e9ae1d..f775ef87e79 100644 --- a/lib/wasix/src/runners/wasi.rs +++ b/lib/wasix/src/runners/wasi.rs @@ -482,7 +482,7 @@ mod tests { let fs = &init.state.fs.root_fs; - fs.read_dir(&std::path::Path::new("/host")).unwrap(); + fs.read_dir(std::path::Path::new("/host")).unwrap(); } #[cfg(all(feature = "host-fs", feature = "sys"))] @@ -535,7 +535,7 @@ mod tests { let fs = &init.state.fs.root_fs; - fs.read_dir(&std::path::Path::new("/host")).unwrap(); - fs.read_dir(&std::path::Path::new("/settings")).unwrap(); + fs.read_dir(std::path::Path::new("/host")).unwrap(); + fs.read_dir(std::path::Path::new("/settings")).unwrap(); } } diff --git a/lib/wasix/src/runtime/package_loader/builtin_loader.rs b/lib/wasix/src/runtime/package_loader/builtin_loader.rs index be4ed7de8e5..5c7e7125910 100644 --- a/lib/wasix/src/runtime/package_loader/builtin_loader.rs +++ b/lib/wasix/src/runtime/package_loader/builtin_loader.rs @@ -704,7 +704,7 @@ mod test { let path = dir.path(); let contents = "fail"; - let correct_hash = WebcHash::sha256(&contents); + let correct_hash = WebcHash::sha256(contents); let used_hash = WebcHash::parse_hex("0000a28ea38a000f3a3328cb7fabe330638d3258affe1a869e3f92986222d997") .unwrap(); diff --git a/lib/wasix/src/runtime/resolver/in_memory_source.rs b/lib/wasix/src/runtime/resolver/in_memory_source.rs index dbe3ef78b7d..1505cf12099 100644 --- a/lib/wasix/src/runtime/resolver/in_memory_source.rs +++ b/lib/wasix/src/runtime/resolver/in_memory_source.rs @@ -77,9 +77,9 @@ impl InMemorySource { let pkg_hash = PackageHash::Sha256(wasmer_config::hash::Sha256Hash( summary.dist.webc_sha256.as_bytes(), )); - if !self.hash_packages.contains_key(&pkg_hash) { - self.hash_packages.insert(pkg_hash, summary.clone()); - } + self.hash_packages + .entry(pkg_hash) + .or_insert_with(|| summary.clone()); // Add the named package. let summaries = self diff --git a/lib/wasix/src/runtime/resolver/multi_source.rs b/lib/wasix/src/runtime/resolver/multi_source.rs index 7178a8d25dc..e876b8225bf 100644 --- a/lib/wasix/src/runtime/resolver/multi_source.rs +++ b/lib/wasix/src/runtime/resolver/multi_source.rs @@ -24,6 +24,12 @@ pub struct MultiSource { strategy: MultiSourceStrategy, } +impl Default for MultiSource { + fn default() -> Self { + Self::new() + } +} + impl MultiSource { pub fn new() -> Self { MultiSource { diff --git a/lib/wasix/tests/runners.rs b/lib/wasix/tests/runners.rs index b58c41e5998..cd77428bdd0 100644 --- a/lib/wasix/tests/runners.rs +++ b/lib/wasix/tests/runners.rs @@ -236,9 +236,8 @@ fn client() -> Client { } builder }; - let client = builder.build().unwrap(); - client + builder.build().unwrap() } #[cfg(not(target_os = "windows"))]