mock_derive cannot mock traits that are Send. Example:
fn send() {
#[mock]
pub trait A {
fn foo(&self);
}
let mock = MockA::new();
let _ = Box::new(mock) as Box<A + Send>;
}
Gives this error:
error[E0277]: `(dyn std::ops::FnMut() + 'static)` cannot be sent between threads safely
--> src/t_mock_derive.rs:251:17
|
251 | let _ = Box::new(mock) as Box<A + Send>;
| ^^^^^^^^^^^^^^ `(dyn std::ops::FnMut() + 'static)` cannot be sent between threads safely
|
= help: the trait `std::marker::Send` is not implemented for `(dyn std::ops::FnMut() + 'static)`
= note: required because of the requirements on the impl of `std::marker::Send` for `std::ptr::Unique<(dyn std::ops::FnMut() + 'static)>`
= note: required because it appears within the type `std::boxed::Box<(dyn std::ops::FnMut() + 'static)>`
= note: required because it appears within the type `std::option::Option<std::boxed::Box<(dyn std::ops::FnMut() + 'static)>>`
= note: required because of the requirements on the impl of `std::marker::Send` for `std::sync::Mutex<std::option::Option<std::boxed::Box<(dyn std::ops::FnMut() + 'static)>>>`
= note: required because it appears within the type `<t_mock_derive::t::MockDerive as TestSuite>::send::MockMethodForA<()>`
= note: required because it appears within the type `std::option::Option<<t_mock_derive::t::MockDerive as TestSuite>::send::MockMethodForA<()>>`
= note: required because it appears within the type `<t_mock_derive::t::MockDerive as TestSuite>::send::MockA`
= note: required for the cast to the object type `dyn <t_mock_derive::t::MockDerive as TestSuite>::send::A + std::marker::Send`
mock_derive cannot mock traits that are
Send. Example:Gives this error: