Open
Description
const S: String = String::new();
fn main() {
let v = vec![[S, "Hello World!".into()], [S, S]];
let mut i = v.into_iter().flatten();
let _ = i.next();
let result: Vec<String> = i.clone().collect();
println!("{result:?}");
}
["\0\0\0\0\0\0\0\0rld!", "\0\0\0\0\0\0\0\0rld!", ""]
free(): invalid pointer
[1] 1131073 IOT instruction (core dumped)
The above code is analogous to #85322 but applied to Flatten
instead of Peekable
: cloning the whole iterator doesn't preserve capacity in the inner vec::IntoIter
. (This also applies to FlatMap
.)
Introduced in 1.76
@rustbot label T-libs, I-unsound, A-iterators