I understand serde is the preferred serialization tool in Rust world. However, it seems to be using features that are not there in stable channel. Does that mean I can't use serde while using Rust stable release? Am I missing something? For example:
#![feature(proc_macro)]
#[macro_use]
extern crate serde_derive;
extern crate serde_json;
#[derive(Serialize, Deserialize, Debug)]
struct Point {
x: i32,
y: i32,
}
The unstable features used are only needed for the #[derive] support. So if you don't need to define serialization or deserialization for new data types, using serde with stable Rust is easy.
If you do need to define serialization for new types, you can implement the traits manually (which isn't necessarily easy), which is still possible using stable Rust.
The serde documentation also covers how to do this.
Ker's comment deserves to be an answer.
right now you still need to use a build script: https://serde.rs/codegen-stable.html
But in addition, we're looking to stabilize the stuff necessary to have Serde work without build scripts in Rust 1.15. That's not guaranteed yet, but it's very likely.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With