diff options
| author | Weicao-CatilGrass <1992414357@qq.com> | 2026-05-31 02:42:52 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-05-31 17:19:20 +0800 |
| commit | 2aa7bda3cb21ce6c052b82e08bcab79a625d04f2 (patch) | |
| tree | f10b89007fc67ca1a948f34abe6869b49296b932 /mingling_core/src/comp/suggest.rs | |
| parent | 3aa409a55e4f2f0ab41b0949cc06eb13c2da4a43 (diff) | |
Enhance code quality across the entire codebase
Diffstat (limited to 'mingling_core/src/comp/suggest.rs')
| -rw-r--r-- | mingling_core/src/comp/suggest.rs | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/mingling_core/src/comp/suggest.rs b/mingling_core/src/comp/suggest.rs index 6d64341..cd025a4 100644 --- a/mingling_core/src/comp/suggest.rs +++ b/mingling_core/src/comp/suggest.rs @@ -16,17 +16,20 @@ pub enum Suggest { } impl Suggest { - /// Creates a new Suggest variant containing a BTreeSet of suggestions. + /// Creates a new Suggest variant containing a `BTreeSet` of suggestions. + #[must_use] pub fn new() -> Self { Self::Suggest(BTreeSet::new()) } - /// Creates a FileCompletion variant. + /// Creates a `FileCompletion` variant. + #[must_use] pub fn file_comp() -> Self { Self::FileCompletion } /// Filters out already typed flag arguments from suggestion results. + #[must_use] pub fn strip_typed_argument(self, ctx: &ShellContext) -> Self { ctx.strip_typed_argument(self) } @@ -103,40 +106,44 @@ impl Ord for SuggestItem { impl SuggestItem { /// Creates a new simple suggestion without description. + #[must_use] pub fn new(suggest: String) -> Self { Self::Simple(suggest) } /// Creates a new suggestion with a description. + #[must_use] pub fn new_with_desc(suggest: String, description: String) -> Self { Self::WithDescription(suggest, description) } /// Adds a description to this suggestion, replacing any existing description. + #[must_use] pub fn with_desc(self, description: String) -> Self { match self { - Self::Simple(suggest) => Self::WithDescription(suggest, description), - Self::WithDescription(suggest, _) => Self::WithDescription(suggest, description), + Self::Simple(suggest) | Self::WithDescription(suggest, _) => { + Self::WithDescription(suggest, description) + } } } /// Returns the suggestion text. + #[must_use] pub fn suggest(&self) -> &String { match self { - Self::Simple(suggest) => suggest, - Self::WithDescription(suggest, _) => suggest, + Self::Simple(suggest) | Self::WithDescription(suggest, _) => suggest, } } /// Updates the suggestion text. pub fn set_suggest(&mut self, new_suggest: String) { match self { - Self::Simple(suggest) => *suggest = new_suggest, - Self::WithDescription(suggest, _) => *suggest = new_suggest, + Self::Simple(suggest) | Self::WithDescription(suggest, _) => *suggest = new_suggest, } } /// Returns the description if present. + #[must_use] pub fn description(&self) -> Option<&String> { match self { Self::Simple(_) => None, |
