Update for Rust 1.0
In Rust 1.0 and later, the code in the example (when uint replaced with some existing type) does not execute with another error:
% rustc test.rs test.rs:23:9: 23:13 error: the trait `core::marker::Sync` is not implemented for the type `core::cell::UnsafeCell<usize>` [E0277] test.rs:23 func(&r7) ^~~~ test.rs:23:9: 23:13 help: run `rustc --explain E0277` to see a detailed explanation test.rs:23:9: 23:13 note: `core::cell::UnsafeCell<usize>` cannot be shared between threads safely test.rs:23:9: 23:13 note: required because it appears within the type `core::cell::Cell<usize>` test.rs:23:9: 23:13 note: required because it appears within the type `core::cell::BorrowRef<'_>` test.rs:23:9: 23:13 note: required because it appears within the type `core::cell::Ref<'_, i32>` test.rs:23:9: 23:13 note: required by `func`
This is a kind of complexity - another feature, Sync , came out of nowhere.
A type that implements Send trait (although its documentation is certainly not available at the moment) is something that can be passed across task boundaries. Most types of Send , but some, like Rc and Weak , are not Send , because there are instances of such types can share unsynchronized mutable state and therefore it is unsafe to use from multiple threads.
Earlier versions of Rust Send meant 'static , so the links were not Send . However, since Rust 1.0, Send no longer implies 'static , so links can be sent in streams. However, for &T be Send , T must be Sync : this is required in the next implementation
impl<'a, T> Send for &'a T where T: Sync + ?Sized
But in our case, we donโt require that &T be Send , we require that T be Send , so that doesnโt matter much, right?
Not. In fact, there are still links, even we do not see them immediately. Remember that for the Send type, each of its components must be Send , that is, each structure field and each part of each enumerated enumeration enumeration must be Send for this structure / enumeration as Send . core::cell::Ref internally contains an instance of struct BorrowRef , which in turn contains a reference to Cell<BorrowFlag> . And this is where Sync comes from: in order, or &Cell<BorrowFlag> to Send , Cell<BorrowFlag> should be Sync ; however, it is not and cannot be Sync , since it provides unsynchronized internal variability. This is the actual cause of the error.