Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- trait MyTrait {
- fn my_fnc(&self);
- }
- struct Service {
- x: String
- }
- impl Drop for Service {
- fn drop(&mut self) {
- println!("Drop service");
- }
- }
- struct Iface<'a> {
- service: &'a Service,
- }
- impl<'a> MyTrait for Iface<'a> {
- fn my_fnc(&self) {
- println!("my_fnc");
- }
- }
- fn main() {
- let service = Service{x: "".to_string()};
- let iface = Iface{service: &service};
- launch_thread(iface);
- println!("End main");
- }
- fn launch_thread<'a>(iface: Iface<'a>) {
- std::thread::spawn(move || iface.my_fnc());
- }
Add Comment
Please, Sign In to add comment