diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-04-17 09:45:13 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-04-17 09:45:13 +0800 |
| commit | 497a667f49c8dea870a8a61ddabd95e24765a80d (patch) | |
| tree | 84bed9d9b604af593b1031ae62ca7b3fec4d7112 /src/bill.rs | |
| parent | 5e7d1968e94bf39d369de0e6ef98cf383cfd3d6f (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/bill.rs')
| -rw-r--r-- | src/bill.rs | 11 |
1 files changed, 5 insertions, 6 deletions
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) |
