1 use async_stream::stream; 2 use futures_util::StreamExt; 3 4 use std::pin::pin; 5 6 #[tokio::main] main()7async fn main() { 8 let mut outer = vec![]; 9 { 10 let v = vec![0; 10]; 11 let v_ref = &v; 12 let mut s = pin!(stream! { 13 for x in v_ref { 14 yield x 15 } 16 }); 17 while let Some(x) = s.next().await { 18 outer.push(x); 19 } 20 }; 21 // use-after-free 22 println!("{outer:?}"); // […garbage allocator internals…, 0, 0, 0] 23 } 24