]> git.scottworley.com Git - tablify/commitdiff
Trim whitespace when parsing entries
authorScott Worley <scottworley@scottworley.com>
Mon, 19 Aug 2024 19:43:34 +0000 (12:43 -0700)
committerScott Worley <scottworley@scottworley.com>
Mon, 19 Aug 2024 19:43:34 +0000 (12:43 -0700)
src/lib.rs

index 01668eb3db650e39157a85f0dc1f50b3663422c2..5b06e705aecaaac8fd071f064dd63d731038687d 100644 (file)
@@ -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]