我介绍了error-chain
到以前工作的应用程序中。错误本身很清楚,std::error::Error + 'static
缺乏实施trait std::marker::Send
:
error[E0277]: the trait bound `std::error::Error + 'static: std::marker::Send` is not satisfied
--> src/main.rs:35:5
|
35 | / error_chain!{
36 | |
37 | | foreign_links {
38 | | Mqttc(::mqttc::Error);
... |
53 | | }
54 | | }
| |_____^ `std::error::Error + 'static` cannot be sent between threads safely
|
= help: the trait `std::marker::Send` is not implemented for `std::error::Error + 'static`
= note: required because of the requirements on the impl of `std::marker::Send` for `std::ptr::Unique<std::error::Error + 'static>`
= note: required because it appears within the type `std::boxed::Box<std::error::Error + 'static>`
= note: required because it appears within the type `mqttc::netopt::Error`
= note: required because it appears within the type `mqttc::Error`
= note: required because it appears within the type `errors::ErrorKind`
= note: required because it appears within the type `errors::Error`
= note: required by `error_chain::ChainedError`
= note: this error originates in a macro outside of the current crate
我不知道如何解决这个问题。请注意,我使用的更多最新的分叉mqttc/mqtt3 https://github.com/amikhalev/rust-mq而不是上游的板条箱。
mqttc::Error
包含一个mqttc::netopt::Error
,其中又包含一个Box<std::error::Error>
(脱糖到std::boxed::Box<std::error::Error + 'static>
. std::error::Error
这是一个特征对象。因为Error
特质没有Send
作为一个超级特征,实现Error
不需要实施Send
。所以,Box<std::error::Error>
不执行Send
因为不是所有类型T: std::error::Error
实施Send
.
这可以通过更改来解决mqttc::netopt::Error
要使用的类型Box<std::error::Error + Send>
代替Box<std::error::Error>
(这对图书馆来说是一个重大改变)。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)