From 95abc3f334a5ad9ab457c06735412657d7878e47 Mon Sep 17 00:00:00 2001 From: Kevin Nakamura Date: Fri, 15 Dec 2023 15:56:10 +0900 Subject: [PATCH] Symbol not limited to 200 characters. Remove arbitrarily defined limits on `take_while`s. --- README.md | 2 +- src/deserialize/parse.rs | 4 ++-- tests/deserialize.rs | 3 +++ 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 31499a6..b30f630 100644 --- a/README.md +++ b/README.md @@ -385,7 +385,7 @@ fn complex_ok() -> Result<(), EdnError> { - [x] String `"\"string\""` - [x] Numbers `"324352"`, `"3442.234"`, `"3/4"` - [x] Keywords `:a` - - [x] Symbol `sym-bol-s` with a maximum of 200 chars + - [x] Symbol `sym-bol-s` - [x] Vector `"[1 :2 \"d\"]"` - [x] List `"(1 :2 \"d\")"` - [x] Set `"#{1 2 3}"` diff --git a/src/deserialize/parse.rs b/src/deserialize/parse.rs index 81d7f5e..b392a25 100644 --- a/src/deserialize/parse.rs +++ b/src/deserialize/parse.rs @@ -139,7 +139,7 @@ fn read_symbol(a: char, chars: &mut iter::Enumerate>) -> Re let c_len = chars .clone() .enumerate() - .take_while(|&(i, c)| i <= 200 && !c.1.is_whitespace() && !DELIMITERS.contains(&c.1)) + .take_while(|&(_, c)| !c.1.is_whitespace() && !DELIMITERS.contains(&c.1)) .count(); let i = chars .clone() @@ -290,7 +290,7 @@ fn read_char(chars: &mut iter::Enumerate>) -> Result(); diff --git a/tests/deserialize.rs b/tests/deserialize.rs index e92fe63..ce206e2 100644 --- a/tests/deserialize.rs +++ b/tests/deserialize.rs @@ -684,6 +684,9 @@ mod test { Edn::Symbol("your-hair!-is+_parsed?".to_string()), ])); assert_eq!(edn, expected); + + let lorem = "Lorem-ipsum-dolor-sit-amet-consectetur-adipiscing-elit-sed-do-eiusmod-tempor-incididunt-ut-labore-et-dolore-magna-aliqua.-Ut-enim-ad-minim-veniam-quis-nostrud-exercitation-ullamco-laboris-nisi-ut-aliquip-ex-ea-commodo-consequat.-Duis-aute-irure-dolor-in-reprehenderit-in-voluptate-velit-esse-cillum-dolore-eu-fugiat-nulla-pariatur.-Excepteur-sint-occaecat-cupidatat-non-proident-sunt-in-culpa-qui-officia-deserunt-mollit-anim-id-est-laborum".to_string(); + assert_eq!(Edn::from_str(lorem.as_str()).unwrap(), Edn::Symbol(lorem)); } #[test]