Passing two objects, where one holds a reference to another, into a thread
问题 I have two objects where the second one requires the fist one to outlive it because it holds a reference to the first one. I need to move both of them into a thread, but the compiler is complaining that the first one doesn't live long enough. Here is the code: use std::thread; trait Facade: Sync { fn add(&self) -> u32; } struct RoutingNode<'a> { facade: &'a (Facade + 'a), } impl<'a> RoutingNode<'a> { fn new(facade: &'a Facade) -> RoutingNode<'a> { RoutingNode { facade: facade } } } fn main()