From b768a28ec4ac7140c15a8d858080ac9cb889fc36 Mon Sep 17 00:00:00 2001 From: Xuanwo Date: Sat, 7 Oct 2023 11:07:02 +0800 Subject: [PATCH] chore: Make clippy happy (#3229) Signed-off-by: Xuanwo --- bin/oli/src/config/mod.rs | 15 ++++++++------- bin/oli/tests/cat.rs | 4 +--- bin/oli/tests/cp.rs | 2 +- bin/oli/tests/rm.rs | 2 +- bin/oli/tests/stat.rs | 4 +--- core/src/layers/retry.rs | 2 +- .../raw/oio/read/into_seekable_read_by_range.rs | 4 ++-- core/src/types/list.rs | 1 - 8 files changed, 15 insertions(+), 19 deletions(-) diff --git a/bin/oli/src/config/mod.rs b/bin/oli/src/config/mod.rs index 08d2cfb6bf88..de074c41fa9e 100644 --- a/bin/oli/src/config/mod.rs +++ b/bin/oli/src/config/mod.rs @@ -79,7 +79,7 @@ impl Config { let profiles = Config::load_from_env().profiles.into_iter().fold( cfg.profiles, |mut acc, (name, opts)| { - acc.entry(name).or_insert_with(HashMap::new).extend(opts); + acc.entry(name).or_default().extend(opts); acc }, ); @@ -115,12 +115,13 @@ impl Config { }, ) }) - .fold(HashMap::new(), |mut acc, (profile_name, key, val)| { - acc.entry(profile_name) - .or_insert_with(HashMap::new) - .insert(key, val); - acc - }); + .fold( + HashMap::new(), + |mut acc: HashMap>, (profile_name, key, val)| { + acc.entry(profile_name).or_default().insert(key, val); + acc + }, + ); Config { profiles } } diff --git a/bin/oli/tests/cat.rs b/bin/oli/tests/cat.rs index 7ab9eea75116..86ee7c97e28b 100644 --- a/bin/oli/tests/cat.rs +++ b/bin/oli/tests/cat.rs @@ -50,9 +50,7 @@ async fn test_cat_for_path_in_current_dir() -> Result<()> { let mut cmd = Command::cargo_bin("oli")?; - cmd.arg("cat") - .arg("dst.txt") - .current_dir(dir.path().clone()); + cmd.arg("cat").arg("dst.txt").current_dir(dir.path()); let actual = fs::read_to_string(&dst_path)?; let res = cmd.assert().success(); let output = res.get_output().stdout.clone(); diff --git a/bin/oli/tests/cp.rs b/bin/oli/tests/cp.rs index d9ef28efa69d..e9be04f188e6 100644 --- a/bin/oli/tests/cp.rs +++ b/bin/oli/tests/cp.rs @@ -54,7 +54,7 @@ async fn test_cp_for_path_in_current_dir() -> Result<()> { cmd.arg("cp") .arg("src.txt") .arg("dst.txt") - .current_dir(dir.path().clone()); + .current_dir(dir.path()); cmd.assert().success(); let actual = fs::read_to_string(dst_path)?; diff --git a/bin/oli/tests/rm.rs b/bin/oli/tests/rm.rs index 81e8c90a61b1..ace187d2772c 100644 --- a/bin/oli/tests/rm.rs +++ b/bin/oli/tests/rm.rs @@ -46,7 +46,7 @@ async fn test_rm_for_path_in_current_dir() -> Result<()> { let mut cmd = Command::cargo_bin("oli")?; - cmd.arg("rm").arg("dst.txt").current_dir(dir.path().clone()); + cmd.arg("rm").arg("dst.txt").current_dir(dir.path()); cmd.assert().success(); assert!(fs::read_to_string(&dst_path).is_err()); diff --git a/bin/oli/tests/stat.rs b/bin/oli/tests/stat.rs index 2e6c9d1d151a..5f8ac009a8fe 100644 --- a/bin/oli/tests/stat.rs +++ b/bin/oli/tests/stat.rs @@ -54,9 +54,7 @@ async fn test_stat_for_path_in_current_dir() -> Result<()> { let mut cmd = Command::cargo_bin("oli")?; - cmd.arg("stat") - .arg("dst.txt") - .current_dir(dir.path().clone()); + cmd.arg("stat").arg("dst.txt").current_dir(dir.path()); let res = cmd.assert().success(); let output = res.get_output().stdout.clone(); diff --git a/core/src/layers/retry.rs b/core/src/layers/retry.rs index e99737dd0a84..67239d3fd5ee 100644 --- a/core/src/layers/retry.rs +++ b/core/src/layers/retry.rs @@ -1283,7 +1283,7 @@ mod tests { fn poll_next(&mut self, cx: &mut Context<'_>) -> Poll>> { let mut bs = vec![0; 1]; match ready!(self.poll_read(cx, &mut bs)) { - Ok(v) if v == 0 => Poll::Ready(None), + Ok(0) => Poll::Ready(None), Ok(v) => Poll::Ready(Some(Ok(Bytes::from(bs[..v].to_vec())))), Err(err) => Poll::Ready(Some(Err(err))), } diff --git a/core/src/raw/oio/read/into_seekable_read_by_range.rs b/core/src/raw/oio/read/into_seekable_read_by_range.rs index 9f623d010aee..26ac62ba79d9 100644 --- a/core/src/raw/oio/read/into_seekable_read_by_range.rs +++ b/core/src/raw/oio/read/into_seekable_read_by_range.rs @@ -183,7 +183,7 @@ where self.poll_read(cx, buf) } State::Reading(r) => match ready!(Pin::new(r).poll_read(cx, buf)) { - Ok(n) if n == 0 => { + Ok(0) => { // Reset state to Idle after all data has been consumed. self.state = State::Idle; Poll::Ready(Ok(0)) @@ -293,7 +293,7 @@ where } State::Reading(r) => { match r.read(buf) { - Ok(n) if n == 0 => { + Ok(0) => { // Reset state to Idle after all data has been consumed. self.state = State::Idle; Ok(0) diff --git a/core/src/types/list.rs b/core/src/types/list.rs index 0c7a82d389d1..fbc64e71be61 100644 --- a/core/src/types/list.rs +++ b/core/src/types/list.rs @@ -97,7 +97,6 @@ impl Stream for Lister { let acc = self.acc.clone(); let fut = async move { - let path = path; let res = acc.stat(&path, OpStat::default()).await; (path, res)