lifetime
The static bound on unscoped threads
A static type bound excludes borrowed data that cannot live long enough. It does not mean that owned values must survive for the entire program. A worker can consume and drop an owned String normally. Expected stdout (not executed): owned Common mistake: Trying to satisfy the bound by leaking every allocated value.
Formal Syntax & Structure
rust syntaxrust
T: Send + 'staticWorking Example
Example Snippetrust
fn main() { fn worker<T: Send + 'static>(value: T) -> T { std::thread::spawn(move || value).join().unwrap() } println!("{}", worker(String::from("owned")));}