@@ -249,7 +249,7 @@ let my_variable = 100;
249
249
type MyType = int; // some built-in types are _not_ camel case
250
250
~~~
251
251
252
- ## Expression syntax
252
+ ## Expressions and semicolons
253
253
254
254
Though it isn't apparent in all code, there is a fundamental
255
255
difference between Rust's syntax and predecessors like C.
@@ -308,12 +308,14 @@ fn is_four(x: int) -> bool {
308
308
}
309
309
~~~~
310
310
311
- ## Literals
311
+ ## Primitive types and literals
312
312
313
+ There are general signed and unsigned integer types, ` int ` , and ` uint ` ,
314
+ as well as 8-, 16-, 32-, and 64-bit variations, ` i8 ` , ` u16 ` , etc.
313
315
Integers can be written in decimal (` 144 ` ), hexadecimal (` 0x90 ` ), or
314
316
binary (` 0b10010000 ` ) base. Each integral type has a corresponding literal
315
317
suffix that can be used to indicate the type of a literal: ` i ` for ` int ` ,
316
- ` u ` for ` uint ` , and ` i8 ` for the ` i8 ` type, etc .
318
+ ` u ` for ` uint ` , ` i8 ` for the ` i8 ` type.
317
319
318
320
In the absence of an integer literal suffix, Rust will infer the
319
321
integer type based on type annotations and function signatures in the
@@ -328,19 +330,21 @@ let c = 100u; // c is a uint
328
330
let d = 1000i32; // d is an i32
329
331
~~~~
330
332
331
- Floating point numbers are written ` 0.0 ` , ` 1e6 ` , or ` 2.1e-4 ` . Without
332
- a suffix, the literal is assumed to be of type ` float ` . Suffixes ` f32 `
333
- (32-bit) and ` f64 ` (64-bit) can be used to create literals of a
334
- specific type.
333
+ There are three floating point types, ` float ` , ` f32 ` , and ` f64 ` .
334
+ Floating point numbers are written ` 0.0 ` , ` 1e6 ` , or ` 2.1e-4 ` .
335
+ Like integers, floating point literals are inferred to the correct type.
336
+ Suffixes ` f ` , ` f32 ` and ` f64 ` can be used to create literals of a specific type.
335
337
336
- The unit literal is written just like the type: ` () ` . The keywords
337
- ` true ` and ` false ` produce the boolean literals.
338
+ The keywords ` true ` and ` false ` produce literals of type ` bool ` .
338
339
339
- Character literals are written between single quotes, as in ` 'x' ` . Just like
340
- C, Rust understands a number of character escapes, using the backslash
340
+ Characters, the ` char ` type, are 4-byte unicode codepoints,
341
+ whose literals are written between single quotes, as in ` 'x' ` .
342
+ Just like C, Rust understands a number of character escapes, using the backslash
341
343
character, such as ` \n ` , ` \r ` , and ` \t ` . String literals,
342
- written between double quotes, allow the same escape sequences. Rust strings
343
- may contain newlines.
344
+ written between double quotes, allow the same escape sequences.
345
+ More on strings [ later] ( #vectors-and-strings ) .
346
+
347
+ The nil type, written ` () ` , has a single value, also written ` () ` .
344
348
345
349
## Operators
346
350
0 commit comments