You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#[macro_use]externcrate sd;externcrate sj;#[derive(Serialize,Deserialize,Debug)]structPoint{x:i32,y:i32,}fnmain(){let point = Point{x:1,y:2};// Convert the Point to a JSON string.let serialized = sj::to_string(&point).unwrap();// Prints serialized = {"x":1,"y":2}println!("serialized = {}", serialized);// Convert the JSON string back to a Point.let deserialized:Point = sj::from_str(&serialized).unwrap();// Prints deserialized = Point { x: 1, y: 2 }println!("deserialized = {:?}", deserialized);}
Output of cargo run:
Compiling demo v0.1.0 (file:///private/tmp/demo)
error[E0463]: can't find crate for `_serde`
--> src/main.rs:5:21
|
5 | #[derive(Serialize, Deserialize, Debug)]
| ^^^^^^^^^^^ can't find crate
error: aborting due to previous error
For more information about this error, try `rustc --explain E0463`.
error: Could not compile `demo`.
To learn more, run the command again with --verbose.
I imagine supporting this will require new features to be added to Rust's procedural macros.
Currently serde_derive requires that you list serde in Cargo.toml as well (see https://serde.rs/derive.html) which is missing in yours. So the failure you see is from there being no serde in Cargo.toml, not directly because of the serde_derive or serde_json rename.
In the case that serde really needs to be renamed, I would prefer to track this under #953. Thanks!
Crates can now be renamed in the dependencies section. Attempting to do this with the current version of serde fails. Example:
Cargo.toml:
src/main.rs:
Output of
cargo run
:I imagine supporting this will require new features to be added to Rust's procedural macros.
Cargo and Rust versions:
The text was updated successfully, but these errors were encountered: