mirror of
https://github.com/rust-lang-nursery/rust-cookbook
synced 2025-02-16 12:18:27 +00:00
download example using bytes instead of text
This commit is contained in:
parent
752b035c1a
commit
a849cd6c47
1 changed files with 3 additions and 3 deletions
|
@ -11,8 +11,8 @@ The temporary directory is automatically removed on program exit.
|
|||
|
||||
```rust,edition2018,no_run
|
||||
use error_chain::error_chain;
|
||||
use std::io::copy;
|
||||
use std::fs::File;
|
||||
use std::io::Write;
|
||||
use tempfile::Builder;
|
||||
|
||||
error_chain! {
|
||||
|
@ -41,8 +41,8 @@ async fn main() -> Result<()> {
|
|||
println!("will be located under: '{:?}'", fname);
|
||||
File::create(fname)?
|
||||
};
|
||||
let content = response.text().await?;
|
||||
copy(&mut content.as_bytes(), &mut dest)?;
|
||||
let content = response.bytes().await?;
|
||||
dest.write(&content)?;
|
||||
Ok(())
|
||||
}
|
||||
```
|
||||
|
|
Loading…
Add table
Reference in a new issue