use error handler shortcut
This commit is contained in:
parent
fcd70e2c4e
commit
2d5ac33cf9
1 changed files with 1 additions and 5 deletions
|
@ -7,11 +7,7 @@ struct Cli {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let result = std::fs::read_to_string("test.txt");
|
let content = std::fs::read_to_string("test.txt")?;
|
||||||
let content = match result {
|
|
||||||
Ok(content) => { content },
|
|
||||||
Err(error) => { return Err(error.into()); },
|
|
||||||
};
|
|
||||||
println!("file content: {}", content);
|
println!("file content: {}", content);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue