Repository: not-fl3/nanoserde (rust)

Issue:
Bug in parsing `#` token in TOML
Hi,

Thanks for a great library.

I use `nanoserde` to load configuration from a TOML file. That file contains some comments but `nanoserde` does not support comments in TOML yet.

Could you please add it? Or let me know if you want a PR.

Thanks

Pull request:
Fix bug in parsing `#` token in TOML
Close #61 

Patch:
diff --git a/src/toml.rs b/src/toml.rs
index c41cb9a..96f04b5 100644
--- a/src/toml.rs
+++ b/src/toml.rs
@@ -473,6 +473,14 @@ impl TomlParser {
                     while self.cur != '\n' && self.cur != '\0' {
                         self.next(i);
                     }
+
+                    while self.cur == '\n'
+                        || self.cur == '\r'
+                        || self.cur == '\t'
+                        || self.cur == ' '
+                    {
+                        self.next(i);
+                    }
                 }
                 '"' => {
                     let mut val = String::new();


Test patch:
diff --git a/tests/toml.rs b/tests/toml.rs
index a53ded8..7e2fda1 100644
--- a/tests/toml.rs
+++ b/tests/toml.rs
@@ -4,10 +4,11 @@ use nanoserde::TomlParser;
 fn de_toml() {
     let toml_str = r#"
 [[array]]
-name = "a"
+# a
+name = "a" #aasdf
 
 [[array]]
-name = "b"
+name = "b#asdf"
 data = 123
 
 [[array]]
@@ -24,7 +25,7 @@ hmm = "b"
     let toml = TomlParser::parse(toml_str).unwrap();
 
     assert_eq!(toml["array"].arr()[0]["name"].str(), "a");
-    assert_eq!(toml["array"].arr()[1]["name"].str(), "b");
+    assert_eq!(toml["array"].arr()[1]["name"].str(), "b#asdf");
     assert_eq!(toml["array"].arr()[1]["data"].num(), 123.);
 
     assert_eq!(toml["other_array"].arr()[0]["hmm"].str(), "a");