@@ -1954,7 +1954,7 @@ On `struct`s:
1954
1954
1955
1955
- ` repr ` - specifies the representation to use for this struct. Takes a list
1956
1956
of options. The currently accepted ones are ` C ` and ` packed ` , which may be
1957
- combined. ` C ` will use a C ABI compatible struct layout, and ` packed ` will
1957
+ combined. ` C ` will use a C ABI comptible struct layout, and ` packed ` will
1958
1958
remove any padding between fields (note that this is very fragile and may
1959
1959
break platforms which require aligned access).
1960
1960
@@ -2367,7 +2367,7 @@ One can indicate the stability of an API using the following attributes:
2367
2367
These levels are directly inspired by
2368
2368
[ Node.js' "stability index"] ( http://nodejs.org/api/documentation.html ) .
2369
2369
2370
- Stability levels are inherited, so an item 's stability attribute is the
2370
+ Stability levels are inherited, so an items 's stability attribute is the
2371
2371
default stability for everything nested underneath it.
2372
2372
2373
2373
There are lints for disallowing items marked with certain levels: ` deprecated ` ,
@@ -2444,7 +2444,7 @@ The currently implemented features of the reference compiler are:
2444
2444
2445
2445
* ` concat_idents ` - Allows use of the ` concat_idents ` macro, which is in many
2446
2446
ways insufficient for concatenating identifiers, and may
2447
- be removed entirely for something more wholesome .
2447
+ be removed entirely for something more wholsome .
2448
2448
2449
2449
* ` default_type_params ` - Allows use of default type parameters. The future of
2450
2450
this feature is uncertain.
@@ -3604,7 +3604,7 @@ of the type.[^structtype]
3604
3604
3605
3605
New instances of a ` struct ` can be constructed with a [ struct expression] ( #structure-expressions ) .
3606
3606
3607
- The memory layout of a ` struct ` is undefined by default to allow for compiler optimizations like
3607
+ The memory layout of a ` struct ` is undefined by default to allow for compiler optimziations like
3608
3608
field reordering, but it can be fixed with the ` #[repr(...)] ` attribute.
3609
3609
In either case, fields may be given in any order in a corresponding struct * expression* ;
3610
3610
the resulting ` struct ` value will always have the same memory layout.
@@ -3668,17 +3668,32 @@ let a: List<int> = Cons(7, box Cons(13, box Nil));
3668
3668
3669
3669
All pointers in Rust are explicit first-class values.
3670
3670
They can be copied, stored into data structures, and returned from functions.
3671
- There are two varieties of pointer in Rust:
3671
+ There are four varieties of pointer in Rust:
3672
+
3673
+ * Owning pointers (` Box ` )
3674
+ : These point to owned heap allocations (or "boxes") in the shared, inter-task heap.
3675
+ Each owned box has a single owning pointer; pointer and pointee retain a 1:1 relationship at all times.
3676
+ Owning pointers are written ` Box<content> ` ,
3677
+ for example ` Box<int> ` means an owning pointer to an owned box containing an integer.
3678
+ Copying an owned box is a "deep" operation:
3679
+ it involves allocating a new owned box and copying the contents of the old box into the new box.
3680
+ Releasing an owning pointer immediately releases its corresponding owned box.
3672
3681
3673
3682
* References (` & ` )
3674
3683
: These point to memory _ owned by some other value_ .
3675
- A reference type is written ` &type ` for some lifetime-variable ` f ` ,
3676
- or just ` &'a type ` when you need an explicit lifetime.
3684
+ References arise by (automatic) conversion from owning pointers, managed pointers,
3685
+ or by applying the borrowing operator ` & ` to some other value,
3686
+ including [ lvalues, rvalues or temporaries] ( #lvalues,-rvalues-and-temporaries ) .
3687
+ A borrow expression is written ` &content ` .
3688
+
3689
+ A reference type is written ` &'f type ` for some lifetime-variable ` f ` ,
3690
+ or just ` &type ` when the lifetime can be elided;
3691
+ for example ` &int ` means a reference to an integer.
3677
3692
Copying a reference is a "shallow" operation:
3678
3693
it involves only copying the pointer itself.
3679
3694
Releasing a reference typically has no effect on the value it points to,
3680
- with the exception of temporary values, which are released when the last
3681
- reference to them is released.
3695
+ with the exception of temporary values,
3696
+ which are released when the last reference to them is released.
3682
3697
3683
3698
* Raw pointers (` * ` )
3684
3699
: Raw pointers are pointers without safety or liveness guarantees.
@@ -3691,9 +3706,6 @@ There are two varieties of pointer in Rust:
3691
3706
they exist to support interoperability with foreign code,
3692
3707
and writing performance-critical or low-level functions.
3693
3708
3694
- The standard library contains addtional 'smart pointer' types beyond references
3695
- and raw pointers.
3696
-
3697
3709
### Function types
3698
3710
3699
3711
The function type constructor ` fn ` forms new function types.
@@ -4202,7 +4214,7 @@ be ignored in favor of only building the artifacts specified by command line.
4202
4214
purpose of this output type is to create a static library containing all of
4203
4215
the local crate's code along with all upstream dependencies. The static
4204
4216
library is actually a ` *.a ` archive on linux and osx and a ` *.lib ` file on
4205
- windows. This format is recommended for use in situations such as linking
4217
+ windows. This format is recommended for use in situtations such as linking
4206
4218
Rust code into an existing non-Rust application because it will not have
4207
4219
dynamic dependencies on other Rust code.
4208
4220
0 commit comments