The description of this extension is kind of casual, so I went to test it:
#[derive(Debug, serde::Deserialize, serde::Serialize)]
struct MaybeFields {
f1: i64,
f2: Option<i64>,
f3: Option<Option<i64>>,
}
fn main() {
let x1: std::result::Result<MaybeFields, _> = ron::from_str(
"#![enable(implicit_some)]\n(f1: 1)"
);
let x2: std::result::Result<MaybeFields, _> = ron::from_str(
"#![enable(implicit_some)]\n(f1: 1, f2: None, f3: None)"
);
let x3: std::result::Result<MaybeFields, _> = ron::from_str(
"#![enable(implicit_some)]\n(f1: 1, f2: 2, f3: 3)"
);
let x4: std::result::Result<MaybeFields, _> = ron::from_str(
"#![enable(implicit_some)]\n(f1: 1, f2: 2, f3: Some(3))"
);
let x5: std::result::Result<MaybeFields, _> = ron::from_str(
"#![enable(implicit_some)]\n(f1: 1, f2: 2, f3: Some(Some(3)))"
);
let x6: std::result::Result<MaybeFields, _> = ron::from_str(
"#![enable(implicit_some)]\n(f1: 1, f2: 2, f3: Some(None))"
);
println!("{:?}", &x1);
println!("{:?}", &x2);
println!("{:?}", &x3);
println!("{:?}", &x4);
println!("{:?}", &x5);
println!("{:?}", &x6);
}
Gives
Ok(MaybeFields { f1: 1, f2: None, f3: None })
Ok(MaybeFields { f1: 1, f2: None, f3: None })
Ok(MaybeFields { f1: 1, f2: Some(2), f3: Some(Some(3)) })
Err(Error { code: ExpectedInteger, position: Position { line: 2, col: 20 } })
Err(Error { code: ExpectedInteger, position: Position { line: 2, col: 20 } })
Err(Error { code: ExpectedInteger, position: Position { line: 2, col: 20 } })
I expected None and Some to work the same way, but it seems that having this implicit_some turned on disallows you to write Some altogether. This means that you can't express {f2: Some(None)} with this extension.
Now actually I'm writing an implementation of RON in another language, and it seems to me now that with this extension some things just become unexpressible. This is fine, but I just need to be certain that this current behaviour is what's expected and not a bug in the implementation. If it is, can you please document it?
The description of this extension is kind of casual, so I went to test it:
Gives
I expected
NoneandSometo work the same way, but it seems that having this implicit_some turned on disallows you to writeSomealtogether. This means that you can't express{f2: Some(None)}with this extension.Now actually I'm writing an implementation of RON in another language, and it seems to me now that with this extension some things just become unexpressible. This is fine, but I just need to be certain that this current behaviour is what's expected and not a bug in the implementation. If it is, can you please document it?