From fc17a8a6a04076abf382cbfbe97079b51d288189 Mon Sep 17 00:00:00 2001 From: Bertram Scharpf Date: Sat, 14 Jun 2025 19:08:08 +0200 Subject: [PATCH 1/5] Trailing spaces --- src/crates/using_lib.md | 2 +- src/custom_types/enum/testcase_linked_list.md | 2 +- src/error/abort_unwind.md | 2 +- src/error/option_unwrap/and_then.md | 2 +- src/error/option_unwrap/defaults.md | 6 +++--- src/error/result/enter_question_mark.md | 2 +- src/flow_control/for.md | 4 ++-- src/flow_control/if_let.md | 6 +++--- src/flow_control/let_else.md | 4 ++-- src/flow_control/while_let.md | 2 +- src/fn/closures.md | 2 +- src/fn/closures/capture.md | 14 +++++++------- src/fn/closures/closure_examples/iter_find.md | 4 ++-- src/generics.md | 2 +- src/generics/assoc_items/types.md | 2 +- src/generics/bounds.md | 2 +- src/generics/gen_fn.md | 2 +- src/generics/where.md | 2 +- src/mod/super.md | 12 ++++++------ src/primitives.md | 2 +- src/scope/borrow/mut.md | 6 +++--- src/scope/borrow/ref.md | 4 ++-- src/scope/lifetime.md | 4 ++-- src/scope/lifetime/explicit.md | 12 ++++++------ src/scope/lifetime/fn.md | 4 ++-- src/scope/lifetime/lifetime_coercion.md | 4 ++-- src/scope/move.md | 2 +- src/std/box.md | 2 +- src/std/hash.md | 10 +++++----- src/std/panic.md | 8 ++++---- src/std/rc.md | 18 +++++++++--------- src/std_misc/channels.md | 2 +- src/std_misc/file/read_lines.md | 2 +- src/testing/dev_dependencies.md | 2 +- src/trait.md | 2 +- src/trait/drop.md | 4 ++-- src/trait/iter.md | 2 +- src/trait/supertraits.md | 2 +- src/variable_bindings/declare.md | 2 +- 39 files changed, 84 insertions(+), 84 deletions(-) diff --git a/src/crates/using_lib.md b/src/crates/using_lib.md index 3195f170c1..30b18125fb 100644 --- a/src/crates/using_lib.md +++ b/src/crates/using_lib.md @@ -20,7 +20,7 @@ fn main() { ```txt # Where library.rlib is the path to the compiled library, assumed that it's # in the same directory here: -$ rustc executable.rs --extern rary=library.rlib && ./executable +$ rustc executable.rs --extern rary=library.rlib && ./executable called rary's `public_function()` called rary's `indirect_access()`, that > called rary's `private_function()` diff --git a/src/custom_types/enum/testcase_linked_list.md b/src/custom_types/enum/testcase_linked_list.md index 8c41ed7c63..68ae7bd88d 100644 --- a/src/custom_types/enum/testcase_linked_list.md +++ b/src/custom_types/enum/testcase_linked_list.md @@ -33,7 +33,7 @@ impl List { // `self` has type `&List`, and `*self` has type `List`, matching on a // concrete type `T` is preferred over a match on a reference `&T` // after Rust 2018 you can use self here and tail (with no ref) below as well, - // rust will infer &s and ref tail. + // rust will infer &s and ref tail. // See https://doc.rust-lang.org/edition-guide/rust-2018/ownership-and-lifetimes/default-match-bindings.html match *self { // Can't take ownership of the tail, because `self` is borrowed; diff --git a/src/error/abort_unwind.md b/src/error/abort_unwind.md index e17856677e..0ff9a6371f 100644 --- a/src/error/abort_unwind.md +++ b/src/error/abort_unwind.md @@ -2,7 +2,7 @@ The previous section illustrates the error handling mechanism `panic`. Different code paths can be conditionally compiled based on the panic setting. The current values available are `unwind` and `abort`. -Building on the prior lemonade example, we explicitly use the panic strategy to exercise different lines of code. +Building on the prior lemonade example, we explicitly use the panic strategy to exercise different lines of code. ```rust,editable,mdbook-runnable fn drink(beverage: &str) { diff --git a/src/error/option_unwrap/and_then.md b/src/error/option_unwrap/and_then.md index 7dee272425..de370b7b2a 100644 --- a/src/error/option_unwrap/and_then.md +++ b/src/error/option_unwrap/and_then.md @@ -9,7 +9,7 @@ known in some languages as flatmap, comes in. `and_then()` calls its function input with the wrapped value and returns the result. If the `Option` is `None`, then it returns `None` instead. In the following example, `cookable_v3()` results in an `Option`. -Using `map()` instead of `and_then()` would have given an +Using `map()` instead of `and_then()` would have given an `Option>`, which is an invalid type for `eat()`. ```rust,editable diff --git a/src/error/option_unwrap/defaults.md b/src/error/option_unwrap/defaults.md index e749c1492a..3b2088e6a5 100644 --- a/src/error/option_unwrap/defaults.md +++ b/src/error/option_unwrap/defaults.md @@ -10,7 +10,7 @@ There is more than one way to unpack an `Option` and fall back on a default if i `or()`is chainable and eagerly evaluates its argument, as is shown in the following example. Note that because `or`'s arguments are evaluated eagerly, the variable passed to `or` is moved. ```rust,editable -#[derive(Debug)] +#[derive(Debug)] enum Fruit { Apple, Orange, Banana, Kiwi, Lemon } fn main() { @@ -35,7 +35,7 @@ fn main() { Another alternative is to use `or_else`, which is also chainable, and evaluates lazily, as is shown in the following example: ```rust,editable -#[derive(Debug)] +#[derive(Debug)] enum Fruit { Apple, Orange, Banana, Kiwi, Lemon } fn main() { @@ -84,7 +84,7 @@ fn main() { Instead of explicitly providing a value to fall back on, we can pass a closure to `get_or_insert_with`, as follows: ```rust,editable -#[derive(Debug)] +#[derive(Debug)] enum Fruit { Apple, Orange, Banana, Kiwi, Lemon } fn main() { diff --git a/src/error/result/enter_question_mark.md b/src/error/result/enter_question_mark.md index 2b86862b15..49d12760ea 100644 --- a/src/error/result/enter_question_mark.md +++ b/src/error/result/enter_question_mark.md @@ -44,7 +44,7 @@ at older code. The same `multiply` function from the previous example would look like this using `try!`: ```rust,editable,edition2015 -// To compile and run this example without errors, while using Cargo, change the value +// To compile and run this example without errors, while using Cargo, change the value // of the `edition` field, in the `[package]` section of the `Cargo.toml` file, to "2015". use std::num::ParseIntError; diff --git a/src/flow_control/for.md b/src/flow_control/for.md index b5d5d62721..f457529df6 100644 --- a/src/flow_control/for.md +++ b/src/flow_control/for.md @@ -71,7 +71,7 @@ fn main() { _ => println!("Hello {}", name), } } - + println!("names: {:?}", names); } ``` @@ -90,7 +90,7 @@ fn main() { _ => println!("Hello {}", name), } } - + println!("names: {:?}", names); // FIXME ^ Comment out this line } diff --git a/src/flow_control/if_let.md b/src/flow_control/if_let.md index 89367924b7..11b5683006 100644 --- a/src/flow_control/if_let.md +++ b/src/flow_control/if_let.md @@ -70,18 +70,18 @@ fn main() { let a = Foo::Bar; let b = Foo::Baz; let c = Foo::Qux(100); - + // Variable a matches Foo::Bar if let Foo::Bar = a { println!("a is foobar"); } - + // Variable b does not match Foo::Bar // So this will print nothing if let Foo::Bar = b { println!("b is foobar"); } - + // Variable c matches Foo::Qux which has a value // Similar to Some() in the previous example if let Foo::Qux(value) = c { diff --git a/src/flow_control/let_else.md b/src/flow_control/let_else.md index 2d07de740a..8413a925ad 100644 --- a/src/flow_control/let_else.md +++ b/src/flow_control/let_else.md @@ -34,7 +34,7 @@ patterns with an unfortunate bit of repetition and an outer `let`: ```rust # use std::str::FromStr; -# +# # fn get_count_item(s: &str) -> (u64, &str) { # let mut it = s.split(' '); let (count_str, item) = match (it.next(), it.next()) { @@ -48,7 +48,7 @@ patterns with an unfortunate bit of repetition and an outer `let`: }; # (count, item) # } -# +# # assert_eq!(get_count_item("3 chairs"), (3, "chairs")); ``` diff --git a/src/flow_control/while_let.md b/src/flow_control/while_let.md index f6f8eff2e0..897375a8e2 100644 --- a/src/flow_control/while_let.md +++ b/src/flow_control/while_let.md @@ -34,7 +34,7 @@ Using `while let` makes this sequence much nicer: fn main() { // Make `optional` of type `Option` let mut optional = Some(0); - + // This reads: "while `let` destructures `optional` into // `Some(i)`, evaluate the block (`{}`). Else `break`. while let Some(i) = optional { diff --git a/src/fn/closures.md b/src/fn/closures.md index 16669fb3b9..d9bdfcd999 100644 --- a/src/fn/closures.md +++ b/src/fn/closures.md @@ -21,7 +21,7 @@ Other characteristics of closures include: ```rust,editable fn main() { let outer_var = 42; - + // A regular function can't refer to variables in the enclosing environment //fn function(i: i32) -> i32 { i + outer_var } // TODO: uncomment the line above and see the compiler error. The compiler diff --git a/src/fn/closures/capture.md b/src/fn/closures/capture.md index c2f0c62acb..1c21857ae9 100644 --- a/src/fn/closures/capture.md +++ b/src/fn/closures/capture.md @@ -15,12 +15,12 @@ required. ```rust,editable fn main() { use std::mem; - + let color = String::from("green"); // A closure to print `color` which immediately borrows (`&`) `color` and // stores the borrow and closure in the `print` variable. It will remain - // borrowed until `print` is used the last time. + // borrowed until `print` is used the last time. // // `println!` only requires arguments by immutable reference so it doesn't // impose anything more restrictive. @@ -30,7 +30,7 @@ fn main() { print(); // `color` can be borrowed immutably again, because the closure only holds - // an immutable reference to `color`. + // an immutable reference to `color`. let _reborrow = &color; print(); @@ -55,15 +55,15 @@ fn main() { // The closure still mutably borrows `count` because it is called later. // An attempt to reborrow will lead to an error. - // let _reborrow = &count; + // let _reborrow = &count; // ^ TODO: try uncommenting this line. inc(); // The closure no longer needs to borrow `&mut count`. Therefore, it is // possible to reborrow without an error - let _count_reborrowed = &mut count; + let _count_reborrowed = &mut count; + - // A non-copy type. let movable = Box::new(3); @@ -100,7 +100,7 @@ fn main() { // ^ Uncommenting above line will result in compile-time error // because borrow checker doesn't allow re-using variable after it // has been moved. - + // Removing `move` from closure's signature will cause closure // to borrow _haystack_ variable immutably, hence _haystack_ is still // available and uncommenting above line will not cause an error. diff --git a/src/fn/closures/closure_examples/iter_find.md b/src/fn/closures/closure_examples/iter_find.md index 62fc57ea9e..e9803716cf 100644 --- a/src/fn/closures/closure_examples/iter_find.md +++ b/src/fn/closures/closure_examples/iter_find.md @@ -57,9 +57,9 @@ fn main() { // we have to destructure `&i32` to `i32` let index_of_first_even_number = vec.iter().position(|&x| x % 2 == 0); assert_eq!(index_of_first_even_number, Some(5)); - + // `into_iter()` for vecs yields `i32` and `position()` does not take a reference, so - // we do not have to destructure + // we do not have to destructure let index_of_first_negative_number = vec.into_iter().position(|x| x < 0); assert_eq!(index_of_first_negative_number, None); } diff --git a/src/generics.md b/src/generics.md index f0ddee859e..215d4b4eed 100644 --- a/src/generics.md +++ b/src/generics.md @@ -43,7 +43,7 @@ struct SingleGen(T); fn main() { // `Single` is concrete and explicitly takes `A`. let _s = Single(A); - + // Create a variable `_char` of type `SingleGen` // and give it the value `SingleGen('a')`. // Here, `SingleGen` has a type parameter explicitly specified. diff --git a/src/generics/assoc_items/types.md b/src/generics/assoc_items/types.md index dbf6d789b4..a5bbbfe139 100644 --- a/src/generics/assoc_items/types.md +++ b/src/generics/assoc_items/types.md @@ -79,7 +79,7 @@ fn main() { container.contains(&number_1, &number_2)); println!("First number: {}", container.first()); println!("Last number: {}", container.last()); - + println!("The difference is: {}", difference(&container)); } ``` diff --git a/src/generics/bounds.md b/src/generics/bounds.md index a3913f6b02..146ecb4270 100644 --- a/src/generics/bounds.md +++ b/src/generics/bounds.md @@ -63,7 +63,7 @@ fn main() { //print_debug(&_triangle); //println!("Area: {}", area(&_triangle)); // ^ TODO: Try uncommenting these. - // | Error: Does not implement either `Debug` or `HasArea`. + // | Error: Does not implement either `Debug` or `HasArea`. } ``` diff --git a/src/generics/gen_fn.md b/src/generics/gen_fn.md index f1985fff8f..96207b9416 100644 --- a/src/generics/gen_fn.md +++ b/src/generics/gen_fn.md @@ -24,7 +24,7 @@ struct SGen(T); // Generic type `SGen`. fn reg_fn(_s: S) {} // Define a function `gen_spec_t` that takes an argument `_s` of type `SGen`. -// It has been explicitly given the type parameter `A`, but because `A` has not +// It has been explicitly given the type parameter `A`, but because `A` has not // been specified as a generic type parameter for `gen_spec_t`, it is not generic. fn gen_spec_t(_s: SGen) {} diff --git a/src/generics/where.md b/src/generics/where.md index 08e073497a..df337db294 100644 --- a/src/generics/where.md +++ b/src/generics/where.md @@ -28,7 +28,7 @@ trait PrintInOption { fn print_in_option(self); } -// Because we would otherwise have to express this as `T: Debug` or +// Because we would otherwise have to express this as `T: Debug` or // use another method of indirect approach, this requires a `where` clause: impl PrintInOption for T where Option: Debug { diff --git a/src/mod/super.md b/src/mod/super.md index 038d4b1271..14784141a8 100644 --- a/src/mod/super.md +++ b/src/mod/super.md @@ -18,29 +18,29 @@ mod my { fn function() { println!("called `my::function()`"); } - + mod cool { pub fn function() { println!("called `my::cool::function()`"); } } - + pub fn indirect_call() { // Let's access all the functions named `function` from this scope! print!("called `my::indirect_call()`, that\n> "); - + // The `self` keyword refers to the current module scope - in this case `my`. // Calling `self::function()` and calling `function()` directly both give // the same result, because they refer to the same function. self::function(); function(); - + // We can also use `self` to access another module inside `my`: self::cool::function(); - + // The `super` keyword refers to the parent scope (outside the `my` module). super::function(); - + // This will bind to the `cool::function` in the *crate* scope. // In this case the crate scope is the outermost scope. { diff --git a/src/primitives.md b/src/primitives.md index cdbee02e77..ef6f85d463 100644 --- a/src/primitives.md +++ b/src/primitives.md @@ -55,7 +55,7 @@ fn main() { // Array signature consists of Type T and length as [T; length]. let my_array: [i32; 5] = [1, 2, 3, 4, 5]; - // Tuple is a collection of values of different types + // Tuple is a collection of values of different types // and is constructed using parentheses (). let my_tuple = (5u32, 1u8, true, -5.04f32); } diff --git a/src/scope/borrow/mut.md b/src/scope/borrow/mut.md index f0bd108cf4..9630d0a529 100644 --- a/src/scope/borrow/mut.md +++ b/src/scope/borrow/mut.md @@ -37,16 +37,16 @@ fn main() { // Create a mutable copy of `immutabook` and call it `mutabook` let mut mutabook = immutabook; - + // Immutably borrow an immutable object borrow_book(&immutabook); // Immutably borrow a mutable object borrow_book(&mutabook); - + // Borrow a mutable object as mutable new_edition(&mut mutabook); - + // Error! Cannot borrow an immutable object as mutable new_edition(&mut immutabook); // FIXME ^ Comment out this line diff --git a/src/scope/borrow/ref.md b/src/scope/borrow/ref.md index e17d679e1a..671690b655 100644 --- a/src/scope/borrow/ref.md +++ b/src/scope/borrow/ref.md @@ -45,13 +45,13 @@ fn main() { // A mutable tuple that includes a pointer let mut mutable_tuple = (Box::new(5u32), 3u32); - + { // Destructure `mutable_tuple` to change the value of `last`. let (_, ref mut last) = mutable_tuple; *last = 2u32; } - + println!("tuple is {:?}", mutable_tuple); } ``` diff --git a/src/scope/lifetime.md b/src/scope/lifetime.md index 01c4bf4050..1b44ed1698 100644 --- a/src/scope/lifetime.md +++ b/src/scope/lifetime.md @@ -16,8 +16,8 @@ lifetimes relate to scopes, as well as how the two differ. ```rust,editable // Lifetimes are annotated below with lines denoting the creation // and destruction of each variable. -// `i` has the longest lifetime because its scope entirely encloses -// both `borrow1` and `borrow2`. The duration of `borrow1` compared +// `i` has the longest lifetime because its scope entirely encloses +// both `borrow1` and `borrow2`. The duration of `borrow1` compared // to `borrow2` is irrelevant since they are disjoint. fn main() { let i = 3; // Lifetime for `i` starts. ────────────────┐ diff --git a/src/scope/lifetime/explicit.md b/src/scope/lifetime/explicit.md index 61ef3876f4..cc62ccda9b 100644 --- a/src/scope/lifetime/explicit.md +++ b/src/scope/lifetime/explicit.md @@ -41,7 +41,7 @@ fn failed_borrow<'a>() { // ERROR: `_x` does not live long enough let _y: &'a i32 = &_x; - // Attempting to use the lifetime `'a` as an explicit type annotation + // Attempting to use the lifetime `'a` as an explicit type annotation // inside the function will fail because the lifetime of `&_x` is shorter // than that of `_y`. A short lifetime cannot be coerced into a longer one. } @@ -49,15 +49,15 @@ fn failed_borrow<'a>() { fn main() { // Create variables to be borrowed below. let (four, nine) = (4, 9); - + // Borrows (`&`) of both variables are passed into the function. print_refs(&four, &nine); - // Any input which is borrowed must outlive the borrower. - // In other words, the lifetime of `four` and `nine` must + // Any input which is borrowed must outlive the borrower. + // In other words, the lifetime of `four` and `nine` must // be longer than that of `print_refs`. - + failed_borrow(); - // `failed_borrow` contains no references to force `'a` to be + // `failed_borrow` contains no references to force `'a` to be // longer than the lifetime of the function, but `'a` is longer. // Because the lifetime is never constrained, it defaults to `'static`. } diff --git a/src/scope/lifetime/fn.md b/src/scope/lifetime/fn.md index c863f09c0b..388fd51dfc 100644 --- a/src/scope/lifetime/fn.md +++ b/src/scope/lifetime/fn.md @@ -42,10 +42,10 @@ fn pass_x<'a, 'b>(x: &'a i32, _: &'b i32) -> &'a i32 { x } fn main() { let x = 7; let y = 9; - + print_one(&x); print_multi(&x, &y); - + let z = pass_x(&x, &y); print_one(z); diff --git a/src/scope/lifetime/lifetime_coercion.md b/src/scope/lifetime/lifetime_coercion.md index 6ebff8f064..5498afcc2b 100644 --- a/src/scope/lifetime/lifetime_coercion.md +++ b/src/scope/lifetime/lifetime_coercion.md @@ -20,10 +20,10 @@ fn choose_first<'a: 'b, 'b>(first: &'a i32, _: &'b i32) -> &'b i32 { fn main() { let first = 2; // Longer lifetime - + { let second = 3; // Shorter lifetime - + println!("The product is {}", multiply(&first, &second)); println!("{} is the first", choose_first(&first, &second)); }; diff --git a/src/scope/move.md b/src/scope/move.md index b20bc406e1..ec829150ee 100644 --- a/src/scope/move.md +++ b/src/scope/move.md @@ -40,7 +40,7 @@ fn main() { // The pointer address of `a` is copied (not the data) into `b`. // Both are now pointers to the same heap allocated data, but // `b` now owns it. - + // Error! `a` can no longer access the data, because it no longer owns the // heap memory //println!("a contains: {}", a); diff --git a/src/std/box.md b/src/std/box.md index bcb5dfde59..3fab709dcf 100644 --- a/src/std/box.md +++ b/src/std/box.md @@ -18,7 +18,7 @@ struct Point { y: f64, } -// A Rectangle can be specified by where its top left and bottom right +// A Rectangle can be specified by where its top left and bottom right // corners are in space #[allow(dead_code)] struct Rectangle { diff --git a/src/std/hash.md b/src/std/hash.md index 6ed0f8ca1c..4baac9b788 100644 --- a/src/std/hash.md +++ b/src/std/hash.md @@ -16,7 +16,7 @@ use std::collections::HashMap; fn call(number: &str) -> &str { match number { - "798-1364" => "We're sorry, the call cannot be completed as dialed. + "798-1364" => "We're sorry, the call cannot be completed as dialed. Please hang up and try again.", "645-7689" => "Hello, this is Mr. Awesome's Pizza. My name is Fred. What can I get for you today?", @@ -24,7 +24,7 @@ fn call(number: &str) -> &str { } } -fn main() { +fn main() { let mut contacts = HashMap::new(); contacts.insert("Daniel", "798-1364"); @@ -47,12 +47,12 @@ fn main() { _ => println!("Don't have Ashley's number."), } - contacts.remove(&"Ashley"); + contacts.remove(&"Ashley"); - // `HashMap::iter()` returns an iterator that yields + // `HashMap::iter()` returns an iterator that yields // (&'a key, &'a value) pairs in arbitrary order. for (contact, &number) in contacts.iter() { - println!("Calling {}: {}", contact, call(number)); + println!("Calling {}: {}", contact, call(number)); } } ``` diff --git a/src/std/panic.md b/src/std/panic.md index d08d1f4e28..01ff70fdba 100644 --- a/src/std/panic.md +++ b/src/std/panic.md @@ -42,15 +42,15 @@ $ rustc panic.rs && valgrind ./panic ==4401== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al. ==4401== Using Valgrind-3.10.0.SVN and LibVEX; rerun with -h for copyright info ==4401== Command: ./panic -==4401== +==4401== thread '
' panicked at 'division by zero', panic.rs:5 -==4401== +==4401== ==4401== HEAP SUMMARY: ==4401== in use at exit: 0 bytes in 0 blocks ==4401== total heap usage: 18 allocs, 18 frees, 1,648 bytes allocated -==4401== +==4401== ==4401== All heap blocks were freed -- no leaks are possible -==4401== +==4401== ==4401== For counts of detected and suppressed errors, rerun with: -v ==4401== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0) ``` diff --git a/src/std/rc.md b/src/std/rc.md index 658145b5ac..5ccc3a018a 100644 --- a/src/std/rc.md +++ b/src/std/rc.md @@ -19,32 +19,32 @@ fn main() { let rc_examples = "Rc examples".to_string(); { println!("--- rc_a is created ---"); - + let rc_a: Rc = Rc::new(rc_examples); println!("Reference Count of rc_a: {}", Rc::strong_count(&rc_a)); - + { println!("--- rc_a is cloned to rc_b ---"); - + let rc_b: Rc = Rc::clone(&rc_a); println!("Reference Count of rc_b: {}", Rc::strong_count(&rc_b)); println!("Reference Count of rc_a: {}", Rc::strong_count(&rc_a)); - + // Two `Rc`s are equal if their inner values are equal println!("rc_a and rc_b are equal: {}", rc_a.eq(&rc_b)); - + // We can use methods of a value directly println!("Length of the value inside rc_a: {}", rc_a.len()); println!("Value of rc_b: {}", rc_b); - + println!("--- rc_b is dropped out of scope ---"); } - + println!("Reference Count of rc_a: {}", Rc::strong_count(&rc_a)); - + println!("--- rc_a is dropped out of scope ---"); } - + // Error! `rc_examples` already moved into `rc_a` // And when `rc_a` is dropped, `rc_examples` is dropped together // println!("rc_examples: {}", rc_examples); diff --git a/src/std_misc/channels.md b/src/std_misc/channels.md index 8c4d45165f..15a735efbf 100644 --- a/src/std_misc/channels.md +++ b/src/std_misc/channels.md @@ -43,7 +43,7 @@ fn main() { // `recv` will block the current thread if there are no messages available ids.push(rx.recv()); } - + // Wait for the threads to complete any remaining work for child in children { child.join().expect("oops! the child thread panicked"); diff --git a/src/std_misc/file/read_lines.md b/src/std_misc/file/read_lines.md index 83907a55e5..c5b7bd274a 100644 --- a/src/std_misc/file/read_lines.md +++ b/src/std_misc/file/read_lines.md @@ -27,7 +27,7 @@ concise and fluent expression. use std::fs::read_to_string; fn read_lines(filename: &str) -> Vec { - read_to_string(filename) + read_to_string(filename) .unwrap() // panic on possible file-reading errors .lines() // split the string into an iterator of string slices .map(String::from) // make each slice into a string diff --git a/src/testing/dev_dependencies.md b/src/testing/dev_dependencies.md index 9d4c3c63c0..2a18cd532b 100644 --- a/src/testing/dev_dependencies.md +++ b/src/testing/dev_dependencies.md @@ -5,7 +5,7 @@ or benchmarks) only. Such dependencies are added to `Cargo.toml` in the `[dev-dependencies]` section. These dependencies are not propagated to other packages which depend on this package. -One such example is [`pretty_assertions`](https://docs.rs/pretty_assertions/1.0.0/pretty_assertions/index.html), which extends standard `assert_eq!` and `assert_ne!` macros, to provide colorful diff. +One such example is [`pretty_assertions`](https://docs.rs/pretty_assertions/1.0.0/pretty_assertions/index.html), which extends standard `assert_eq!` and `assert_ne!` macros, to provide colorful diff. File `Cargo.toml`: ```toml diff --git a/src/trait.md b/src/trait.md index 3c297f5942..67e7ceb887 100644 --- a/src/trait.md +++ b/src/trait.md @@ -60,7 +60,7 @@ impl Animal for Sheep { "baaaaah!" } } - + // Default trait methods can be overridden. fn talk(&self) { // For example, we can add some quiet contemplation. diff --git a/src/trait/drop.md b/src/trait/drop.md index a3e481ea71..7134330c93 100644 --- a/src/trait/drop.md +++ b/src/trait/drop.md @@ -70,7 +70,7 @@ impl TempFile { fn new(path: PathBuf) -> std::io::Result { // Note: File::create() will overwrite existing files let file = File::create(&path)?; - + Ok(Self { file, path }) } } @@ -101,7 +101,7 @@ fn main() -> std::io::Result<()> { let temp2 = TempFile::new("another_test.txt".into())?; drop(temp2); // Explicitly drop the file println!("Manually dropped file"); - + Ok(()) } ``` diff --git a/src/trait/iter.md b/src/trait/iter.md index 611c18b579..0e9efc20cd 100644 --- a/src/trait/iter.md +++ b/src/trait/iter.md @@ -35,7 +35,7 @@ impl Iterator for Fibonacci { self.curr = self.next; self.next = current + self.next; - // Since there's no endpoint to a Fibonacci sequence, the `Iterator` + // Since there's no endpoint to a Fibonacci sequence, the `Iterator` // will never return `None`, and `Some` is always returned. Some(current) } diff --git a/src/trait/supertraits.md b/src/trait/supertraits.md index 5a735af1ae..79ed35fa27 100644 --- a/src/trait/supertraits.md +++ b/src/trait/supertraits.md @@ -18,7 +18,7 @@ trait Programmer { fn fav_language(&self) -> String; } -// CompSciStudent (computer science student) is a subtrait of both Programmer +// CompSciStudent (computer science student) is a subtrait of both Programmer // and Student. Implementing CompSciStudent requires you to impl both supertraits. trait CompSciStudent: Programmer + Student { fn git_username(&self) -> String; diff --git a/src/variable_bindings/declare.md b/src/variable_bindings/declare.md index 9d2382a3c3..122b0bfcbc 100644 --- a/src/variable_bindings/declare.md +++ b/src/variable_bindings/declare.md @@ -1,6 +1,6 @@ # Declare first -It is possible to declare variable bindings first and initialize them later, but all variable bindings must be initialized before they are used: the compiler forbids use of uninitialized variable bindings, as it would lead to undefined behavior. +It is possible to declare variable bindings first and initialize them later, but all variable bindings must be initialized before they are used: the compiler forbids use of uninitialized variable bindings, as it would lead to undefined behavior. It is not common to declare a variable binding and initialize it later in the function. It is more difficult for a reader to find the initialization when initialization is separated from declaration. From 3da646d3c144343f3c33fccea7d1003fc5703c6c Mon Sep 17 00:00:00 2001 From: Bertram Scharpf Date: Thu, 26 Jun 2025 20:24:22 +0200 Subject: [PATCH 2/5] Typos --- po/es.po | 2 +- src/scope/borrow.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/po/es.po b/po/es.po index bbf265a1b3..80c62e1e27 100644 --- a/po/es.po +++ b/po/es.po @@ -593,7 +593,7 @@ msgstr "Sacando `Result`s de `Option`s" #: src/SUMMARY.md:172 src/error/multiple_error_types/define_error_type.md:1 msgid "Defining an error type" -msgstr "Defniniendo un tipo de error" +msgstr "Definiendo un tipo de error" #: src/SUMMARY.md:173 src/error/multiple_error_types/boxing_errors.md:1 msgid "`Box`ing errors" diff --git a/src/scope/borrow.md b/src/scope/borrow.md index c80a4dded8..196cf079f4 100644 --- a/src/scope/borrow.md +++ b/src/scope/borrow.md @@ -20,7 +20,7 @@ fn borrow_i32(borrowed_i32: &i32) { } fn main() { - // Create a boxed i32 in the heap, and a i32 on the stack + // Create a boxed i32 in the heap, and an i32 on the stack // Remember: numbers can have arbitrary underscores added for readability // 5_i32 is the same as 5i32 let boxed_i32 = Box::new(5_i32); From c33adb94c6eb61c1d7809bbbf43eb3d0d08f3173 Mon Sep 17 00:00:00 2001 From: Bertram Scharpf Date: Thu, 26 Jun 2025 20:25:18 +0200 Subject: [PATCH 3/5] Remove wrong indentation --- src/error/option_unwrap/defaults.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/error/option_unwrap/defaults.md b/src/error/option_unwrap/defaults.md index 3b2088e6a5..e5bf2db265 100644 --- a/src/error/option_unwrap/defaults.md +++ b/src/error/option_unwrap/defaults.md @@ -27,7 +27,7 @@ fn main() { // But the variable named `apple` has been moved regardless, and cannot be used anymore. // println!("Variable apple was moved, so this line won't compile: {:?}", apple); // TODO: uncomment the line above to see the compiler error - } +} ``` ## `or_else()` is chainable, evaluates lazily, keeps empty value intact From 071ae661cb8d06fc0a3b31a6b2df21c07894b39f Mon Sep 17 00:00:00 2001 From: Bertram Scharpf Date: Thu, 26 Jun 2025 20:25:35 +0200 Subject: [PATCH 4/5] Remove empty lines --- src/std_misc/fs.md | 1 - src/std_misc/path.md | 1 - src/std_misc/threads/testcase_mapreduce.md | 2 -- 3 files changed, 4 deletions(-) diff --git a/src/std_misc/fs.md b/src/std_misc/fs.md index ba2d4b4fac..04d1e10bad 100644 --- a/src/std_misc/fs.md +++ b/src/std_misc/fs.md @@ -103,7 +103,6 @@ fn main() { println!("! {:?}", why.kind()); }); } - ``` Here's the expected successful output: diff --git a/src/std_misc/path.md b/src/std_misc/path.md index 378df6ed87..7fd931fcaf 100644 --- a/src/std_misc/path.md +++ b/src/std_misc/path.md @@ -45,7 +45,6 @@ fn main() { Some(s) => println!("new path is {}", s), } } - ``` Be sure to check at other `Path` methods (`posix::Path` or `windows::Path`) and diff --git a/src/std_misc/threads/testcase_mapreduce.md b/src/std_misc/threads/testcase_mapreduce.md index 0de796d9da..c021b743d6 100644 --- a/src/std_misc/threads/testcase_mapreduce.md +++ b/src/std_misc/threads/testcase_mapreduce.md @@ -115,8 +115,6 @@ fn main() { println!("Final sum result: {}", final_result); } - - ``` ### Assignments From 386237275e2d939e8b242f1727207732087b5563 Mon Sep 17 00:00:00 2001 From: Bertram Scharpf Date: Sat, 5 Jul 2025 10:01:42 +0200 Subject: [PATCH 5/5] Color values and hex output are unsigned --- src/custom_types/enum/c_like.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/custom_types/enum/c_like.md b/src/custom_types/enum/c_like.md index 65f832bef8..25b90dbc42 100644 --- a/src/custom_types/enum/c_like.md +++ b/src/custom_types/enum/c_like.md @@ -25,8 +25,8 @@ fn main() { println!("zero is {}", Number::Zero as i32); println!("one is {}", Number::One as i32); - println!("roses are #{:06x}", Color::Red as i32); - println!("violets are #{:06x}", Color::Blue as i32); + println!("roses are #{:06x}", Color::Red as u32); + println!("violets are #{:06x}", Color::Blue as u32); } ```