Code:
#[macro_use]
extern crate serde_derive;
extern crate serde;
#[derive(Deserialize)]
struct A {
#[serde(default="false")]
a: bool,
}
fn main() {
println!("Hello, world!");
}
Link to playground:
https://play.rust-lang.org/?gist=8792a9fd44c0fff060f54e8f3b5281c3&version=stable
It seems you can work around it by creating a constant that is set to false.
Thanks! We are tracking this in #368.
For anyone coming across this and #368 has not been merged, a workaround can be:
#[macro_use]
extern crate serde_derive;
extern crate serde;
fn default_as_false() -> bool {
false
}
#[derive(Deserialize)]
struct A {
#[serde(default="default_as_false")]
a: bool,
}
fn main() {
println!("Hello, world!");
}
Link to playground:
https://play.rust-lang.org/?version=stable&mode=debug&edition=2015&gist=12e58011d3cb46ba08e849e8a20592d5
Most helpful comment
For anyone coming across this and #368 has not been merged, a workaround can be:
Link to playground:
https://play.rust-lang.org/?version=stable&mode=debug&edition=2015&gist=12e58011d3cb46ba08e849e8a20592d5