Skip to content

tutorial: clearer explanation of freezing. #12536

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

Closed
wants to merge 3 commits into from
Closed
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
8 changes: 4 additions & 4 deletions src/doc/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -1468,14 +1468,14 @@ For a more in-depth explanation of references and lifetimes, read the

## Freezing

Lending an immutable pointer to an object freezes it and prevents mutation.
Lending an &-pointer to an object freezes it and prevents mutation—even if the object was declared as `mut`.
`Freeze` objects have freezing enforced statically at compile-time. An example
of a non-`Freeze` type is [`RefCell<T>`][refcell].

~~~~
let mut x = 5;
{
let y = &x; // `x` is now frozen, it cannot be modified
let y = &x; // `x` is now frozen. It cannot be modified or re-assigned.
}
// `x` is now unfrozen again
# x = 3;
Expand Down Expand Up @@ -2021,8 +2021,8 @@ C++ templates.

## Traits

Within a generic function -- that is, a function parameterized by a
type parameter, say, `T` -- the operations we can do on arguments of
Within a generic functionthat is, a function parameterized by a
type parameter, say, `T`the operations we can do on arguments of
type `T` are quite limited. After all, since we don't know what type
`T` will be instantiated with, we can't safely modify or query values
of type `T`. This is where _traits_ come into play. Traits are Rust's
Expand Down