Skip to content

Commit ae5cc0a

Browse files
committed
Merge pull request #596 from spastorino/generics_name_in_example
GenTup is not a tuple so name it as GenVal
2 parents 7009d67 + 765e95c commit ae5cc0a

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

examples/generics/impl/impl.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
struct Tup (f64,);
2-
struct GenTup<T>(T,);
1+
struct Val (f64,);
2+
struct GenVal<T>(T,);
33

4-
// impl of Tup
5-
impl Tup {
4+
// impl of Val
5+
impl Val {
66
fn value(&self) -> &f64 { &self.0 }
77
}
88

9-
// impl of GenTup for a generic type `T`
10-
impl <T> GenTup<T> {
9+
// impl of GenVal for a generic type `T`
10+
impl <T> GenVal<T> {
1111
fn value(&self) -> &T { &self.0 }
1212
}
1313

1414
fn main() {
15-
let x = Tup(3.0);
16-
let y = GenTup(3i32);
15+
let x = Val(3.0);
16+
let y = GenVal(3i32);
1717

1818
println!("{}, {}", x.value(), y.value());
1919
}

examples/generics/impl/input.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ Similar to functions, implementations require care to remain generic.
22

33
```rust
44
struct S; // A null struct
5-
struct GenericTup<T>(T,);
5+
struct GenericVal<T>(T,);
66

7-
// impl of GenericTup we specifically specialize:
8-
impl GenericTup<f32> {} // Specialize to `f32`
9-
impl GenericTup<S> {} // Specialize to `S` defined above
7+
// impl of GenericVal we specifically specialize:
8+
impl GenericVal<f32> {} // Specialize to `f32`
9+
impl GenericVal<S> {} // Specialize to `S` defined above
1010

1111
// `<T>` Must precede the type to remain generic
12-
impl <T> GenericTup<T> {}
12+
impl <T> GenericVal<T> {}
1313
```
1414

1515
Note: Rust does not *currently* allow overlap between implementations. The

0 commit comments

Comments
 (0)