Conversation
4318d43 to
5495f12
Compare
| base: "John".to_string(), | ||
| scope: None, | ||
| }), | ||
| lastname: None, |
There was a problem hiding this comment.
In that case I expect more to retrieve an enum here.
The test is not easy to understand as a person has basically a first name and a last name, so it's not a choice, more a combination.
I think the example here is more relevant: https://www.w3schools.com/xml/el_choice.asp
Where. Person may have role employee or member.
So for me the expected code will be:
let model = Person::Employee("John".to_string());
// Generated part by xml-schema
enum Person {
Employee(String),
Member(String),
}| let model = Person { | ||
| firstname: "John".to_string(), | ||
| lastname: "".to_string(), | ||
| }; |
There was a problem hiding this comment.
in that case I expect to have:
Person {
parents: vec![Parent::Firstname("John".to_string())],
}
There was a problem hiding this comment.
Yup exactly, I just patched this in one commit just to get it to compile. I am currently working on making this a vector.
There was a problem hiding this comment.
Oh sorry I just implemented:
let model = Person {
firstname_list: vec!["John".to_string()],
lastname_list: vec![],
};
which i notice now is a bit different from what you imagined.
There was a problem hiding this comment.
I have some attempts which try to implement this as enum, you can see the last commit here: 740c37b
Unforuntately the test fails with:
thread 'choice_multiple' panicked at xml_schema/tests/choice.rs:99:3:
assertion `left == right` failed
left: Gift { content: [] }
right: Gift { content: [price_history(1), price_history(3)] }
So I probably got the yaserde config wrong :(
I will pause this work for now.
Some things still to do:
Supersedes #20