I'm trying to use DateTime from rust-chrono crate to my own trait.
#[derive(Debug, RustcEncodable, RustcDecodable)]
pub struct Accomplishment {
name: String,
accomplishment_type: String,
date: DateTime<UTC>
}
When I try to compile this it complains that
src/lib.rs:11:33: 11:47 error: the trait `rustc_serialize::serialize::Decodable` is not implemented for the type `chrono::datetime::DateTime<chrono::offset::utc::UTC>` [E0277]
src/lib.rs:11 #[derive(Debug, RustcEncodable, RustcDecodable)]
When I checked the github repo of chrono it had the rustc_serialize support implemented. But it is as a feature. In commit log it has
cargo test -v --features rustc-serialize
I'm not sure how to have this feature for my project. Can someone help me on how to use chrono with rustc-serialize?
There is a similar question regarding this. But what I wanted is to use the serialization support available in chrono in my project without implementing a wrapper trait.
Add the feature to your dependency in the Cargo.toml
[dependencies.chrono]
version = "*"
features = ["rustc-serialize"]
The relevant Documentation can be found here
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