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

Multiple selectors on enum variant #44

Open
cornytrace opened this issue Nov 23, 2022 · 0 comments
Open

Multiple selectors on enum variant #44

cornytrace opened this issue Nov 23, 2022 · 0 comments

Comments

@cornytrace
Copy link

Consider the following code:

#[derive(Nom)]
#[nom(LittleEndian, Selector = "FileType")]
pub enum FileBody {
    #[nom(Selector = "FileType::DIR")]
    Dir(DirEntry),
    #[nom(Selector = "FileType::FILE | FileType::BYTES")]
    File(FileEntry),
}

This fails with the following error message:

proc-macro derive panicked
message: Parsing the 'nom' meta attribute failed: Error("unexpected token")

Stacking selector attributes results in runtime parsing errors:

#[derive(Nom)]
#[nom(LittleEndian, Selector = "FileType")]
pub enum FileBody {
    #[nom(Selector = "FileType::DIR")]
    Dir(DirEntry),
    #[nom(Selector = "FileType::FILE")]
    #[nom(Selector = "FileType::BYTES")]
    File(FileEntry),
}

Or:

#[derive(Nom)]
#[nom(LittleEndian, Selector = "FileType")]
pub enum FileBody {
    #[nom(Selector = "FileType::DIR")]
    Dir(DirEntry),
    #[nom(Selector = "FileType::FILE", Selector = "FileType::BYTES")]
    File(FileEntry),
}
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

No branches or pull requests

1 participant