Skip to content
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

Implement deserialize_any #48

Closed
dtolnay opened this issue Aug 10, 2017 · 3 comments
Closed

Implement deserialize_any #48

dtolnay opened this issue Aug 10, 2017 · 3 comments

Comments

@dtolnay
Copy link

dtolnay commented Aug 10, 2017

It looks like RON is self-describing. It should be able to tell what type is in the data without relying on a Deserializer hint.

#[macro_use]
extern crate serde_derive;

extern crate ron;

#[derive(Deserialize, Debug)]
#[serde(untagged)]
enum Untagged {
    U8(u8),
    Bool(bool),
}

fn main() {
    println!("{}", ron::de::from_str::<u8>("99").unwrap());
    println!("{}", ron::de::from_str::<bool>("true").unwrap());

    // unhelpful panic :(
    ron::de::from_str::<Untagged>("true");
}
@torkleyy
Copy link
Contributor

I started implementing that, but it turned out RON is not completely self-describing: There is no way to tell if it is an enum or a struct.

@dtolnay
Copy link
Author

dtolnay commented Aug 10, 2017

That shouldn't matter. JSON certainly doesn't distinguish between those right, and it is self-describing?

@torkleyy
Copy link
Contributor

Okay, if that's the case I'll take a look at it later.

bors bot added a commit that referenced this issue Sep 11, 2017
53: Add Value and implement deserialize_any r=kvark a=torkleyy

Fixes #48
bors bot added a commit that referenced this issue Sep 21, 2017
53: Add Value and implement deserialize_any r=kvark a=torkleyy

Fixes #45
Fixes #48
@bors bors bot closed this as completed in #53 Sep 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants