docs: add Panics sections to line_col() and PrattParser::parse()#1167
Conversation
📝 WalkthroughWalkthroughThis pull request adds Rustdoc documentation to two public functions in the pest library, specifically documenting the panic conditions that occur when functions receive out-of-bounds or invalid input. No functional logic or control flow was modified. Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
pest/src/pratt_parser.rs (1)
315-319: Consider documenting the empty pairs panic condition.The documentation accurately covers the panic conditions for missing mappers and unexpected tokens. However, it doesn't mention that
parse()also panics whenpairsis empty (as shown in Line 342'sexpectcall). While this is documented at the struct level (Line 104), including it here would make the method documentation more complete and self-contained.📝 Suggested enhancement
/// # Panics /// -/// Panics if the input pairs contain a prefix operator with no [`map_prefix`], +/// Panics if the input pairs are empty, contain a prefix operator with no [`map_prefix`], /// an infix operator with no [`map_infix`], a postfix operator with no [`map_postfix`], /// or an unexpected token that is not a valid prefix, primary, infix, or postfix expression.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@pest/src/pratt_parser.rs` around lines 315 - 319, Update the parse() method docs to also state that it will panic when the provided pairs iterator is empty (the expect call at parse()'s body will trigger), so the panic conditions list includes "panics if pairs is empty" in addition to the existing missing mapper and unexpected token cases; reference the parse() function and the struct-level note (previously at the struct doc) to make this method's documentation self-contained.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@pest/src/pratt_parser.rs`:
- Around line 315-319: Update the parse() method docs to also state that it will
panic when the provided pairs iterator is empty (the expect call at parse()'s
body will trigger), so the panic conditions list includes "panics if pairs is
empty" in addition to the existing missing mapper and unexpected token cases;
reference the parse() function and the struct-level note (previously at the
struct doc) to make this method's documentation self-contained.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: c88bdf10-0a68-45cb-b477-80e21bcf45be
📒 Files selected for processing (2)
pest/src/position.rspest/src/pratt_parser.rs
Two public functions that can panic were missing # Panics documentation:
Addresses #999
Summary by CodeRabbit