diff --git a/rustbook-en/listings/ch10-generic-types-traits-and-lifetimes/listing-10-24/src/main.rs b/rustbook-en/listings/ch10-generic-types-traits-and-lifetimes/listing-10-24/src/main.rs index 2937b194c..ca3cf86d2 100644 --- a/rustbook-en/listings/ch10-generic-types-traits-and-lifetimes/listing-10-24/src/main.rs +++ b/rustbook-en/listings/ch10-generic-types-traits-and-lifetimes/listing-10-24/src/main.rs @@ -4,7 +4,7 @@ struct ImportantExcerpt<'a> { fn main() { let novel = String::from("Call me Ishmael. Some years ago..."); - let first_sentence = novel.split('.').next().expect("Could not find a '.'"); + let first_sentence = novel.split('.').next().unwrap(); let i = ImportantExcerpt { part: first_sentence, }; diff --git a/rustbook-en/listings/ch10-generic-types-traits-and-lifetimes/no-listing-10-lifetimes-on-methods/src/main.rs b/rustbook-en/listings/ch10-generic-types-traits-and-lifetimes/no-listing-10-lifetimes-on-methods/src/main.rs index b8222308d..c04ec3823 100644 --- a/rustbook-en/listings/ch10-generic-types-traits-and-lifetimes/no-listing-10-lifetimes-on-methods/src/main.rs +++ b/rustbook-en/listings/ch10-generic-types-traits-and-lifetimes/no-listing-10-lifetimes-on-methods/src/main.rs @@ -21,7 +21,7 @@ impl<'a> ImportantExcerpt<'a> { fn main() { let novel = String::from("Call me Ishmael. Some years ago..."); - let first_sentence = novel.split('.').next().expect("Could not find a '.'"); + let first_sentence = novel.split('.').next().unwrap(); let i = ImportantExcerpt { part: first_sentence, }; diff --git a/rustbook-en/packages/mdbook-trpl-listing/src/lib.rs b/rustbook-en/packages/mdbook-trpl-listing/src/lib.rs index af817ff21..59d338fe5 100644 --- a/rustbook-en/packages/mdbook-trpl-listing/src/lib.rs +++ b/rustbook-en/packages/mdbook-trpl-listing/src/lib.rs @@ -98,7 +98,7 @@ impl Preprocessor for TrplListing { } fn supports_renderer(&self, renderer: &str) -> bool { - renderer == "html" + renderer == "html" || renderer == "markdown" } } diff --git a/rustbook-en/packages/mdbook-trpl-note/src/lib.rs b/rustbook-en/packages/mdbook-trpl-note/src/lib.rs index 4b8e2fa42..1508a566e 100644 --- a/rustbook-en/packages/mdbook-trpl-note/src/lib.rs +++ b/rustbook-en/packages/mdbook-trpl-note/src/lib.rs @@ -49,7 +49,7 @@ impl Preprocessor for TrplNote { } fn supports_renderer(&self, renderer: &str) -> bool { - renderer == "html" + renderer == "html" || renderer == "markdown" } } diff --git a/rustbook-en/packages/tools/src/bin/remove_markup.rs b/rustbook-en/packages/tools/src/bin/remove_markup.rs index cda6ebaa3..6ec0fdfb9 100644 --- a/rustbook-en/packages/tools/src/bin/remove_markup.rs +++ b/rustbook-en/packages/tools/src/bin/remove_markup.rs @@ -26,7 +26,7 @@ fn remove_markup(input: String) -> String { let caption_start_regex = Regex::new(r#"\A(.*)\z"#).unwrap(); let caption_end_regex = Regex::new(r#"(.*)\z"#).unwrap(); - let regexen = vec![filename_regex, caption_start_regex, caption_end_regex]; + let regexen = [filename_regex, caption_start_regex, caption_end_regex]; let lines: Vec<_> = input .lines() diff --git a/rustbook-en/src/ch02-00-guessing-game-tutorial.md b/rustbook-en/src/ch02-00-guessing-game-tutorial.md index f80ad5208..5aebefdd9 100644 --- a/rustbook-en/src/ch02-00-guessing-game-tutorial.md +++ b/rustbook-en/src/ch02-00-guessing-game-tutorial.md @@ -682,13 +682,12 @@ in the expression refers to the original `guess` variable that contained the input as a string. The `trim` method on a `String` instance will eliminate any whitespace at the beginning and end, which we must do to be able to compare the string to the `u32`, which can only contain numerical data. The user must press -enter to satisfy `read_line` and input their -guess, which adds a newline character to the string. For example, if the user -types 5 and presses enter, `guess` looks like this: `5\n`. The `\n` -represents “newline.” (On Windows, pressing enter results in a carriage return and a newline, -`\r\n`.) The `trim` method eliminates `\n` or `\r\n`, resulting in just `5`. +enter to satisfy `read_line` and input their guess, which adds a +newline character to the string. For example, if the user types 5 and +presses enter, `guess` looks like this: `5\n`. The `\n` represents +“newline.” (On Windows, pressing enter results in a carriage return +and a newline, `\r\n`.) The `trim` method eliminates `\n` or `\r\n`, resulting +in just `5`. The [`parse` method on strings][parse] converts a string to another type. Here, we use it to convert from a string to a number. We need to @@ -762,11 +761,11 @@ and run the program again. The program will now ask for another guess forever, which actually introduces a new problem. It doesn’t seem like the user can quit! The user could always interrupt the program by using the keyboard shortcut -ctrl-c. But there’s another way to escape this -insatiable monster, as mentioned in the `parse` discussion in [“Comparing the -Guess to the Secret Number”](#comparing-the-guess-to-the-secret-number): if the user enters a non-number answer, the program will crash. We -can take advantage of that to allow the user to quit, as shown here: +ctrl-c. But there’s another way to escape this insatiable +monster, as mentioned in the `parse` discussion in [“Comparing the Guess to the +Secret Number”](#comparing-the-guess-to-the-secret-number): if +the user enters a non-number answer, the program will crash. We can take +advantage of that to allow the user to quit, as shown here: