mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-26 07:25:48 +00:00
Fallout: docs, elided examples often elided too much.
This commit is contained in:
parent
d801a4da7c
commit
ef42c2befd
@ -576,7 +576,7 @@ the final namespace qualifier is omitted.
|
|||||||
Two examples of paths with type arguments:
|
Two examples of paths with type arguments:
|
||||||
|
|
||||||
```
|
```
|
||||||
# struct HashMap<K, V>;
|
# struct HashMap<K, V>(K,V);
|
||||||
# fn f() {
|
# fn f() {
|
||||||
# fn id<T>(t: T) -> T { t }
|
# fn id<T>(t: T) -> T { t }
|
||||||
type T = HashMap<i32,String>; // Type arguments used in a type expression
|
type T = HashMap<i32,String>; // Type arguments used in a type expression
|
||||||
@ -1603,7 +1603,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 is in scope) to pointers to the trait name, used as a type.
|
||||||
|
|
||||||
```
|
```
|
||||||
# trait Shape { }
|
# trait Shape { fn dummy(&self) { } }
|
||||||
# impl Shape for i32 { }
|
# impl Shape for i32 { }
|
||||||
# let mycircle = 0i32;
|
# let mycircle = 0i32;
|
||||||
let myshape: Box<Shape> = Box::new(mycircle) as Box<Shape>;
|
let myshape: Box<Shape> = Box::new(mycircle) as Box<Shape>;
|
||||||
@ -1634,8 +1634,8 @@ let x: f64 = Num::from_i32(42);
|
|||||||
Traits may inherit from other traits. For example, in
|
Traits may inherit from other traits. For example, in
|
||||||
|
|
||||||
```
|
```
|
||||||
trait Shape { fn area() -> f64; }
|
trait Shape { fn area(&self) -> f64; }
|
||||||
trait Circle : Shape { fn radius() -> f64; }
|
trait Circle : Shape { fn radius(&self) -> f64; }
|
||||||
```
|
```
|
||||||
|
|
||||||
the syntax `Circle : Shape` means that types that implement `Circle` must also
|
the syntax `Circle : Shape` means that types that implement `Circle` must also
|
||||||
@ -1729,7 +1729,7 @@ type parameters taken by the trait it implements. Implementation parameters
|
|||||||
are written after the `impl` keyword.
|
are written after the `impl` keyword.
|
||||||
|
|
||||||
```
|
```
|
||||||
# trait Seq<T> { }
|
# trait Seq<T> { fn dummy(&self, _: T) { } }
|
||||||
impl<T> Seq<T> for Vec<T> {
|
impl<T> Seq<T> for Vec<T> {
|
||||||
/* ... */
|
/* ... */
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user