@@ -75,7 +75,7 @@ pattern-matching or by using `N` directly as a field to access the
75
75
76
76
An example of a tuple type and its use:
77
77
78
- ```
78
+ ``` rust
79
79
type Pair <'a > = (i32 , & 'a str );
80
80
let p : Pair <'static > = (10 , " ten" );
81
81
let (a , b ) = p ;
@@ -104,7 +104,7 @@ to, it borrows it.
104
104
105
105
Examples:
106
106
107
- ``` { rust}
107
+ ``` rust
108
108
// A stack-allocated array
109
109
let array : [i32 ; 3 ] = [1 , 2 , 3 ];
110
110
@@ -191,7 +191,7 @@ enclosing `enum` or `struct` type itself. Such recursion has restrictions:
191
191
192
192
An example of a * recursive* type and its use:
193
193
194
- ```
194
+ ``` rust
195
195
enum List <T > {
196
196
Nil ,
197
197
Cons (T , Box <List <T >>)
@@ -238,7 +238,7 @@ or `extern`), a sequence of input types and an output type.
238
238
239
239
An example of a ` fn ` type:
240
240
241
- ```
241
+ ``` rust
242
242
fn add (x : i32 , y : i32 ) -> i32 {
243
243
x + y
244
244
}
@@ -256,7 +256,7 @@ Internal to the compiler, there are also function types that are specific to a p
256
256
function item. In the following snippet, for example, the internal types of the functions
257
257
` foo ` and ` bar ` are different, despite the fact that they have the same signature:
258
258
259
- ```
259
+ ``` rust
260
260
fn foo () { }
261
261
fn bar () { }
262
262
```
@@ -319,7 +319,7 @@ implementation of `R`, and the pointer value of `E`.
319
319
320
320
An example of a trait object:
321
321
322
- ```
322
+ ``` rust
323
323
trait Printable {
324
324
fn stringify (& self ) -> String ;
325
325
}
@@ -345,7 +345,7 @@ type signature of `print`, and the cast expression in `main`.
345
345
Within the body of an item that has type parameter declarations, the names of
346
346
its type parameters are types:
347
347
348
- ``` ignore
348
+ ``` rust, ignore
349
349
fn to_vec<A: Clone>(xs: &[A]) -> Vec<A> {
350
350
if xs.is_empty() {
351
351
return vec![];
@@ -366,7 +366,7 @@ The special type `Self` has a meaning within traits and impls. In a trait defini
366
366
to an implicit type parameter representing the "implementing" type. In an impl,
367
367
it is an alias for the implementing type. For example, in:
368
368
369
- ```
369
+ ``` rust
370
370
pub trait From <T > {
371
371
fn from (T ) -> Self ;
372
372
}
@@ -381,7 +381,7 @@ impl From<i32> for String {
381
381
The notation ` Self ` in the impl refers to the implementing type: ` String ` . In another
382
382
example:
383
383
384
- ```
384
+ ``` rust
385
385
trait Printable {
386
386
fn make_string (& self ) -> String ;
387
387
}
0 commit comments