Skip to content
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

Typo fixes #556

Merged
merged 9 commits into from
Mar 28, 2019
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
2 changes: 1 addition & 1 deletion src/expressions/match-expr.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ let message = match maybe_digit {
```

> Note: Multiple matches using the `|` operator can cause the pattern guard and
> and side effects it has to execute multiple times. For example:
> the side effects it has to execute multiple times. For example:
>
> ```rust
> # use std::cell::Cell;
Expand Down
4 changes: 2 additions & 2 deletions src/expressions/operator-expr.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ Dereferencing a raw pointer requires `unsafe`.

On non-pointer types `*x` is equivalent to `*std::ops::Deref::deref(&x)` in an
[immutable place expression context](expressions.html#mutability) and
`*std::ops::Deref::deref_mut(&mut x)` in a mutable place expression context.
`*std::ops::DerefMut::deref_mut(&mut x)` in a mutable place expression context.

```rust
let x = &7;
Expand Down Expand Up @@ -131,7 +131,7 @@ println!("{:?}", res);
# assert!(res.is_err())
```

When applied to values of the `Option<T>` type, it propagates `Nones`. If the
When applied to values of the `Option<T>` type, it propagates `None`s. If the
value is `None`, then it will return `None`. If applied to `Some(x)`, then it
will unwrap the value to evaluate to `x`.

Expand Down
2 changes: 1 addition & 1 deletion src/special-types-and-traits.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ according to the following rules:
closure that captures a `T` by shared reference and a `U` by value implements
any auto traits that both `&T` and `U` do.

For generic types (counting the built-in types above as generic over `T`), if an
For generic types (counting the built-in types above as generic over `T`), if a
generic implementation is available, then the compiler does not automatically
implement it for types that could use the implementation except that they do not
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Centril Perhaps this can be re-phrased? I can't seem to understand what the except that they do not meet... part means. Does that mean except if they or except then they...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider:

struct A<T>(T);

unsafe impl<T: Copy> Send for A<T> {}

fn assert_send<T: Send>() {}

fn main() {
    assert_send::<A<u8>>();
    assert_send::<A<String>>();
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the compiler would have done this (and does so if we comment out our unsafe impl):

unsafe impl Send for A<String> {}
// as part of:
unsafe impl Send for A<T> where T: Send {}

But our unsafe impl tells the compiler to disregard its auto trait rules and instead use our "rule" (impl), i.e. we tell the compiler that it is not safe to Send values of type A<T> unless T: Copy?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, pretty much.

meet the requisite trait bounds. For instance, the standard library implements
Expand Down
12 changes: 6 additions & 6 deletions src/type-coercions.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ Coercion is allowed between the following types:
* `T_1` to `T_3` where `T_1` coerces to `T_2` and `T_2` coerces to `T_3`
(*transitive case*)

Note that this is not fully supported yet
Note that this is not fully supported yet.

* `&mut T` to `&T`

Expand Down Expand Up @@ -158,9 +158,9 @@ cases where other coercions are not, as described above. They can still happen
anywhere else a coercion can occur.

Two traits, [`Unsize`] and [`CoerceUnsized`], are used
to assist in this process and expose it for library use. The compiler following
coercions are built-in and, if `T` can be coerced to `U` with one of the, then
the compiler will provide an implementation of `Unsize<U>` for `T`:
to assist in this process and expose it for library use. The following
coercions are built-ins and, if `T` can be coerced to `U` with one of them, then
an implementation of `Unsize<U>` for `T` will be provided:

* `[T; n]` to `[T]`.

Expand All @@ -182,5 +182,5 @@ unsized coercion to `Foo<U>`.
> has been stabilized, the traits themselves are not yet stable and therefore
> can't be used directly in stable Rust.

[Unsize]: ../std/marker/trait.Unsize.html
[CoerceUnsized]: ../std/ops/trait.CoerceUnsized.html
[`Unsize`]: ../std/marker/trait.Unsize.html
[`CoerceUnsized`]: ../std/ops/trait.CoerceUnsized.html
2 changes: 1 addition & 1 deletion src/type-layout.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ The union will have a size of the maximum size of all of its fields rounded to
its alignment, and an alignment of the maximum alignment of all of its fields.
These maximums may come from different fields.

```
```rust
#[repr(C)]
union Union {
f1: u16,
Expand Down
2 changes: 1 addition & 1 deletion src/types/trait-object.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ of the base trait.
Trait objects are written as the optional keyword `dyn` followed by a set of
trait bounds, but with the following restrictions on the trait bounds. All
traits except the first trait must be auto traits, there may not be more than
one lifetime, and opt-out bounds (e.g. `?sized`) are not allowed. Furthermore,
one lifetime, and opt-out bounds (e.g. `?Sized`) are not allowed. Furthermore,
paths to traits may be parenthesized.

For example, given a trait `Trait`, the following are all trait objects:
Expand Down
2 changes: 2 additions & 0 deletions src/variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,5 @@ fn initialization_example() {
// uninit_after_if; // err: use of possibly uninitialized `uninit_after_if`
}
```

[`if` expression]: expressions/if-expr.html#if-expressions