From 0d999bc3cb6e12f158f71a2a28fecfa992e09b47 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Mon, 19 Aug 2024 12:43:34 -0700 Subject: [PATCH] Trim whitespace when parsing entries --- src/lib.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) 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] -- 2.44.1