From 08d9132f15e7dd901e4e829481adbce208e86e17 Mon Sep 17 00:00:00 2001 From: Joshua Chapman Date: Sun, 18 Sep 2022 15:50:40 +0200 Subject: [PATCH 1/2] fix(case-insensitive): remove type parameter Remove the type :: from the None in the Default trait implementation for Ini since it will fail to compile, because it will require a None::> --- src/lib.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 11d277e..fca83cc 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -664,11 +664,9 @@ impl Default for Ini { /// Creates an ini instance with an empty general section. This allows [Ini::general_section] /// and [Ini::with_general_section] to be called without panicking. fn default() -> Self { - let mut result = Ini { - sections: Default::default(), - }; + let mut result = Ini { sections: Default::default() }; - result.sections.insert(None::, Default::default()); + result.sections.insert(None, Default::default()); result } From bf1d0d36495540a8b6490099d47a1959d93cc95c Mon Sep 17 00:00:00 2001 From: Joshua Chapman Date: Sun, 18 Sep 2022 16:29:52 +0200 Subject: [PATCH 2/2] fix: len in test with feature `brackets-in-section-names` The test is different from the test without feature active, it doesn't count the general section in the len assertion. --- src/lib.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index fca83cc..cdcf107 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -501,7 +501,7 @@ impl<'a> From> for SectionEntry<'a> { } /// Ini struct -#[derive(Clone)] +#[derive(Debug, Clone)] pub struct Ini { sections: ListOrderedMultimap, } @@ -654,7 +654,7 @@ impl Ini { self.sections.keys_len() } - /// Check if object coutains no section + /// Check if object contains no section pub fn is_empty(&self) -> bool { self.sections.is_empty() } @@ -1431,7 +1431,8 @@ mod test { assert!(opt.is_ok()); let output = opt.unwrap(); - assert_eq!(output.len(), 2); + // there is always a general section + assert_eq!(output.len(), 3); assert!(output.section(Some("sec1")).is_some()); let sec1 = output.section(Some("sec1")).unwrap(); @@ -1906,10 +1907,8 @@ a3 = n3 let ini = Ini::new(); - let opt = WriteOption { - line_separator: LineSeparator::CR, - ..Default::default() - }; + let opt = WriteOption { line_separator: LineSeparator::CR, + ..Default::default() }; let mut buf = Vec::new(); ini.write_to_opt(&mut buf, opt).unwrap();