@@ -268,7 +268,7 @@ cases mentioned in [Number literals](#number-literals) below.
268
268
##### Suffixes
269
269
| Integer | Floating-point |
270
270
| ---------| ----------------|
271
- | ` is ` ( ` isize ` ) , ` us ` ( ` usize ` ) , ` u8 ` , ` i8 ` , ` u16 ` , ` i16 ` , ` u32 ` , ` i32 ` , ` u64 ` , ` i64 ` | ` f32 ` , ` f64 ` |
271
+ | ` u8 ` , ` i8 ` , ` u16 ` , ` i16 ` , ` u32 ` , ` i32 ` , ` u64 ` , ` i64 ` , ` is ` ( ` isize ` ) , ` us ` ( ` usize ` ) | ` f32 ` , ` f64 ` |
272
272
273
273
#### Character and string literals
274
274
@@ -468,27 +468,29 @@ Like any literal, an integer literal may be followed (immediately,
468
468
without any spaces) by an _ integer suffix_ , which forcibly sets the
469
469
type of the literal. There are 10 valid values for an integer suffix:
470
470
471
- * The ` is ` and ` us ` suffixes give the literal type ` isize ` or ` usize ` ,
472
- respectively.
473
471
* Each of the signed and unsigned machine types ` u8 ` , ` i8 ` ,
474
472
` u16 ` , ` i16 ` , ` u32 ` , ` i32 ` , ` u64 ` and ` i64 `
475
473
give the literal the corresponding machine type.
474
+ * The ` is ` and ` us ` suffixes give the literal type ` isize ` or ` usize ` ,
475
+ respectively.
476
476
477
477
The type of an _ unsuffixed_ integer literal is determined by type inference.
478
478
If an integer type can be _ uniquely_ determined from the surrounding program
479
479
context, the unsuffixed integer literal has that type. If the program context
480
- underconstrains the type, it is considered a static type error; if the program
481
- context overconstrains the type, it is also considered a static type error.
480
+ underconstrains the type, it defaults to the signed 32-bit integer ` i32 ` ; if
481
+ the program context overconstrains the type, it is considered a static type
482
+ error.
482
483
483
484
Examples of integer literals of various forms:
484
485
485
486
```
486
- 123is ; // type isize
487
- 123us ; // type usize
488
- 123_us ; // type usize
487
+ 123i32 ; // type i32
488
+ 123u32 ; // type u32
489
+ 123_u32 ; // type u32
489
490
0xff_u8; // type u8
490
491
0o70_i16; // type i16
491
492
0b1111_1111_1001_0000_i32; // type i32
493
+ 0us; // type usize
492
494
```
493
495
494
496
##### Floating-point literals
@@ -1135,8 +1137,8 @@ used as a type name.
1135
1137
1136
1138
When a generic function is referenced, its type is instantiated based on the
1137
1139
context of the reference. For example, calling the ` iter ` function defined
1138
- above on ` [1, 2] ` will instantiate type parameter ` T ` with ` isize ` , and require
1139
- the closure parameter to have type ` fn(isize ) ` .
1140
+ above on ` [1, 2] ` will instantiate type parameter ` T ` with ` i32 ` , and require
1141
+ the closure parameter to have type ` fn(i32 ) ` .
1140
1142
1141
1143
The type parameters can also be explicitly supplied in a trailing
1142
1144
[ path] ( #paths ) component after the function name. This might be necessary if
@@ -2746,9 +2748,9 @@ constant expression that can be evaluated at compile time, such as a
2746
2748
[ literal] ( #literals ) or a [ static item] ( #static-items ) .
2747
2749
2748
2750
```
2749
- [1is , 2, 3, 4];
2751
+ [1 , 2, 3, 4];
2750
2752
["a", "b", "c", "d"];
2751
- [0is ; 128]; // array with 128 zeros
2753
+ [0 ; 128]; // array with 128 zeros
2752
2754
[0u8, 0u8, 0u8, 0u8];
2753
2755
```
2754
2756
@@ -2921,7 +2923,7 @@ moves](#moved-and-copied-types) its right-hand operand to its left-hand
2921
2923
operand.
2922
2924
2923
2925
```
2924
- # let mut x = 0is ;
2926
+ # let mut x = 0 ;
2925
2927
# let y = 0;
2926
2928
2927
2929
x = y;
@@ -3307,11 +3309,11 @@ fn main() {
3307
3309
```
3308
3310
3309
3311
Patterns can also dereference pointers by using the ` & ` , ` &mut ` and ` box `
3310
- symbols, as appropriate. For example, these two matches on ` x: &isize ` are
3312
+ symbols, as appropriate. For example, these two matches on ` x: &i32 ` are
3311
3313
equivalent:
3312
3314
3313
3315
```
3314
- # let x = &3is ;
3316
+ # let x = &3 ;
3315
3317
let y = match *x { 0 => "zero", _ => "some" };
3316
3318
let z = match x { &0 => "zero", _ => "some" };
3317
3319
@@ -3332,7 +3334,7 @@ Multiple match patterns may be joined with the `|` operator. A range of values
3332
3334
may be specified with ` ... ` . For example:
3333
3335
3334
3336
```
3335
- # let x = 2is ;
3337
+ # let x = 2 ;
3336
3338
3337
3339
let message = match x {
3338
3340
0 | 1 => "not many",
@@ -3673,16 +3675,16 @@ The type of a closure mapping an input of type `A` to an output of type `B` is
3673
3675
An example of creating and calling a closure:
3674
3676
3675
3677
``` rust
3676
- let captured_var = 10is ;
3678
+ let captured_var = 10 ;
3677
3679
3678
3680
let closure_no_args = | & : | println! (" captured_var={}" , captured_var );
3679
3681
3680
- let closure_args = | & : arg : isize | -> isize {
3682
+ let closure_args = | & : arg : i32 | -> i32 {
3681
3683
println! (" captured_var={}, arg={}" , captured_var , arg );
3682
3684
arg // Note lack of semicolon after 'arg'
3683
3685
};
3684
3686
3685
- fn call_closure <F : Fn (), G : Fn (isize ) -> isize >(c1 : F , c2 : G ) {
3687
+ fn call_closure <F : Fn (), G : Fn (i32 ) -> i32 >(c1 : F , c2 : G ) {
3686
3688
c1 ();
3687
3689
c2 (2 );
3688
3690
}
@@ -3714,7 +3716,7 @@ trait Printable {
3714
3716
fn stringify(&self) -> String;
3715
3717
}
3716
3718
3717
- impl Printable for isize {
3719
+ impl Printable for i32 {
3718
3720
fn stringify(&self) -> String { self.to_string() }
3719
3721
}
3720
3722
@@ -3723,7 +3725,7 @@ fn print(a: Box<Printable>) {
3723
3725
}
3724
3726
3725
3727
fn main() {
3726
- print(Box::new(10is ) as Box<Printable>);
3728
+ print(Box::new(10 ) as Box<Printable>);
3727
3729
}
3728
3730
```
3729
3731
0 commit comments