How to tell the borrow checker that a cleared Vec contains no borrows? [duplicate]
问题 This question already has answers here : Borrow checker doesn't realize that `clear` drops reference to local variable (6 answers) Closed 22 days ago . I'm processing a massive TSV (tab separated values) file and want to do this as efficiently as possible. To that end, I thought I'd prevent allocation of a new Vec for every line by pre-allocating it before the loop: let mut line = String::new(); let mut fields = Vec::with_capacity(headers.len()); while reader.read_line(&mut line)? > 0 {