>>931
こういうこと?これもエラーになる。

use std::{thread, time::Duration};

fn main() {
let v = vec![Box::new(1), Box::new(2)];
thread::spawn(|| sub(&v[1]));
drop(v);
}

fn sub(ptr: &i32) {
thread::sleep(Duration::from_secs(100000));
println!("{ptr}");
}

https://play.rust-lang.org/?version=stable&;mode=debug&edition=2021&gist=d90b955b8539696c776b1d44b0e8c5a9


ちなみにこれはコンパイルが通る
https://play.rust-lang.org/?version=stable&;mode=debug&edition=2021&gist=38157f3760d2ce9dde7d9d22c74195ad

これは通らない
https://play.rust-lang.org/?version=stable&;mode=debug&edition=2021&gist=38157f3760d2ce9dde7d9d22c74195ad