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

Replaced ~T by Box<T> in manual #14175

Closed
wants to merge 1 commit 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
18 changes: 9 additions & 9 deletions src/doc/rust.md
Original file line number Diff line number Diff line change
Expand Up @@ -2648,9 +2648,9 @@ before the expression they apply to.
: Logical negation. On the boolean type, this flips between `true` and
`false`. On integer types, this inverts the individual bits in the
two's complement representation of the value.
* `~`
* `box`
: [Boxing](#pointer-types) operators. Allocate a box to hold the value they are applied to,
and store the value in it. `~` creates an owned box.
and store the value in it. `box` creates an owned box.
* `&`
: Borrow operator. Returns a reference, pointing to its operand.
The operand of a borrow is statically proven to outlive the resulting pointer.
Expand Down Expand Up @@ -3156,7 +3156,7 @@ fn main() {
~~~~

Patterns can also dereference pointers by using the `&`,
`~` or `@` symbols, as appropriate. For example, these two matches
`box` or `@` symbols, as appropriate. For example, these two matches
on `x: &int` are equivalent:

~~~~
Expand Down Expand Up @@ -3438,11 +3438,11 @@ All pointers in Rust are explicit first-class values.
They can be copied, stored into data structures, and returned from functions.
There are four varieties of pointer in Rust:

* Owning pointers (`~`)
* Owning pointers (`Box`)
: These point to owned heap allocations (or "boxes") in the shared, inter-task heap.
Each owned box has a single owning pointer; pointer and pointee retain a 1:1 relationship at all times.
Owning pointers are written `~content`,
for example `~int` means an owning pointer to an owned box containing an integer.
Owning pointers are written `Box<content>`,
for example `Box<int>` means an owning pointer to an owned box containing an integer.
Copying an owned box is a "deep" operation:
it involves allocating a new owned box and copying the contents of the old box into the new box.
Releasing an owning pointer immediately releases its corresponding owned box.
Expand Down Expand Up @@ -3562,8 +3562,8 @@ Whereas most calls to trait methods are "early bound" (statically resolved) to s
a call to a method on an object type is only resolved to a vtable entry at compile time.
The actual implementation for each vtable entry can vary on an object-by-object basis.

Given a pointer-typed expression `E` of type `&T` or `~T`, where `T` implements trait `R`,
casting `E` to the corresponding pointer type `&R` or `~R` results in a value of the _object type_ `R`.
Given a pointer-typed expression `E` of type `&T` or `Box<T>`, where `T` implements trait `R`,
casting `E` to the corresponding pointer type `&R` or `Box<R>` results in a value of the _object type_ `R`.
This result is represented as a pair of pointers:
the vtable pointer for the `T` implementation of `R`, and the pointer value of `E`.

Expand Down Expand Up @@ -3761,7 +3761,7 @@ Local variables are immutable unless declared otherwise like: `let mut x = ...`.

Function parameters are immutable unless declared with `mut`. The
`mut` keyword applies only to the following parameter (so `|mut x, y|`
and `fn f(mut x: ~int, y: ~int)` declare one mutable variable `x` and
and `fn f(mut x: Box<int>, y: Box<int>)` declare one mutable variable `x` and
one immutable variable `y`).

Methods that take either `self` or `~self` can optionally place them in a
Expand Down