Skip to content

Commit e4adb5f

Browse files
Jorge AparicioManishearth
authored andcommitted
unignore and fix doctests in guide and reference
1 parent 568ff2e commit e4adb5f

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

reference.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1559,11 +1559,11 @@ Type parameters can be specified for a trait to make it generic. These appear
15591559
after the trait name, using the same syntax used in [generic
15601560
functions](#generic-functions).
15611561

1562-
``` ignore
1562+
```
15631563
trait Seq<T> {
15641564
fn len(&self) -> uint;
15651565
fn elt_at(&self, n: uint) -> T;
1566-
fn iter(&self, |T|);
1566+
fn iter<F>(&self, F) where F: Fn(T);
15671567
}
15681568
```
15691569

@@ -3217,8 +3217,8 @@ expression's captured environment.
32173217
In this example, we define a function `ten_times` that takes a higher-order
32183218
function argument, and call it with a lambda expression as an argument.
32193219

3220-
``` ignore
3221-
fn ten_times(f: |int|) {
3220+
```
3221+
fn ten_times<F>(f: F) where F: Fn(int) {
32223222
let mut i = 0;
32233223
while i < 10 {
32243224
f(i);
@@ -3821,14 +3821,14 @@ or `extern`), a sequence of input types and an output type.
38213821

38223822
An example of a `fn` type:
38233823

3824-
``` ignore
3824+
```
38253825
fn add(x: int, y: int) -> int {
38263826
return x + y;
38273827
}
38283828
38293829
let mut x = add(5,7);
38303830
3831-
type Binop<'a> = |int,int|: 'a -> int;
3831+
type Binop = fn(int, int) -> int;
38323832
let bo: Binop = add;
38333833
x = bo(5,7);
38343834
```
@@ -3849,17 +3849,17 @@ The type of a closure mapping an input of type `A` to an output of type `B` is
38493849

38503850
An example of creating and calling a closure:
38513851

3852-
``` ignore
3852+
```rust
38533853
let captured_var = 10i;
38543854

3855-
let closure_no_args = || println!("captured_var={}", captured_var);
3855+
let closure_no_args = |&:| println!("captured_var={}", captured_var);
38563856

3857-
let closure_args = |arg: int| -> int {
3857+
let closure_args = |&: arg: int| -> int {
38583858
println!("captured_var={}, arg={}", captured_var, arg);
38593859
arg // Note lack of semicolon after 'arg'
38603860
};
38613861

3862-
fn call_closure(c1: ||, c2: |int| -> int) {
3862+
fn call_closure<F: Fn(), G: Fn(int) -> int>(c1: F, c2: G) {
38633863
c1();
38643864
c2(2);
38653865
}

0 commit comments

Comments
 (0)