Handling of non-dec numbers (eg "0x2a")
Grinkers opened this issue · 1 comments
Grinkers commented
According to the spec, this isn't an issue. Here's a very relavent discussion I found while looking into this.
edn-format/edn#47
here is some examples of read-string
(clojure.edn/read-string "0x2a") -> 42
(clojure.edn/read-string "2r101010") -> 42
(clojure.edn/read-string "36r16") -> 42
As far as this crate is concerned, I think maybe it should be more liberal than the spec for some convenient patterns. In particular, "0x" being supported in both rust and clojure.edn/read-string. "2r" vs "0b" is a bit harder of a thing and could be a future nightmare. Alternatively, perhaps this crate should be more apparent with off-spec integers so these doesn't succeed.
assert_eq!(Edn::from_str("0x2a").unwrap().to_int().unwrap(), 0);
assert_eq!(Edn::from_str("42FOOBAR9000").unwrap().to_int().unwrap(), 42);
naomijub commented
Seems interesting, are you able to open a PR for this?