From d370b05aa2c9eae42782e1fbf6cec59b1e62eb5f Mon Sep 17 00:00:00 2001 From: Tanish-Eagle Date: Tue, 9 Aug 2022 18:21:21 +0530 Subject: [PATCH] Fixed some grammar mistakes --- en/src/result-panic/result.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/en/src/result-panic/result.md b/en/src/result-panic/result.md index 064277b..37abc34 100644 --- a/en/src/result-panic/result.md +++ b/en/src/result-panic/result.md @@ -1,7 +1,7 @@ # result and ? `Result` is an enum to describe possible errors. It has two variants: -- `Ok(T)`: a value T was found +- `Ok(T)`: A value T was found - `Err(e)`: An error was found with a value `e` In short words, the expected outcome is `Ok`, while the unexpected outcome is `Err`. @@ -25,7 +25,7 @@ fn main() { let result = multiply("t", "2"); assert_eq!(result.__, 8); - println!("Success!") + println!("Success!"); } ``` @@ -44,7 +44,7 @@ fn multiply(n1_str: &str, n2_str: &str) -> __ { fn main() { assert_eq!(multiply("3", "4").unwrap(), 12); - println!("Success!") + println!("Success!"); } ``` @@ -69,7 +69,7 @@ fn read_file1() -> Result { } // FILL in the blanks with one code line -// DON'T change any code else +// DON'T change any code lines fn read_file2() -> Result { let mut s = String::new(); @@ -80,7 +80,7 @@ fn read_file2() -> Result { fn main() { assert_eq!(read_file1().unwrap_err().to_string(), read_file2().unwrap_err().to_string()); - println!("Success!") + println!("Success!"); } ``` @@ -100,7 +100,7 @@ fn add_two(n_str: &str) -> Result { fn main() { assert_eq!(add_two("4").unwrap(), 6); - println!("Success!") + println!("Success!"); } ``` @@ -109,7 +109,7 @@ fn main() { use std::num::ParseIntError; // With the return type rewritten, we use pattern matching without `unwrap()`. -// But it's so Verbose.. +// But it's so Verbose... fn multiply(n1_str: &str, n2_str: &str) -> Result { match n1_str.parse::() { Ok(n1) => { @@ -146,14 +146,14 @@ fn main() { let tt = multiply("t", "2"); print(tt); - println!("Success!") + println!("Success!"); } ``` ### Type alias Using `std::result::Result` everywhere is verbose and tedious, we can use alias for this purpose. -At a module level, creating aliases can be particularly helpful. Errors found in the a specific module often has the same `Err` type, so a single alias can succinctly defined all associated `Results`. This is so useful even the `std` library even supplies one: [`io::Result`](https://doc.rust-lang.org/std/io/type.Result.html). +At a module level, creating aliases can be particularly helpful. Errors found in a specific module often has the same `Err` type, so a single alias can succinctly defined all associated `Results`. This is so useful even the `std` library even supplies one: [`io::Result`](https://doc.rust-lang.org/std/io/type.Result.html). 6. 🌟 ```rust,editable @@ -181,7 +181,7 @@ fn main() { print(multiply("10", "2")); print(multiply("t", "2")); - println!("Success!") + println!("Success!"); } ```