daa84 / neovim-lib

Rust library for Neovim clients
GNU Lesser General Public License v3.0
192 stars 26 forks source link

Turn on serde support for Value. #9

Closed autozimu closed 7 years ago

autozimu commented 7 years ago

Which makes conversion from/to other types much easier

Also update rmpv to latest release.

daa84 commented 7 years ago

Don't understand why serde support make conversion much easier? Currently i use Value::as_* functions, and trait From. Thanks

autozimu commented 7 years ago

WIth with-serde turned on, one can have

#[Deserialize, Serialize]
struct MyStruct {
    foo: String,
    bar: i64,
}

let v = Value;
let s: MyStruct = rmpv::ext::deserialize_from(v).unwrap();

From this point, one can just use s instead of matching and casting.

daa84 commented 7 years ago

Looks cool, thanks 👍