Fix code in WASI-tutorial.md
This commit is contained in:
@@ -121,14 +121,14 @@ use std::io::{Read, Write};
|
|||||||
|
|
||||||
fn process(input_fname: &str, output_fname: &str) -> Result<(), String> {
|
fn process(input_fname: &str, output_fname: &str) -> Result<(), String> {
|
||||||
let mut input_file =
|
let mut input_file =
|
||||||
fs::File::open(input_fname).map_err(|err| format!("error opening input: {}", err))?;
|
fs::File::open(input_fname).map_err(|err| format!("error opening input {}: {}", input_fname, err))?;
|
||||||
let mut contents = Vec::new();
|
let mut contents = Vec::new();
|
||||||
input_file
|
input_file
|
||||||
.read_to_end(&mut contents)
|
.read_to_end(&mut contents)
|
||||||
.map_err(|err| format!("read error: {}", err))?;
|
.map_err(|err| format!("read error: {}", err))?;
|
||||||
|
|
||||||
let mut output_file = fs::File::create(output_fname)
|
let mut output_file = fs::File::create(output_fname)
|
||||||
.map_err(|err| format!("error opening output '{}': {}", output_fname, err))?;
|
.map_err(|err| format!("error opening output {}: {}", output_fname, err))?;
|
||||||
output_file
|
output_file
|
||||||
.write_all(&contents)
|
.write_all(&contents)
|
||||||
.map_err(|err| format!("write error: {}", err))
|
.map_err(|err| format!("write error: {}", err))
|
||||||
@@ -139,7 +139,7 @@ fn main() {
|
|||||||
let program = args[0].clone();
|
let program = args[0].clone();
|
||||||
|
|
||||||
if args.len() < 3 {
|
if args.len() < 3 {
|
||||||
eprintln!("{} <input_file> <output_file>", program);
|
eprintln!("usage: {} <input_file> <output_file>", program);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user