Fix: change display impl to match as str#1151
Conversation
📝 WalkthroughWalkthroughDisplay implementations for Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
tomtau
left a comment
There was a problem hiding this comment.
maybe the old formatting can be preserved with the "alternate" flag on the formatter (or the other way round)?
so one can have both with format!("{pair}") and format!("{pair:#}") ?
| // option. All files in the project carrying such notice may not be copied, | ||
| // modified, or distributed except according to those terms. | ||
|
|
||
| use alloc::format; |
There was a problem hiding this comment.
if it's removed here, the tests should import it: https://github.com/pest-parser/pest/actions/runs/21472450223/job/61858601867?pr=1151#step:4:240
There was a problem hiding this comment.
It seems like format is used in cfg("pretty-print") so I added the import under feature flag.
c4ca742 to
f2949fd
Compare
I added this now so that |
Fixes issue #1149.
Bug description from the original issue:
What was done
Displayimplementation forPairwas changed as this is whereto_stringcomes from. Rather than giving pair name and it's range it now simply returns the span content usingas_str, which quarantees thatas_str().to_string()andto_string()will give the same output for Pair, even if for some reason as_str would be changed in future. I also added a simple unit test for this.Considerations
This changes how displaying of Pairs work. However, there was already a Debug implementation that would give the whole Pair struct.
This is my first ever (code) contribution to OSS, so any feedback would be appreciated.
Summary by CodeRabbit
Refactor
Tests
✏️ Tip: You can customize this high-level summary in your review settings.