From 533058dec676c2e337d527a3d01e1fcaf90754f5 Mon Sep 17 00:00:00 2001 From: Korlo <88337245+Rqnsom@users.noreply.github.com> Date: Wed, 15 Jun 2022 12:28:30 +0200 Subject: [PATCH] Fix for a set of typos --- src/generics/phantom.md | 18 +++++++++--------- src/hello/print.md | 2 +- src/primitives/array.md | 6 +++--- src/trait/disambiguating.md | 12 +++++++----- 4 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/generics/phantom.md b/src/generics/phantom.md index 59cf125d11..8743a3ed68 100644 --- a/src/generics/phantom.md +++ b/src/generics/phantom.md @@ -4,7 +4,7 @@ A phantom type parameter is one that doesn't show up at runtime, but is checked statically (and only) at compile time. Data types can use extra generic type parameters to act as markers -or to perform type checking at compile time. These extra parameters +or to perform type checking at compile time. These extra parameters hold no storage values, and have no runtime behavior. In the following example, we combine [std::marker::PhantomData] @@ -16,7 +16,7 @@ use std::marker::PhantomData; // A phantom tuple struct which is generic over `A` with hidden parameter `B`. #[derive(PartialEq)] // Allow equality test for this type. -struct PhantomTuple(A,PhantomData); +struct PhantomTuple(A, PhantomData); // A phantom type struct which is generic over `A` with hidden parameter `B`. #[derive(PartialEq)] // Allow equality test for this type. @@ -42,14 +42,14 @@ fn main() { first: 'Q', phantom: PhantomData, }; - + // Compile-time Error! Type mismatch so these cannot be compared: - //println!("_tuple1 == _tuple2 yields: {}", - // _tuple1 == _tuple2); - + // println!("_tuple1 == _tuple2 yields: {}", + // _tuple1 == _tuple2); + // Compile-time Error! Type mismatch so these cannot be compared: - //println!("_struct1 == _struct2 yields: {}", - // _struct1 == _struct2); + // println!("_struct1 == _struct2 yields: {}", + // _struct1 == _struct2); } ``` @@ -60,4 +60,4 @@ fn main() { [Derive]: ../trait/derive.md [struct]: ../custom_types/structs.md [TupleStructs]: ../custom_types/structs.md -[std::marker::PhantomData]: https://doc.rust-lang.org/std/marker/struct.PhantomData.html \ No newline at end of file +[std::marker::PhantomData]: https://doc.rust-lang.org/std/marker/struct.PhantomData.html diff --git a/src/hello/print.md b/src/hello/print.md index 6452c33106..efedeb79df 100644 --- a/src/hello/print.md +++ b/src/hello/print.md @@ -7,7 +7,7 @@ some of which include: * `print!`: same as `format!` but the text is printed to the console (io::stdout). * `println!`: same as `print!` but a newline is appended. * `eprint!`: same as `print!` but the text is printed to the standard error (io::stderr). -* `eprintln!`: same as `eprint!`but a newline is appended. +* `eprintln!`: same as `eprint!` but a newline is appended. All parse text in the same fashion. As a plus, Rust checks formatting correctness at compile time. diff --git a/src/primitives/array.md b/src/primitives/array.md index e624f03271..d0cd50e26a 100644 --- a/src/primitives/array.md +++ b/src/primitives/array.md @@ -6,9 +6,9 @@ at compile time, is part of their type signature `[T; length]`. Slices are similar to arrays, but their length is not known at compile time. Instead, a slice is a two-word object, the first word is a pointer to the data, -and the second word is the length of the slice. The word size is the same as -usize, determined by the processor architecture eg 64 bits on an x86-64. -Slices can be used to borrow a section of an array, and have the type signature +and the second word is the length of the slice. The word size is the same as +usize, determined by the processor architecture e.g. 64 bits on an x86-64. +Slices can be used to borrow a section of an array, and have the type signature `&[T]`. ```rust,editable,ignore,mdbook-runnable diff --git a/src/trait/disambiguating.md b/src/trait/disambiguating.md index c893e9dc8d..ae80d4acb8 100644 --- a/src/trait/disambiguating.md +++ b/src/trait/disambiguating.md @@ -1,9 +1,11 @@ # Disambiguating overlapping traits -A type can implement many different traits. What if two traits both require the same name? For example, many traits might have a method named `get()`. They might even have different return types! +A type can implement many different traits. What if two traits both require +the same name? For example, many traits might have a method named `get()`. +They might even have different return types! -Good news: because each trait implementation gets its own `impl` block, it's -clear which trait's `get` method you're implementing. +Good news: because each trait implementation gets its own `impl` block, it's +clear which trait's `get` method you're implementing. What about when it comes time to _call_ those methods? To disambiguate between them, we have to use Fully Qualified Syntax. @@ -38,12 +40,12 @@ impl AgeWidget for Form { } fn main() { - let form = Form{ + let form = Form { username: "rustacean".to_owned(), age: 28, }; - // If you uncomment this line, you'll get an error saying + // If you uncomment this line, you'll get an error saying // "multiple `get` found". Because, after all, there are multiple methods // named `get`. // println!("{}", form.get());