Skip to content

Fix for a set of typos #1551

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/generics/phantom.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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, B>(A,PhantomData<B>);
struct PhantomTuple<A, B>(A, PhantomData<B>);

// A phantom type struct which is generic over `A` with hidden parameter `B`.
#[derive(PartialEq)] // Allow equality test for this type.
Expand All @@ -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);
}
```

Expand All @@ -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
[std::marker::PhantomData]: https://doc.rust-lang.org/std/marker/struct.PhantomData.html
2 changes: 1 addition & 1 deletion src/hello/print.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions src/primitives/array.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 7 additions & 5 deletions src/trait/disambiguating.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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());
Expand Down