@@ -338,12 +338,16 @@ type of the literal. The integer suffix must be the name of one of the
338
338
integral types: ` u8 ` , ` i8 ` , ` u16 ` , ` i16 ` , ` u32 ` , ` i32 ` , ` u64 ` , ` i64 ` ,
339
339
` isize ` , or ` usize ` .
340
340
341
- The type of an _ unsuffixed_ integer literal is determined by type inference.
342
- If an integer type can be _ uniquely_ determined from the surrounding program
343
- context, the unsuffixed integer literal has that type. If the program context
344
- underconstrains the type, it defaults to the signed 32-bit integer ` i32 ` ; if
345
- the program context overconstrains the type, it is considered a static type
346
- error.
341
+ The type of an _ unsuffixed_ integer literal is determined by type inference:
342
+
343
+ * If an integer type can be _ uniquely_ determined from the surrounding
344
+ program context, the unsuffixed integer literal has that type.
345
+
346
+ * If the program context underconstrains the type, it defaults to the
347
+ signed 32-bit integer ` i32 ` .
348
+
349
+ * If the program context overconstrains the type, it is considered a
350
+ static type error.
347
351
348
352
Examples of integer literals of various forms:
349
353
@@ -371,12 +375,17 @@ The suffix forcibly sets the type of the literal. There are two valid
371
375
_ floating-point suffixes_ , ` f32 ` and ` f64 ` (the 32-bit and 64-bit floating point
372
376
types), which explicitly determine the type of the literal.
373
377
374
- The type of an _ unsuffixed_ floating-point literal is determined by type
375
- inference. If a floating-point type can be _ uniquely_ determined from the
376
- surrounding program context, the unsuffixed floating-point literal has that type.
377
- If the program context underconstrains the type, it defaults to double-precision ` f64 ` ;
378
- if the program context overconstrains the type, it is considered a static type
379
- error.
378
+ The type of an _ unsuffixed_ floating-point literal is determined by
379
+ type inference:
380
+
381
+ * If a floating-point type can be _ uniquely_ determined from the
382
+ surrounding program context, the unsuffixed floating-point literal
383
+ has that type.
384
+
385
+ * If the program context underconstrains the type, it defaults to ` f64 ` .
386
+
387
+ * If the program context overconstrains the type, it is considered a
388
+ static type error.
380
389
381
390
Examples of floating-point literals of various forms:
382
391
@@ -2963,14 +2972,12 @@ move values (depending on their type) from the environment into the lambda
2963
2972
expression's captured environment.
2964
2973
2965
2974
In this example, we define a function ` ten_times ` that takes a higher-order
2966
- function argument, and call it with a lambda expression as an argument:
2975
+ function argument, and we then call it with a lambda expression as an argument:
2967
2976
2968
2977
```
2969
2978
fn ten_times<F>(f: F) where F: Fn(i32) {
2970
- let mut i = 0i32;
2971
- while i < 10 {
2972
- f(i);
2973
- i += 1;
2979
+ for index in 0..10 {
2980
+ f(index);
2974
2981
}
2975
2982
}
2976
2983
@@ -3319,10 +3326,13 @@ An example of a tuple type and its use:
3319
3326
3320
3327
```
3321
3328
type Pair<'a> = (i32, &'a str);
3322
- let p: Pair<'static> = (10, "hello ");
3329
+ let p: Pair<'static> = (10, "ten ");
3323
3330
let (a, b) = p;
3324
- assert!(b != "world");
3325
- assert!(p.0 == 10);
3331
+
3332
+ assert_eq!(a, 10);
3333
+ assert_eq!(b, "ten");
3334
+ assert_eq!(p.0, 10);
3335
+ assert_eq!(p.1, "ten");
3326
3336
```
3327
3337
3328
3338
For historical reasons and convenience, the tuple type with no elements (` () ` )
@@ -3332,8 +3342,8 @@ is often called ‘unit’ or ‘the unit type’.
3332
3342
3333
3343
Rust has two different types for a list of items:
3334
3344
3335
- * ` [T; N] ` , an 'array'.
3336
- * ` &[T] ` , a 'slice'.
3345
+ * ` [T; N] ` , an 'array'
3346
+ * ` &[T] ` , a 'slice'
3337
3347
3338
3348
An array has a fixed size, and can be allocated on either the stack or the
3339
3349
heap.
@@ -3486,7 +3496,7 @@ x = bo(5,7);
3486
3496
3487
3497
#### Function types for specific items
3488
3498
3489
- Internally to the compiler, there are also function types that are specific to a particular
3499
+ Internal to the compiler, there are also function types that are specific to a particular
3490
3500
function item. In the following snippet, for example, the internal types of the functions
3491
3501
` foo ` and ` bar ` are different, despite the fact that they have the same signature:
3492
3502
@@ -3643,7 +3653,7 @@ Coercions are defined in [RFC401]. A coercion is implicit and has no syntax.
3643
3653
### Coercion sites
3644
3654
3645
3655
A coercion can only occur at certain coercion sites in a program; these are
3646
- typically places where the desired type is explicit or can be dervied by
3656
+ typically places where the desired type is explicit or can be derived by
3647
3657
propagation from explicit types (without type inference). Possible coercion
3648
3658
sites are:
3649
3659
0 commit comments