@@ -603,7 +603,7 @@ mod b {
603
603
```
604
604
605
605
* Paths starting with the keyword ` super ` begin resolution relative to the
606
- parent module. Each further identifier must resolve to an item
606
+ parent module. Each further identifier must resolve to an item.
607
607
608
608
``` rust
609
609
mod a {
@@ -985,7 +985,7 @@ top of [modules](#modules) and [blocks](#blocks).
985
985
986
986
Use declarations support a number of convenient shortcuts:
987
987
988
- * Rebinding the target name as a new local name, using the syntax ` use p::q::r as x; ` .
988
+ * Rebinding the target name as a new local name, using the syntax ` use p::q::r as x; `
989
989
* Simultaneously binding a list of paths differing only in their final element,
990
990
using the glob-like brace syntax ` use a::b::{c,d,e,f}; `
991
991
* Binding all paths matching a given prefix, using the asterisk wildcard syntax
@@ -1091,7 +1091,7 @@ set of *input* [*slots*](#memory-slots) as parameters, through which the caller
1091
1091
passes arguments into the function, and an * output* [ * slot* ] ( #memory-slots )
1092
1092
through which the function passes results back to the caller.
1093
1093
1094
- A function may also be copied into a first class * value* , in which case the
1094
+ A function may also be copied into a first- class * value* , in which case the
1095
1095
value has the corresponding [ * function type* ] ( #function-types ) , and can be used
1096
1096
otherwise exactly as a function item (with a minor additional cost of calling
1097
1097
the function indirectly).
@@ -1224,7 +1224,7 @@ the guarantee that these issues are never caused by safe code.
1224
1224
* A value other than ` false ` (0) or ` true ` (1) in a ` bool `
1225
1225
* A discriminant in an ` enum ` not included in the type definition
1226
1226
* A value in a ` char ` which is a surrogate or above ` char::MAX `
1227
- * non -UTF-8 byte sequences in a ` str `
1227
+ * Non -UTF-8 byte sequences in a ` str `
1228
1228
* Unwinding into Rust from foreign code or unwinding from Rust into foreign
1229
1229
code. Rust's failure system is not compatible with exception handling in
1230
1230
other languages. Unwinding must be caught and handled at FFI boundaries.
@@ -1827,7 +1827,7 @@ accesses in two cases:
1827
1827
1828
1828
These two cases are surprisingly powerful for creating module hierarchies
1829
1829
exposing public APIs while hiding internal implementation details. To help
1830
- explain, here's a few use cases and what they would entail.
1830
+ explain, here's a few use cases and what they would entail:
1831
1831
1832
1832
* A library developer needs to expose functionality to crates which link
1833
1833
against their library. As a consequence of the first case, this means that
@@ -1858,7 +1858,7 @@ import/expression is only valid if the destination is in the current visibility
1858
1858
scope.
1859
1859
1860
1860
Here's an example of a program which exemplifies the three cases outlined
1861
- above.
1861
+ above:
1862
1862
1863
1863
```
1864
1864
// This module is private, meaning that no external crate can access this
@@ -2117,6 +2117,13 @@ macro scope.
2117
2117
destructors from being run twice. Destructors might be run multiple times on
2118
2118
the same object with this attribute.
2119
2119
- ` doc ` - Doc comments such as ` /// foo ` are equivalent to ` #[doc = "foo"] ` .
2120
+ - ` rustc_on_unimplemented ` - Write a custom note to be shown along with the error
2121
+ when the trait is found to be unimplemented on a type.
2122
+ You may use format arguments like ` {T} ` , ` {A} ` to correspond to the
2123
+ types at the point of use corresponding to the type parameters of the
2124
+ trait of the same name. ` {Self} ` will be replaced with the type that is supposed
2125
+ to implement the trait but doesn't. To use this, the ` on_unimplemented ` feature gate
2126
+ must be enabled.
2120
2127
2121
2128
### Conditional compilation
2122
2129
@@ -2163,7 +2170,7 @@ arbitrarily complex configurations through nesting.
2163
2170
The following configurations must be defined by the implementation:
2164
2171
2165
2172
* ` target_arch = "..." ` . Target CPU architecture, such as ` "x86" ` , ` "x86_64" `
2166
- ` "mips" ` , ` "arm" ` , or ` "aarch64" ` .
2173
+ ` "mips" ` , ` "powerpc" ` , ` " arm"` , or ` "aarch64" ` .
2167
2174
* ` target_endian = "..." ` . Endianness of the target CPU, either ` "little" ` or
2168
2175
` "big" ` .
2169
2176
* ` target_family = "..." ` . Operating system family of the target, e. g.
@@ -2213,7 +2220,7 @@ mod m1 {
2213
2220
```
2214
2221
2215
2222
This example shows how one can use ` allow ` and ` warn ` to toggle a particular
2216
- check on and off.
2223
+ check on and off:
2217
2224
2218
2225
``` {.ignore}
2219
2226
#[warn(missing_docs)]
@@ -2235,7 +2242,7 @@ mod m2{
2235
2242
```
2236
2243
2237
2244
This example shows how one can use ` forbid ` to disallow uses of ` allow ` for
2238
- that lint check.
2245
+ that lint check:
2239
2246
2240
2247
``` {.ignore}
2241
2248
#[forbid(missing_docs)]
@@ -2318,9 +2325,9 @@ These language items are traits:
2318
2325
* ` ord `
2319
2326
: Elements have a partial ordering.
2320
2327
* ` deref `
2321
- : ` * ` can be applied, yielding a reference to another type
2328
+ : ` * ` can be applied, yielding a reference to another type.
2322
2329
* ` deref_mut `
2323
- : ` * ` can be applied, yielding a mutable reference to another type
2330
+ : ` * ` can be applied, yielding a mutable reference to another type.
2324
2331
2325
2332
These are functions:
2326
2333
@@ -2341,7 +2348,7 @@ These are functions:
2341
2348
* ` type_id `
2342
2349
: The type returned by the ` type_id ` intrinsic.
2343
2350
* ` unsafe `
2344
- : A type whose contents can be mutated through an immutable reference
2351
+ : A type whose contents can be mutated through an immutable reference.
2345
2352
2346
2353
#### Marker types
2347
2354
@@ -2350,11 +2357,11 @@ These types help drive the compiler's analysis
2350
2357
* ` begin_unwind `
2351
2358
: ___ Needs filling in___
2352
2359
* ` no_copy_bound `
2353
- : This type does not implement "copy", even if eligible
2360
+ : This type does not implement "copy", even if eligible.
2354
2361
* ` no_send_bound `
2355
- : This type does not implement "send", even if eligible
2362
+ : This type does not implement "send", even if eligible.
2356
2363
* ` no_sync_bound `
2357
- : This type does not implement "sync", even if eligible
2364
+ : This type does not implement "sync", even if eligible.
2358
2365
* ` eh_personality `
2359
2366
: ___ Needs filling in___
2360
2367
* ` exchange_free `
@@ -2376,11 +2383,11 @@ These types help drive the compiler's analysis
2376
2383
* ` iterator `
2377
2384
: ___ Needs filling in___
2378
2385
* ` contravariant_lifetime `
2379
- : The lifetime parameter should be considered contravariant
2386
+ : The lifetime parameter should be considered contravariant.
2380
2387
* ` covariant_lifetime `
2381
- : The lifetime parameter should be considered covariant
2388
+ : The lifetime parameter should be considered covariant.
2382
2389
* ` invariant_lifetime `
2383
- : The lifetime parameter should be considered invariant
2390
+ : The lifetime parameter should be considered invariant.
2384
2391
* ` malloc `
2385
2392
: Allocate memory on the managed heap.
2386
2393
* ` owned_box `
@@ -2390,11 +2397,11 @@ These types help drive the compiler's analysis
2390
2397
* ` start `
2391
2398
: ___ Needs filling in___
2392
2399
* ` contravariant_type `
2393
- : The type parameter should be considered contravariant
2400
+ : The type parameter should be considered contravariant.
2394
2401
* ` covariant_type `
2395
- : The type parameter should be considered covariant
2402
+ : The type parameter should be considered covariant.
2396
2403
* ` invariant_type `
2397
- : The type parameter should be considered invariant
2404
+ : The type parameter should be considered invariant.
2398
2405
* ` ty_desc `
2399
2406
: ___ Needs filling in___
2400
2407
@@ -2425,15 +2432,15 @@ There are three different types of inline attributes:
2425
2432
* ` #[inline(always)] ` asks the compiler to always perform an inline expansion.
2426
2433
* ` #[inline(never)] ` asks the compiler to never perform an inline expansion.
2427
2434
2428
- ### Deriving
2435
+ ### Derive
2429
2436
2430
- The ` deriving ` attribute allows certain traits to be automatically implemented
2437
+ The ` derive ` attribute allows certain traits to be automatically implemented
2431
2438
for data structures. For example, the following will create an ` impl ` for the
2432
2439
` PartialEq ` and ` Clone ` traits for ` Foo ` , the type parameter ` T ` will be given
2433
2440
the ` PartialEq ` or ` Clone ` constraints for the appropriate ` impl ` :
2434
2441
2435
2442
```
2436
- #[deriving (PartialEq, Clone)]
2443
+ #[derive (PartialEq, Clone)]
2437
2444
struct Foo<T> {
2438
2445
a: int,
2439
2446
b: T
@@ -2455,7 +2462,7 @@ impl<T: PartialEq> PartialEq for Foo<T> {
2455
2462
}
2456
2463
```
2457
2464
2458
- Supported traits for ` deriving ` are:
2465
+ Supported traits for ` derive ` are:
2459
2466
2460
2467
* Comparison traits: ` PartialEq ` , ` Eq ` , ` PartialOrd ` , ` Ord ` .
2461
2468
* Serialization: ` Encodable ` , ` Decodable ` . These require ` serialize ` .
@@ -2921,13 +2928,13 @@ automatically dereferenced to make the field access possible.
2921
2928
``` {.ebnf .gram}
2922
2929
array_expr : '[' "mut" ? vec_elems? ']' ;
2923
2930
2924
- array_elems : [expr [',' expr]*] | [expr ',' ".." expr] ;
2931
+ array_elems : [expr [',' expr]*] | [expr ';' expr] ;
2925
2932
```
2926
2933
2927
2934
An [ array] ( #array,-and-slice-types ) _ expression_ is written by enclosing zero
2928
2935
or more comma-separated expressions of uniform type in square brackets.
2929
2936
2930
- In the ` [expr ',' ".." expr] ` form, the expression after the ` ".." ` must be a
2937
+ In the ` [expr ';' expr] ` form, the expression after the ` ';' ` must be a
2931
2938
constant expression that can be evaluated at compile time, such as a
2932
2939
[ literal] ( #literals ) or a [ static item] ( #static-items ) .
2933
2940
@@ -3219,11 +3226,11 @@ the simplest and least-expensive form (analogous to a ```|| { }``` expression),
3219
3226
the lambda expression captures its environment by reference, effectively
3220
3227
borrowing pointers to all outer variables mentioned inside the function.
3221
3228
Alternately, the compiler may infer that a lambda expression should copy or
3222
- move values (depending on their type. ) from the environment into the lambda
3229
+ move values (depending on their type) from the environment into the lambda
3223
3230
expression's captured environment.
3224
3231
3225
3232
In this example, we define a function ` ten_times ` that takes a higher-order
3226
- function argument, and call it with a lambda expression as an argument.
3233
+ function argument, and call it with a lambda expression as an argument:
3227
3234
3228
3235
```
3229
3236
fn ten_times<F>(f: F) where F: Fn(int) {
@@ -3661,14 +3668,14 @@ within an object along with one byte past the end.
3661
3668
The types ` char ` and ` str ` hold textual data.
3662
3669
3663
3670
A value of type ` char ` is a [ Unicode scalar value] (
3664
- http://www.unicode.org/glossary/#unicode_scalar_value ) (ie . a code point that
3671
+ http://www.unicode.org/glossary/#unicode_scalar_value ) (i.e . a code point that
3665
3672
is not a surrogate), represented as a 32-bit unsigned word in the 0x0000 to
3666
3673
0xD7FF or 0xE000 to 0x10FFFF range. A ` [char] ` array is effectively an UCS-4 /
3667
3674
UTF-32 string.
3668
3675
3669
3676
A value of type ` str ` is a Unicode string, represented as an array of 8-bit
3670
3677
unsigned bytes holding a sequence of UTF-8 codepoints. Since ` str ` is of
3671
- unknown size, it is not a _ first class_ type, but can only be instantiated
3678
+ unknown size, it is not a _ first- class_ type, but can only be instantiated
3672
3679
through a pointer type, such as ` &str ` or ` String ` .
3673
3680
3674
3681
### Tuple types
@@ -3698,7 +3705,7 @@ assert!(b != "world");
3698
3705
3699
3706
Rust has two different types for a list of items:
3700
3707
3701
- * ` [T .. N] ` , an 'array'
3708
+ * ` [T; N] ` , an 'array'.
3702
3709
* ` &[T] ` , a 'slice'.
3703
3710
3704
3711
An array has a fixed size, and can be allocated on either the stack or the
@@ -3710,9 +3717,9 @@ to, it borrows it.
3710
3717
An example of each kind:
3711
3718
3712
3719
``` {rust}
3713
- let vec: Vec<int> = vec![1, 2, 3];
3714
- let arr: [int ; 3] = [1, 2, 3];
3715
- let s: &[int] = vec.as_slice();
3720
+ let vec: Vec<i32> = vec![1, 2, 3];
3721
+ let arr: [i32 ; 3] = [1, 2, 3];
3722
+ let s: &[i32] = vec.as_slice();
3716
3723
```
3717
3724
3718
3725
As you can see, the ` vec! ` macro allows you to create a ` Vec<T> ` easily. The
@@ -3798,7 +3805,7 @@ enum List<T> {
3798
3805
Cons(T, Box<List<T>>)
3799
3806
}
3800
3807
3801
- let a: List<int > = List::Cons(7, Box::new(List::Cons(13, Box::new(List::Nil))));
3808
+ let a: List<i32 > = List::Cons(7, Box::new(List::Cons(13, Box::new(List::Nil))));
3802
3809
```
3803
3810
3804
3811
### Pointer types
0 commit comments