serde-rs / serde-rs.github.io

https://serde.rs
Creative Commons Attribution Share Alike 4.0 International
22 stars 96 forks source link

Add the new deser_hjson deserializer for Hjson #121

Closed Canop closed 3 years ago

Canop commented 3 years ago

Another crate, hjson-rust was listed in the past for Hjson but hadn't been made compatible with serde 1.0 and isn't compatible with derive based operations.

This new crate, deser-hjson is explicitly geared at derive based deserialization.

Canop commented 3 years ago

You're right, it's almost never possible to borrow any part from the initial string as escaping can occur everywhere.

I made a new version 1.1.10 with DeserializeOwned.

dtolnay commented 3 years ago

Note that that change would have been a breaking change. Previously correct working code like the following would be broken by your 0.1.10 release.

fn f<'de, T: serde::Deserialize<'de> + std::fmt::Display>() {
    println!("{}", deser_hjson::from_str::<T>("1 ").unwrap());
}

fn main() {
    f::<i32>();
}
Canop commented 3 years ago

Thanks for the note. Now that it's "official" and might be used more largely, I'll be serious with breaking changes and I'll make a changelog for the next versions.