Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parse_parens, parse_braces, parse_brackets and structs returned by them are public API now. #1592

Closed
wants to merge 1 commit into from

Conversation

rrupy
Copy link

@rrupy rrupy commented Feb 27, 2024

#1519
parenthesized!, braced! and bracketed! macros are very verbous in situations where you want to handle Err in current function beacause in this case they are expand in return statement. That's why they must be public.

Code example:

If you have an optional code in parentheses and you don't need the paren token:

if input.peek(token::Paren) {
    let paren_content;
    parenthesized!(paren_content in input);
    paren_content.parse::<ExprUnsafe>()?;
}

vs

if let Ok(Parens { token: _, content}) = parse_parens(input) {
    content.parse::<ExprUnsafe>()?;
}

Copy link
Owner

@dtolnay dtolnay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the code example you've shared, I think the difference is not significant enough to justify exposing these additional APIs.

Thanks anyway for the PR!

@dtolnay dtolnay closed this Mar 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants