Closed
Description
Currently, only the explicit unsafe impl
s of Send
and Sync
(and their !
counterparts) are shown in the docs. This makes me write a test code that actually sends some value across thread boundaries. For example, to find out whether Core
from tokio-core
is Send
, I should test it:
extern crate tokio_core;
extern crate futures;
fn main() {
let core = tokio_core::reactor::Core::new().unwrap();
std::thread::spawn(move || {
let mut xcore = core;
xcore.run(futures::future::ok::<usize, usize>(0)).unwrap();
}).join().unwrap();
}
Then it turns out that Core
does not implement Send
. (And it's hard to get the point quickly.)
error[E0277]: the trait bound `std::rc::Rc<std::cell::RefCell<tokio_core::reactor::Inner>>: std::marker::Send` is not satisfied in `[closure@src/main.rs:6:24: 9:6 core:tokio_core::reactor::Core]`
--> src/main.rs:6:5
|
6 | std::thread::spawn(move || {
| ^^^^^^^^^^^^^^^^^^ `std::rc::Rc<std::cell::RefCell<tokio_core::reactor::Inner>>` cannot be sent between threads safely
|
= help: within `[closure@src/main.rs:6:24: 9:6 core:tokio_core::reactor::Core]`, the trait `std::marker::Send` is not implemented for `std::rc::Rc<std::cell::RefCell<tokio_core::reactor::Inner>>`
= note: required because it appears within the type `tokio_core::reactor::Core`
= note: required because it appears within the type `[closure@src/main.rs:6:24: 9:6 core:tokio_core::reactor::Core]`
= note: required by `std::thread::spawn`
Of course, we normally don't send Core
across thread boundaries, but this is just an example. I often encounter this kind of question when using a crate for the first time. I want rustdoc to automatically generate whether a type implements Send
or Sync
. Maybe the information is in the section other than "Trait Implementations."
Metadata
Metadata
Assignees
Labels
No labels