trait

Send: transfer a value between threads

Send is a safety property of a type that permits ownership transfer across threads. It is normally inferred from fields. Rc is not Send because its shared reference counts are not atomic; do not write an unsafe implementation merely to bypass a diagnostic. Expected stdout (not executed): transfer Common mistake: Assuming a move closure makes every captured type Send.

Formal Syntax & Structure

rust syntaxrust
pub unsafe auto trait Send {}

Working Example

Example Snippetrust
fn main() {    fn require_send<T: Send>(_: &T) {}    let value = String::from("transfer");    require_send(&value);    println!("{}", std::thread::spawn(move || value).join().unwrap());}
Rust Reference