本文介绍了如何修复 Encodable/Decodable 弃用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一些存储库(例如 https://github.com/sebcrozet/nalgebra)有错误

A few repos (e.g. https://github.com/sebcrozet/nalgebra) have errors along the lines of

warning: deriving(Decodable) is deprecated in favor of deriving(RustcDecodable).

RustcDecodable 替换 Decodable 原因

error: attempt to bound type parameter with a nonexistent trait `rustc_serialize::Decoder`

如何更新这些内容?

推荐答案

我相信你的错误来自 这个提交:

I believe that your error comes from this commit:

此提交完成了 in-tree 的弃用故事序列化库.编译器现在会在任何时候发出警告它遇到 deriving(Encodable)deriving(Decodable),并且库本身现在标记为 #[unstable] 用于当功能暂存时已启用.

所有序列化用户都可以迁移到 rustc-serialize crate在 crates.io 上,它提供了与libserialize 库内树.新的派生模式被命名为RustcEncodableRustcDecodable 并且需要 extern crate"rustc-serialize" 作为 rustc_serialize 在 crate 根,以便正确展开.

All users of serialization can migrate to the rustc-serialize crate on crates.io which provides the exact same interface as the libserialize library in-tree. The new deriving modes are named RustcEncodable and RustcDecodable and require extern crate "rustc-serialize" as rustc_serialize at the crate root in order to expand correctly.

要迁移所有 crate,请将以下内容添加到您的 Cargo.toml:

To migrate all crates, add the following to your Cargo.toml:

[dependencies]
rustc-serialize = "0.1.1"

然后将以下内容添加到您的 crate 根目录中:

And then add the following to your crate root:

extern crate "rustc-serialize" as rustc_serialize;

最后,将 EncodableDecodable 派生模式重命名为RustcEncodableRustcDecodable.

Finally, rename Encodable and Decodable deriving modes to RustcEncodable and RustcDecodable.

这篇关于如何修复 Encodable/Decodable 弃用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-17 17:11