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

Add require_ident to Path #1496

Merged
merged 1 commit into from
Sep 10, 2023
Merged

Add require_ident to Path #1496

merged 1 commit into from
Sep 10, 2023

Conversation

Fancyflame
Copy link
Contributor

@Fancyflame Fancyflame commented Sep 2, 2023

Parsing options inside a list is very commonplace:

#[my_attr(path(linux = "path/to/file")]
          ^^^^ ^^^^^
          Here is our options

Although we have get_ident, we (at least I) would not like to handle None. Just like require_path, require_list and require_key_value, which I love.

match &*path.require_ident()?.to_string() {
    "linux" => { ... }
    "windows" => { ... }
    "macos" => { ... }
    other => return Err(Error::new(
        Span::call_site(),
        format!("platform `{other}` not supported")
    ))
}

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.

Thanks!

@dtolnay dtolnay merged commit 07a89dd into dtolnay:master Sep 10, 2023
17 checks passed
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.

None yet

2 participants