]> git.scottworley.com Git - tablify/commitdiff
Use Default trait for default Config
authorScott Worley <scottworley@scottworley.com>
Fri, 4 Oct 2024 04:38:41 +0000 (21:38 -0700)
committerScott Worley <scottworley@scottworley.com>
Fri, 4 Oct 2024 05:09:16 +0000 (22:09 -0700)
src/lib.rs

index 74a54a2b814b96c88ba540c61bb962036105922e..6d147dd9f250506eb0061a85071d6f329c438cdf 100644 (file)
@@ -31,11 +31,14 @@ impl Config {
         Ok(())
     }
 }
         Ok(())
     }
 }
-
-const DEFAULT_CONFIG: Config = Config {
-    column_threshold: 2,
-    static_columns: vec![],
-};
+impl Default for Config {
+    fn default() -> Self {
+        Self {
+            column_threshold: 2,
+            static_columns: vec![],
+        }
+    }
+}
 
 const HEADER: &str = r#"<!DOCTYPE html>
 <html>
 
 const HEADER: &str = r#"<!DOCTYPE html>
 <html>
@@ -213,7 +216,7 @@ impl<'cfg, Input: Iterator<Item = Result<String, std::io::Error>>> Iterator
 }
 
 fn read_input(input: impl std::io::Read) -> Result<(Vec<Rowlike>, Config), std::io::Error> {
 }
 
 fn read_input(input: impl std::io::Read) -> Result<(Vec<Rowlike>, Config), std::io::Error> {
-    let mut config = DEFAULT_CONFIG;
+    let mut config = Config::default();
     let reader = Reader::new(&mut config, std::io::BufReader::new(input).lines());
     reader
         .collect::<Result<Vec<_>, _>>()
     let reader = Reader::new(&mut config, std::io::BufReader::new(input).lines());
     reader
         .collect::<Result<Vec<_>, _>>()
@@ -724,7 +727,7 @@ mod tests {
     fn test_render_row() {
         assert_eq!(
             render_row(
     fn test_render_row() {
         assert_eq!(
             render_row(
-                &DEFAULT_CONFIG,
+                &Config::default(),
                 &["foo".to_owned()],
                 &mut Rowlike::Row(Row {
                     label: "nope".to_owned(),
                 &["foo".to_owned()],
                 &mut Rowlike::Row(Row {
                     label: "nope".to_owned(),