-
Notifications
You must be signed in to change notification settings - Fork 118
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
Ability to configure Deserializer
to enable extensions when parsing
#281
Comments
That seems plausible. |
I'd like this feature if #319 comes! Just exposing impl<'de> Deserializer<'de> {
pub fn exts(&self) -> &Extensions {
&self.bytes.exts
}
pub fn exts_mut(&mut self) -> &mut Extensions {
&mut self.bytes.exts
}
} |
I do understand why this is needed, but at the same time I don't like that, with this implemented, RON files can't be read by themselves; you need to know what extensions they are parsed with. |
We have 2 models here: the original typed model, where you need to know the types being deserialized, and the value model, where RON is read opaquely. Having this feature seems to be in line with the typed model, but will block the value model. |
Maybe files that rely on some extensions by default should just be named differently as a convention? like |
I've been thinking about this issue a lot and my own conclusion is: What are RON extensions?RON extensions, right now, are deserialization options that are configured together with the deserialized data (in the .ron file). They do not influence parsing of RON - the syntax always stays the same. ConsiderationsKnowing a Rust type, one might have certain expectations about how to write correct RON for it. However, that's not all there is to it: What RON is correct and what isn't is completely controlled by what deserialization code serde comes up with. If I were to use a different deserialization library I might have to write different RON for it (e.g. it might not accept a RON tuple when a fixed-size array is expected). Now that means that we have two options to control deserialization:
As it turns out, there are many options in
|
This is now (#343) possible with |
Problem: I want
#![enable(unwrap_newtypes, implicit_some)]
to be the default, and don't want my users to require to write it in every RON file.Current workaround: Inject that line before parsing. It's suboptimal because I can't use
BufReader
and if there's a parsing error, the reported line number will be wrong from the user's POV.Proposed Solution: Ability to configure
Deserializer
to enable extensions before parsing.The text was updated successfully, but these errors were encountered: