by Xirdus · 1w ago · 0 comments
use std::thread;
fn main() {
let v = vec![1, 2, 3];
let handle = thread::spawn(|| {
println!("{:?}", v); // borrows `v`
});
handle.join().unwrap();
}
If lifetimes could have upper bounds then this would work.Would upper bounds prevent falling apart if you did something very questionable with cyclical Rc's? If so, how so? What kind of code would compiler REJECT that it wouldn't today?
I don’t understand the second paragraph. “Questionable” is vague, lots of things are questionable. The last sentence I don’t understand.
I’m illustrating a limitation of the compiler and of Rust as it exists today, not some pre-1.0 version, and I’m not comparing it to some complete alternative compiler without that limitation. The sample code above is an illustration of the limitation only.