pest-parser / pest

The Elegant Parser
https://pest.rs
Apache License 2.0
4.67k stars 262 forks source link

Adding get_input() to types that already have public as_str() 🏷️ #890

Closed 0nyr closed 1 year ago

0nyr commented 1 year ago

Hello Pest team.

This PR is a followup to my last PR Merging Spans :recycle: #887.

In this last PR, I have introduced a getter for Span in order to be able to access the private input field of a Span. This allows to access the original input string without having to pass its reference everywhere in function arguments. In my personal project, I use this feature to be able to merge Spans.

There is no reason not to add this function to other types that also have this private field and a public as_str() function. I have added meaningful doc and tests and run cargo fmt.

I also renamed my tests to all have different names, making test debugging via commands like cargo test <get_input_test> -- --nocapture non-ambiguous.