This new method is not used yet outside of its own unit tests,
so this changeset should make no observable change.
The Rust parser implementation attempts to exactly replicate the behavior of
the Python one, even in edge cases where that behavior is… surprising.
New unit tests capture some of these edge cases.
This started as a line-by-line port. The main changes are:
- Pass around a parser mode enum instead of parser functions
- Inline the whole parser into one function
- Use [u8]::get which returns an Option, instead of indexing after explicitly checking the length.
nit: I find that these are more readable by using r#"this kind of string"#