From: Scott Worley Date: Fri, 4 Oct 2024 04:38:41 +0000 (-0700) Subject: Use Default trait for default Config X-Git-Tag: v0.4.0~3 X-Git-Url: http://git.scottworley.com/tablify/commitdiff_plain/bc55297895c1343baa24c93330438972a0c4ac89?ds=sidebyside;hp=71e34cc04258862ab4ef7177c2719ca3ec8bedcf Use Default trait for default Config --- diff --git a/src/lib.rs b/src/lib.rs index 74a54a2..6d147dd 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -31,11 +31,14 @@ impl Config { 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#" @@ -213,7 +216,7 @@ impl<'cfg, Input: Iterator>> Iterator } fn read_input(input: impl std::io::Read) -> Result<(Vec, 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::, _>>() @@ -724,7 +727,7 @@ mod tests { fn test_render_row() { assert_eq!( render_row( - &DEFAULT_CONFIG, + &Config::default(), &["foo".to_owned()], &mut Rowlike::Row(Row { label: "nope".to_owned(),