diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2015-02-18 15:52:01 -0800 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2015-02-18 15:52:01 -0800 |
| commit | 1506b34e0c52b098158541d2ba9e334df1ce4812 (patch) | |
| tree | a9ead87eacaf0acafdb0c4f72c334c2d5601b0ca /src/doc/reference.md | |
| parent | 3e7a04cb3cac2b803dc8188d9a55ba1836404ea3 (diff) | |
| parent | 9f8b9d6847ab02f7f1c28c84988ceae4c0a10f26 (diff) | |
| download | rust-1506b34e0c52b098158541d2ba9e334df1ce4812.tar.gz rust-1506b34e0c52b098158541d2ba9e334df1ce4812.zip | |
rollup merge of #22286: nikomatsakis/variance-4b
Conflicts: src/librustc/middle/infer/combine.rs src/librustc_typeck/check/wf.rs
Diffstat (limited to 'src/doc/reference.md')
| -rw-r--r-- | src/doc/reference.md | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/doc/reference.md b/src/doc/reference.md index 3bbe60a77c9..db940947040 100644 --- a/src/doc/reference.md +++ b/src/doc/reference.md @@ -572,7 +572,7 @@ the final namespace qualifier is omitted. Two examples of paths with type arguments: ``` -# struct HashMap<K, V>; +# struct HashMap<K, V>(K,V); # fn f() { # fn id<T>(t: T) -> T { t } type T = HashMap<i32,String>; // Type arguments used in a type expression @@ -1599,7 +1599,7 @@ pointer values (pointing to a type for which an implementation of the given trait is in scope) to pointers to the trait name, used as a type. ``` -# trait Shape { } +# trait Shape { fn dummy(&self) { } } # impl Shape for i32 { } # let mycircle = 0i32; let myshape: Box<Shape> = Box::new(mycircle) as Box<Shape>; @@ -1630,8 +1630,8 @@ let x: f64 = Num::from_i32(42); Traits may inherit from other traits. For example, in ``` -trait Shape { fn area() -> f64; } -trait Circle : Shape { fn radius() -> f64; } +trait Shape { fn area(&self) -> f64; } +trait Circle : Shape { fn radius(&self) -> f64; } ``` the syntax `Circle : Shape` means that types that implement `Circle` must also @@ -1725,7 +1725,7 @@ type parameters taken by the trait it implements. Implementation parameters are written after the `impl` keyword. ``` -# trait Seq<T> { } +# trait Seq<T> { fn dummy(&self, _: T) { } } impl<T> Seq<T> for Vec<T> { /* ... */ } |
