@@ -257,18 +257,18 @@ cases mentioned in [Number literals](#number-literals) below.
257
257
258
258
| [ Number literals] ( #number-literals ) ` * ` | Example | Exponentiation | Suffixes |
259
259
| ----------------------------------------| ---------| ----------------| ----------|
260
- | Decimal integer | ` 98_222i ` | ` N/A ` | Integer suffixes |
261
- | Hex integer | ` 0xffi ` | ` N/A ` | Integer suffixes |
262
- | Octal integer | ` 0o77i ` | ` N/A ` | Integer suffixes |
263
- | Binary integer | ` 0b1111_0000i ` | ` N/A ` | Integer suffixes |
260
+ | Decimal integer | ` 98_222is ` | ` N/A ` | Integer suffixes |
261
+ | Hex integer | ` 0xffis ` | ` N/A ` | Integer suffixes |
262
+ | Octal integer | ` 0o77is ` | ` N/A ` | Integer suffixes |
263
+ | Binary integer | ` 0b1111_0000is ` | ` N/A ` | Integer suffixes |
264
264
| Floating-point | ` 123.0E+77f64 ` | ` Optional ` | Floating-point suffixes |
265
265
266
266
` * ` All number literals allow ` _ ` as a visual separator: ` 1_234.0E+18f64 `
267
267
268
268
##### Suffixes
269
269
| Integer | Floating-point |
270
270
| ---------| ----------------|
271
- | ` i ` (` int ` ), ` u ` (` uint ` ), ` u8 ` , ` i8 ` , ` u16 ` , ` i16 ` , ` u32 ` , ` i32 ` , ` u64 ` , ` i64 ` | ` f32 ` , ` f64 ` |
271
+ | ` is ` (` isize ` ), ` us ` (` usize ` ), ` u8 ` , ` i8 ` , ` u16 ` , ` i16 ` , ` u32 ` , ` i32 ` , ` u64 ` , ` i64 ` | ` f32 ` , ` f64 ` |
272
272
273
273
#### Character and string literals
274
274
@@ -468,7 +468,7 @@ 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 ` i ` and ` u ` suffixes give the literal type ` int ` or ` uint ` ,
471
+ * The ` is ` and ` us ` suffixes give the literal type ` isize ` or ` usize ` ,
472
472
respectively.
473
473
* Each of the signed and unsigned machine types ` u8 ` , ` i8 ` ,
474
474
` u16 ` , ` i16 ` , ` u32 ` , ` i32 ` , ` u64 ` and ` i64 `
@@ -483,9 +483,9 @@ context overconstrains the type, it is also considered a static type error.
483
483
Examples of integer literals of various forms:
484
484
485
485
```
486
- 123i ; // type int
487
- 123u ; // type uint
488
- 123_u; // type uint
486
+ 123is ; // type isize
487
+ 123us ; // type usize
488
+ 123_us // type usize
489
489
0xff_u8; // type u8
490
490
0o70_i16; // type i16
491
491
0b1111_1111_1001_0000_i32; // type i32
@@ -1002,11 +1002,11 @@ use std::option::Option::{Some, None};
1002
1002
use std::collections::hash_map::{mod, HashMap};
1003
1003
1004
1004
fn foo<T>(_: T){}
1005
- fn bar(map1: HashMap<String, uint >, map2: hash_map::HashMap<String, uint >){}
1005
+ fn bar(map1: HashMap<String, usize >, map2: hash_map::HashMap<String, usize >){}
1006
1006
1007
1007
fn main() {
1008
- // Equivalent to 'std::iter::range_step(0u, 10u, 2u );'
1009
- range_step(0u, 10u, 2u );
1008
+ // Equivalent to 'std::iter::range_step(0us, 10, 2 );'
1009
+ range_step(0us, 10, 2 );
1010
1010
1011
1011
// Equivalent to 'foo(vec![std::option::Option::Some(1.0f64),
1012
1012
// std::option::Option::None]);'
@@ -1611,7 +1611,7 @@ trait is in scope) to pointers to the trait name, used as a type.
1611
1611
```
1612
1612
# trait Shape { }
1613
1613
# impl Shape for int { }
1614
- # let mycircle = 0i ;
1614
+ # let mycircle = 0is ;
1615
1615
let myshape: Box<Shape> = Box::new(mycircle) as Box<Shape>;
1616
1616
```
1617
1617
@@ -2821,7 +2821,7 @@ parentheses. They are used to create [tuple-typed](#tuple-types) values.
2821
2821
``` {.tuple}
2822
2822
(0,);
2823
2823
(0.0, 4.5);
2824
- ("a", 4u , true);
2824
+ ("a", 4us , true);
2825
2825
```
2826
2826
2827
2827
### Unit expressions
@@ -2958,9 +2958,9 @@ constant expression that can be evaluated at compile time, such as a
2958
2958
[ literal] ( #literals ) or a [ static item] ( #static-items ) .
2959
2959
2960
2960
```
2961
- [1i , 2, 3, 4];
2961
+ [1is , 2, 3, 4];
2962
2962
["a", "b", "c", "d"];
2963
- [0i ; 128]; // array with 128 zeros
2963
+ [0is ; 128]; // array with 128 zeros
2964
2964
[0u8, 0u8, 0u8, 0u8];
2965
2965
```
2966
2966
@@ -3133,7 +3133,7 @@ moves](#moved-and-copied-types) its right-hand operand to its left-hand
3133
3133
operand.
3134
3134
3135
3135
```
3136
- # let mut x = 0i ;
3136
+ # let mut x = 0is ;
3137
3137
# let y = 0;
3138
3138
3139
3139
x = y;
@@ -3270,7 +3270,7 @@ conditional expression evaluates to `false`, the `while` expression completes.
3270
3270
An example:
3271
3271
3272
3272
```
3273
- let mut i = 0u ;
3273
+ let mut i = 0us ;
3274
3274
3275
3275
while i < 10 {
3276
3276
println!("hello");
@@ -3349,8 +3349,8 @@ for e in v.iter() {
3349
3349
An example of a for loop over a series of integers:
3350
3350
3351
3351
```
3352
- # fn bar(b:uint ) { }
3353
- for i in range(0u , 256) {
3352
+ # fn bar(b:usize ) { }
3353
+ for i in range(0us , 256) {
3354
3354
bar(i);
3355
3355
}
3356
3356
```
@@ -3520,11 +3520,11 @@ fn main() {
3520
3520
```
3521
3521
3522
3522
Patterns can also dereference pointers by using the ` & ` , ` &mut ` and ` box `
3523
- symbols, as appropriate. For example, these two matches on ` x: &int ` are
3523
+ symbols, as appropriate. For example, these two matches on ` x: &isize ` are
3524
3524
equivalent:
3525
3525
3526
3526
```
3527
- # let x = &3i ;
3527
+ # let x = &3is ;
3528
3528
let y = match *x { 0 => "zero", _ => "some" };
3529
3529
let z = match x { &0 => "zero", _ => "some" };
3530
3530
@@ -3545,7 +3545,7 @@ Multiple match patterns may be joined with the `|` operator. A range of values
3545
3545
may be specified with ` ... ` . For example:
3546
3546
3547
3547
```
3548
- # let x = 2i ;
3548
+ # let x = 2is ;
3549
3549
3550
3550
let message = match x {
3551
3551
0 | 1 => "not many",
@@ -3886,16 +3886,16 @@ The type of a closure mapping an input of type `A` to an output of type `B` is
3886
3886
An example of creating and calling a closure:
3887
3887
3888
3888
``` rust
3889
- let captured_var = 10i ;
3889
+ let captured_var = 10is ;
3890
3890
3891
3891
let closure_no_args = | & : | println! (" captured_var={}" , captured_var );
3892
3892
3893
- let closure_args = | & : arg : int | -> int {
3893
+ let closure_args = | & : arg : isize | -> isize {
3894
3894
println! (" captured_var={}, arg={}" , captured_var , arg );
3895
3895
arg // Note lack of semicolon after 'arg'
3896
3896
};
3897
3897
3898
- fn call_closure <F : Fn (), G : Fn (int ) -> int >(c1 : F , c2 : G ) {
3898
+ fn call_closure <F : Fn (), G : Fn (isize ) -> isize >(c1 : F , c2 : G ) {
3899
3899
c1 ();
3900
3900
c2 (2 );
3901
3901
}
@@ -3927,7 +3927,7 @@ trait Printable {
3927
3927
fn stringify(&self) -> String;
3928
3928
}
3929
3929
3930
- impl Printable for int {
3930
+ impl Printable for isize {
3931
3931
fn stringify(&self) -> String { self.to_string() }
3932
3932
}
3933
3933
@@ -3936,7 +3936,7 @@ fn print(a: Box<Printable>) {
3936
3936
}
3937
3937
3938
3938
fn main() {
3939
- print(Box::new(10i ) as Box<Printable>);
3939
+ print(Box::new(10is ) as Box<Printable>);
3940
3940
}
3941
3941
```
3942
3942
0 commit comments