From: Scott Worley Date: Mon, 19 Aug 2024 19:43:34 +0000 (-0700) Subject: Trim whitespace when parsing entries X-Git-Tag: v0.2.0~8 X-Git-Url: http://git.scottworley.com/tablify/commitdiff_plain/0d999bc3cb6e12f158f71a2a28fecfa992e09b47 Trim whitespace when parsing entries --- diff --git a/src/lib.rs b/src/lib.rs index 01668eb..5b06e70 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -51,8 +51,8 @@ impl From<&str> for Entry { instance: None, }, Some((col, instance)) => Entry { - col: String::from(col), - instance: Some(String::from(instance)), + col: String::from(col.trim()), + instance: Some(String::from(instance.trim())), }, } } @@ -174,6 +174,13 @@ mod tests { instance: Some(String::from("bar")) } ); + assert_eq!( + Entry::from("foo: bar"), + Entry { + col: String::from("foo"), + instance: Some(String::from("bar")) + } + ); } #[test]