-
Notifications
You must be signed in to change notification settings - Fork 90
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
Improve bool parsing as XML can support also 0/1 value as bool #88
Improve bool parsing as XML can support also 0/1 value as bool #88
Conversation
In #51 a test was requested to complete the feature. I added a test that deserializes |
test_parse_ok(&[ | ||
("<bla>true</bla>", true), | ||
("<bla>false</bla>", false), | ||
("<bla> true </bla>", true), | ||
("<bla> false </bla>", false), | ||
("<bla>1</bla>", true), | ||
("<bla>0</bla>", false), | ||
]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you also add a test for the error case please?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ping on this one too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I see, it was fixed. Nvm.
src/de/mod.rs
Outdated
match s.as_str() { | ||
"true" | "1" => visitor.visit_bool(true), | ||
"false" | "0" => visitor.visit_bool(false), | ||
_ => Err(ErrorKind::UnexpectedToken( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe better to use Error::unknown_variant
or Error::invalid_value
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@RReverser, are you suggesting creating a new ErrorKind
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missed this. No, I meant using Serde's own method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. I chose Error::invalid_value
.
This reverts commit e39a9b8.
(approved; as a reminder, please clean up history a bit before merging) |
Improve bool parsing as XML can support also 0/1 value as bool
Continuation of #51