Allow advanced lookups in lookup and lookup_mut #89
Conversation
The new algorithm allows the explicit usage of "" and '' to denote key names. This is useful for accessing tables or keys that are named in a non-conventional manner.
Thanks! Can you add some negative tests for |
@@ -290,6 +290,46 @@ impl<'a> Parser<'a> { | |||
} | |||
} | |||
|
|||
// Parse an array index as a natural number | |||
fn array_index(&mut self) -> Option<String> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there's a method to parse integers somewhere else, perhaps that could be leveraged here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think parsing integers accepts the +xx and -xx notation, which I don't think should be applicable. I'll need to look through the parser methods...
Edit: number_or_datetime can be used whilst evaluating the Value type to be an integer. I'll try leveraging it.
Edit2: fn integer may be the solution with allow_sign = false 👍
Added a bunch of negative tests and some positive ones. I tried avoiding I'm a little uncertain of what convention to use in the tests. |
Looks great to me, thanks! |
These commits allow one to search for tables with unconventional names. Example:
These commits have some breaking changes for the tests, as sending a raw " into lookup will no longer work correctly. One must send
r#""\"""#
or"\"\\\"\""
instead.Performance: It may be possible to have a slight performance decrease for all lookups because each entry is now parsed and put into a String. This can be remedied by creating a lookup_simple method that takes simple names only.
Bugs discovered: the parser fails to parse "" and '' as a key name.