-
Notifications
You must be signed in to change notification settings - Fork 33
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
match enum struct variant defect? #103
Comments
Yes, this seems like a defect in ructe. I'll try to fix it. |
I guess it can be fixed here: ructe/src/templateexpression.rs Lines 210 to 244 in 75b2e7d
Unfortunatly I only have some experience with https://pest.rs/ . Nom seems to be a fine parsing library too. Maybe I will find some spare time this weekend to look into https://lib.rs/crates/nom. Maybe I can contribute in the future ^^. Please take note there is more to the match syntax to explore: https://doc.rust-lang.org/book/ch18-03-pattern-syntax.html There are many cases I didn't know of before. For example the enum Variation {
Structure {
id: usize,
name: String,
not_used: i32,
},
SimpleVariant,
}
fn main() {
let variation = Variation::Structure {
id: 42,
name: "an example for the great ructe lib 🦀".into(),
not_used: -123,
};
match variation {
Variation::Structure {
id,
name: the_name,
..
} => {
println!(r#"Object with ID {} has the name "{}""#, id, the_name);
}
Variation::SimpleVariant => {
println!("This is just a simple variant match");
}
}
} Please consider documenting which patterns are explicitly implemented and tested. If the mentioned enum/struct patterns work, that would be great. If you cannot fix it, because of lack of time or whatever reason, I will try to make a good work around =) thankyou 🙏 Are you looking for help with this library of yours? If so I will check if I can take off some spare time to contribute to this lib. |
I try to match the following enum with internal struct variants
with
The error message is:
this works:
In rust this works:
Am I doing something wrong? Is this a defect of the library?
I enjoy using ructe 🦀 thankyou for sharing 🙏
The text was updated successfully, but these errors were encountered: