aboutsummaryrefslogtreecommitdiff
path: root/src/edit.rs
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-04-17 09:45:13 +0800
committer魏曹先生 <1992414357@qq.com>2026-04-17 09:45:13 +0800
commit497a667f49c8dea870a8a61ddabd95e24765a80d (patch)
tree84bed9d9b604af593b1031ae62ca7b3fec4d7112 /src/edit.rs
parent5e7d1968e94bf39d369de0e6ef98cf383cfd3d6f (diff)
Apply clippy suggestions
- Use `BTreeMap::entry` API in `update_item` - Replace `or_insert_with(Vec::new)` with `or_default` - Iterate over map values instead of key-value pairs - Use `std::io::Error::other` for custom errors - Simplify filter logic with direct predicate - Replace manual `Into` implementation with `From` - Remove unnecessary explicit returns
Diffstat (limited to 'src/edit.rs')
-rw-r--r--src/edit.rs14
1 files changed, 2 insertions, 12 deletions
diff --git a/src/edit.rs b/src/edit.rs
index f9c751c..d505fc8 100644
--- a/src/edit.rs
+++ b/src/edit.rs
@@ -17,10 +17,7 @@ pub fn input_with_editor_cutsom(
let status = Command::new(editor).arg(cache_path).status()?;
if !status.success() {
- return Err(std::io::Error::new(
- std::io::ErrorKind::Other,
- "Editor exited with non-zero status",
- ));
+ return Err(std::io::Error::other("Editor exited with non-zero status"));
}
// Read the modified content
@@ -29,14 +26,7 @@ pub fn input_with_editor_cutsom(
// Remove comment lines and trim
let processed_content: String = content
.lines()
- .filter_map(|line| {
- let trimmed = line.trim();
- if trimmed.starts_with(comment_prefix) {
- None
- } else {
- Some(line)
- }
- })
+ .filter(|line| !line.trim().starts_with(comment_prefix))
.collect::<Vec<&str>>()
.join("\n");