ebarnard / rust-plist

A rusty plist parser.
MIT License
71 stars 42 forks source link

Deserialising a boolean to a serde_yaml::Value not working #75

Closed gibfahn closed 2 years ago

gibfahn commented 2 years ago

See reproduction here: https://github.com/gibfahn/plist_repro

Basically this code was working when I built it on top of https://github.com/ebarnard/rust-plist/pull/70.

fn main() {
    let test_value: plist::Value = serde_yaml::from_str("true").unwrap();

    // Should print:
    //   Value: Boolean(true)
    println!("Value: {:?}", test_value);
}

However when I tried the 1.3.0 release, I get the following error:

❯ c r
    Finished dev [unoptimized + debuginfo] target(s) in 0.01s
     Running `target/debug/plist_repro`
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Message("invalid type: newtype struct, expected any supported plist value", None)', src/main.rs:2:65
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Looks like this behaviour started working in https://github.com/ebarnard/rust-plist/pull/70, and then stopped working again in https://github.com/ebarnard/rust-plist/commit/6ee1be24d8e72cb229dfe56e777f422cd4c2977c. I'm not sure if this is expected to work, or if I was relying on buggy behaviour, but as far as I can tell this is the recommended way in serde to decode e.g. a yaml file into a plist::Value.

Full matrix:

Version Works?
1.2.1
f518ab0c00f0a1d8b3ac9ee40eace4dc5484857c
6ee1be24d8e72cb229dfe56e777f422cd4c2977c
1.3.0
ebarnard commented 2 years ago

It's a bug. Does 7609f6b3cd62b0723289773a65481e3685db755d fix your actual usecase?

gibfahn commented 2 years ago

Yep, that works great, thanks!

ebarnard commented 2 years ago

Released in v1.3.1.

gibfahn commented 2 years ago

Confirmed working, thanks for this excellent crate @ebarnard !