我正在尝试将rust-chrono包中的DateTime用于我的自定义trait。
#[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)]
当我查看 chrono 的 Github 仓库 时,发现已经实现了对 rustc_serialize 的支持,但作为一个功能特性。在 提交日志 中有相关记录。
cargo test -v --features rustc-serialize
我不确定如何在我的项目中实现此功能。有人可以帮我了解如何在rustc-serialize中使用chrono吗?
关于这个问题,类似的问题已经有了解答。但是我想在我的项目中使用chrono中提供的序列化支持,而不是实现一个包装器trait。