rust-lang-nursery / rust-cookbook

https://rust-lang-nursery.github.io/rust-cookbook
Creative Commons Zero v1.0 Universal
2.24k stars 286 forks source link

redundant code from partial download example in chapter 19.4.3? #649

Open jsomedon opened 2 years ago

jsomedon commented 2 years ago

In the code example I see these two lines in the end:

  let content = response.text()?;
  std::io::copy(&mut content.as_bytes(), &mut output_file)?;

Looks like the first line is getting text from response of previous .head() call -- that should be empty string? Then the second line turns that text into bytes then appends to the output_file -- output_file should already contain content of the file to be downloaded, that's done by the for loop above these two lines. So I wonder if these lines are necessary, or am I missing something here?