Json chrono crate 的序列化功能

Json Serialization feature of chrono crate

我正在尝试将 rust-chrono crate 中的 DateTime 用于我自己的特征。

#[derive(Debug, RustcEncodable, RustcDecodable)]
pub struct Accomplishment {
  name: String,
  accomplishment_type: String,
  date: DateTime<UTC>
}

当我尝试编译它时,它会抱怨

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)]

当我检查 github repo of chrono it had the rustc_serialize support implemented. But it is as a feature. In commit log 时它有

cargo test -v --features rustc-serialize

我不确定如何为我的项目提供此功能。有人可以帮助我了解如何将 chrono 与 rustc-serialize 结合使用吗?

有一个关于此的 。但是我想要的是在我的项目中使用 chrono 中可用的序列化支持而不实现包装器特征。

将功能添加到 Cargo.toml

中的依赖项
[dependencies.chrono]
version = "*"
features = ["rustc-serialize"]

可以找到相关文档here