8000 Ron does not properly round trip through Value · Issue #121 · ron-rs/ron · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Ron does not properly round trip through Value #121
@jrmuizel

Description

@jrmuizel
#[macro_use]
extern crate serde;

extern crate ron;
use ron::de::*;
use ron::ser;
use ron::value::Value;

#[derive(Serialize)]
struct Scene(Option<(u32, u32)>);

#[derive(Serialize)]
struct Scene2 {
    foo: Option<(u32, u32)>,
}

fn main() {
    {
        let s = ser::to_string(&Scene2 { foo: Some((1, 1)) }).unwrap();
        println!("{}", s);
        let scene: Value = from_str(&s).unwrap();
        println!("{:?}", scene);
    }
    {
        let s = ser::to_string(&Scene( Some((1, 1)) )).unwrap();
        println!("{}", s);
        let scene: Value = from_str(&s).unwrap();
        println!("{:?}", scene);
    }
}

The first example gives:

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Parser(ExpectedIdentifier, Position { col: 12, line: 1 })', libcore/result.rs:945:5

The second gives:

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Parser(ExpectedMapColon, Position { col: 6, line: 1 })', libcore/result.rs:945:5

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0