Browse Source

Remove hardcoded path, address clippy nits.

Kestrel 1 day ago
parent
commit
f8b44291bb
3 changed files with 7 additions and 6 deletions
  1. 1 1
      Cargo.toml
  2. 4 3
      src/check.rs
  3. 2 2
      src/data/ledger/print.rs

+ 1 - 1
Cargo.toml

@@ -7,7 +7,7 @@ edition = "2024"
 # core dependencies
 log = { version = "0.4.0" }
 anyhow = { version = "1" }
-stringstore = { version = "0.1.5", features = ["serde"], path = "../stringstore/" }
+stringstore = { version = "0.1.5", features = ["serde"] }
 rust_decimal = { version = "1.37" }
 itertools = { version = "0.14" }
 

+ 4 - 3
src/check.rs

@@ -8,9 +8,10 @@ fn check_equal_sum(root: &Root) -> Result<(), DataError> {
     for le in root.all_ledger_data() {
         let Some(mono) = le.mono_unit() else { continue };
 
-        let net = le.balances.iter().fold(Some(Decimal::ZERO), |acc, b| {
-            acc.and_then(|acc| acc.checked_add(*b.amount))
-        });
+        let net = le
+            .balances
+            .iter()
+            .try_fold(Decimal::ZERO, |acc, b| acc.checked_add(*b.amount));
         if net != Some(Decimal::ZERO) {
             let report = ariadne::Report::build(ariadne::ReportKind::Error, le.span()).with_labels(
                 le.balances.iter().map(|v| {

+ 2 - 2
src/data/ledger/print.rs

@@ -12,7 +12,7 @@ fn print_ledger_entry(root: &Root, entry: &LedgerEntry, padding: usize) {
         entry.datestamp.0,
         entry.datestamp.1,
         entry.datestamp.2,
-        entry.title.as_ref().map(String::as_str).unwrap_or("")
+        entry.title.as_deref().unwrap_or("")
     );
 
     let force_show = entry.balances.iter().unique_by(|b| *b.account).count() > 1;
@@ -43,7 +43,7 @@ fn print_ledger_entry(root: &Root, entry: &LedgerEntry, padding: usize) {
         }
     }
     // empty line afterwards
-    println!("");
+    println!();
 }
 
 pub fn print_ledger<'l>(root: &Root, entries: impl Iterator<Item = &'l Spanned<LedgerEntry>>) {