From 497a667f49c8dea870a8a61ddabd95e24765a80d Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Fri, 17 Apr 2026 09:45:13 +0800 Subject: 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 --- src/bill.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src/bill.rs') diff --git a/src/bill.rs b/src/bill.rs index 291b759..62a1d3b 100644 --- a/src/bill.rs +++ b/src/bill.rs @@ -62,8 +62,10 @@ impl Bills { /// Update the bill item with the specified ID pub fn update_item(&mut self, id: &Uuid, item: BillItem) -> bool { - if self.items.contains_key(&id.to_string()) { - self.items.insert(id.to_string(), item); + if let std::collections::btree_map::Entry::Occupied(mut e) = + self.items.entry(id.to_string()) + { + e.insert(item); true } else { false @@ -100,10 +102,7 @@ impl SplitResult { reason, }; - self.items - .entry(payer) - .or_insert_with(Vec::new) - .push(result_item); + self.items.entry(payer).or_default().push(result_item); } /// Get all bill items for a specified payer (immutable reference) -- cgit