You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, only the explicit unsafe impls 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:
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."
The text was updated successfully, but these errors were encountered:
tirr-c
changed the title
Hard to find out whether a type is Send or Sync in the docs
Hard to find out whether a type is Send or Sync
Sep 6, 2017
Currently, only the explicit unsafe
impl
s ofSend
andSync
(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 whetherCore
fromtokio-core
isSend
, I should test it:Then it turns out that
Core
does not implementSend
. (And it's hard to get the point quickly.)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 implementsSend
orSync
. Maybe the information is in the section other than "Trait Implementations."The text was updated successfully, but these errors were encountered: