let mut out = String::new();
- if let Ok(ref orig) = orig {
- if let Some(first_line) = orig.lines().into_iter().next() {
- if first_line.starts_with("#") {
- out.push_str(first_line);
- out.push_str("\n");
- }
+ if let Ok(orig) = &orig {
+ for line in orig.lines().take_while(|line| line.starts_with("#")) {
+ out.push_str(line);
+ out.push_str("\n");
}
}
let mut lockfile = p.read_file("Cargo.lock");
lockfile.insert_str(0, "# @generated\n");
+ lockfile.insert_str(0, "# some other comment\n");
println!("saving Cargo.lock contents:\n{}", lockfile);
p.change_file("Cargo.lock", &lockfile);