Add is_empty and len to GitConfig
@@ -453,6 +453,18 @@ impl<'event> GitConfig<'event> {
Ok(())
}
+
+ /// Returns the number of entries in the config. This ignores any comments.
+ /// For example, a config with multiple empty sections will return 0.
+ pub fn len(&self) -> usize {
+ self.sections.values().fold(0, |acc, section| acc + section.len())
+ }
+
+ /// Returns if there are no entries in the config. This will return true
+ /// if there are only empty sections or comments.
+ pub fn is_empty(&self) -> bool {
+ self.sections.values().all(|section| section.is_empty())
+ }
}
/// # Raw value API
