From c6cd9229f2e053b280379213ffc04ccb2800d388 Mon Sep 17 00:00:00 2001 From: Jorge Perez Burgos Date: Tue, 19 Mar 2024 19:43:51 +0100 Subject: [PATCH] Fmt and clippy fixes. --- src/parsers/degiro.rs | 1 - src/parsers/ib.rs | 13 +++++-------- src/reports/aeat_720.rs | 4 +--- src/utils/zip.rs | 3 +-- 4 files changed, 7 insertions(+), 14 deletions(-) diff --git a/src/parsers/degiro.rs b/src/parsers/degiro.rs index d2896c1..0ee2ca6 100644 --- a/src/parsers/degiro.rs +++ b/src/parsers/degiro.rs @@ -305,7 +305,6 @@ impl DegiroParser { "balance notes", many0(|x| DegiroParser::balance_note(x, broker)), )(input) - .map(|(next_input, res)| (next_input, res)) } fn parse_account_notes(&self, notes: &str) -> Result { diff --git a/src/parsers/ib.rs b/src/parsers/ib.rs index ecbd4a9..f9b3eca 100644 --- a/src/parsers/ib.rs +++ b/src/parsers/ib.rs @@ -151,7 +151,7 @@ impl IBParser { .map(|x| x.value()) .unwrap() .as_element() - .map(|x| has_class(x)) + .map(has_class) == Some(true) { state = NoteState::Note; @@ -173,7 +173,7 @@ impl IBParser { .map(|x| x.value()) .unwrap() .as_element() - .map(|x| has_class(x)) + .map(has_class) == Some(true) { state = NoteState::Invalid; @@ -201,11 +201,8 @@ impl IBParser { if let Some(element) = table_row.first_child().unwrap().value().as_element() { if element.has_class("header-asset", CaseSensitivity::AsciiCaseInsensitive) { - if table_row.text().next() == Some(IBParser::STOCKS_STR) { - start_parsing_symbols = true; - } else { - start_parsing_symbols = false; - } + start_parsing_symbols = + table_row.text().next() == Some(IBParser::STOCKS_STR); continue; } } @@ -310,7 +307,7 @@ impl IBParser { .map(|x| x.value()) .unwrap() .as_element() - .map(|x| has_class(x)) + .map(has_class) == Some(true) { currency = table_row.text().next(); diff --git a/src/reports/aeat_720.rs b/src/reports/aeat_720.rs index 7a0ccaa..bb2cf7d 100644 --- a/src/reports/aeat_720.rs +++ b/src/reports/aeat_720.rs @@ -577,9 +577,7 @@ impl Aeat720Report { } pub fn generate(self) -> Result> { - let mut result = Vec::new(); - - result.reserve( + let mut result = Vec::with_capacity( AEAT_720_REGISTER_SIZE_BYTES * (self.details.len() + 1) + (self.details.len() + 1), ); diff --git a/src/utils/zip.rs b/src/utils/zip.rs index 3a34717..c680609 100644 --- a/src/utils/zip.rs +++ b/src/utils/zip.rs @@ -14,8 +14,7 @@ pub fn read_zip(data: Vec) -> Result> { } let mut file = archive.by_index(0)?; - let mut contents = Vec::new(); - contents.reserve(file.size() as usize); + let mut contents = Vec::with_capacity(file.size() as usize); file.read_exact(&mut contents)?;