From 9000c8a46b1a15ecdf173ff941ebd32d0c19db00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn-Michael=20Miehe?= <40151420+ldericher@users.noreply.github.com> Date: Wed, 25 Jun 2025 16:34:32 +0000 Subject: [PATCH] clippy fix --- src/appstate.rs | 2 ++ src/cli.rs | 12 ++++++------ src/lib.rs | 3 +++ src/output.rs | 2 +- src/sharry/client.rs | 2 +- 5 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/appstate.rs b/src/appstate.rs index 6ea5a25..9f423d1 100644 --- a/src/appstate.rs +++ b/src/appstate.rs @@ -41,6 +41,7 @@ impl AppState { } } + #[must_use] pub fn try_resume(args: &Cli) -> Option { let inner = CacheFile::try_resume(args) .inspect_err(|e| debug!("could not resume from hash {:?}: {e}", args.get_hash())) @@ -138,6 +139,7 @@ impl AppState { Ok(self.inner.peek_uploading().is_none() && self.inner.queue_empty()) } + #[must_use] pub fn rewind_chunk(mut self) -> Option { self.inner = self.inner.rewind_chunk()?; diff --git a/src/cli.rs b/src/cli.rs index 546427b..aafb8c4 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -101,26 +101,26 @@ fn parse_sharry_file(data: &str) -> io::Result { } impl Cli { - pub fn get_timeout(&self) -> Option { + #[must_use] pub fn get_timeout(&self) -> Option { (!self.timeout.is_zero()).then_some(self.timeout) } - pub fn get_uri(&self) -> Uri { + #[must_use] pub fn get_uri(&self) -> Uri { Uri::new(&self.protocol, &self.url) } - pub fn may_retry(&self, tries: u32) -> bool { + #[must_use] pub fn may_retry(&self, tries: u32) -> bool { match self.retry_limit { 0 => true, limit => tries < limit, } } - pub fn get_share_request(&self) -> NewShareRequest { + #[must_use] pub fn get_share_request(&self) -> NewShareRequest { NewShareRequest::new(&self.name, self.description.as_ref(), self.max_views) } - pub fn get_level_filter(&self) -> LevelFilter { + #[must_use] pub fn get_level_filter(&self) -> LevelFilter { match self.verbose { 0 => LevelFilter::Error, 1 => LevelFilter::Warn, @@ -134,7 +134,7 @@ impl Cli { self.files.iter().map(FileTrait::get_name).collect() } - pub fn get_hash(&self) -> String { + #[must_use] pub fn get_hash(&self) -> String { let file_refs = { let mut refs: Vec<_> = self.files.iter().collect(); refs.sort_unstable(); diff --git a/src/lib.rs b/src/lib.rs index 7ef854d..27e5322 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,3 +1,6 @@ +// TODO fix with documentation +#![allow(clippy::missing_errors_doc)] + mod appstate; mod cachefile; mod cli; diff --git a/src/output.rs b/src/output.rs index 0ca1038..db164bd 100644 --- a/src/output.rs +++ b/src/output.rs @@ -10,7 +10,7 @@ type StaticStyled<'t> = LazyLock>; pub static SHRUPL: StaticStyled = LazyLock::new(|| style("ShrUpl").yellow().bold()); -pub fn prompt_continue() -> bool { +#[must_use] pub fn prompt_continue() -> bool { let prompt = format!( "This operation has previously been stopped. {}", style("How to proceed?").cyan() diff --git a/src/sharry/client.rs b/src/sharry/client.rs index d3fdac0..0469710 100644 --- a/src/sharry/client.rs +++ b/src/sharry/client.rs @@ -149,7 +149,7 @@ impl ClientError { Self::Unknown(into_string(e)) } - pub fn is_fatal(&self) -> bool { + #[must_use] pub fn is_fatal(&self) -> bool { match self { Self::InvalidParameter(p) => p.is_fatal(), Self::Unknown(_) => true,