File tree Expand file tree Collapse file tree 2 files changed +6
-4
lines changed Expand file tree Collapse file tree 2 files changed +6
-4
lines changed Original file line number Diff line number Diff line change 1
1
---
2
- refs/heads/master: 21c9d0858b1ee0c6fe508a9eb1d229713a2649e4
2
+ refs/heads/master: d098faa8555d48a9bc1de34542fc6d1dd5a2ab9c
3
3
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4
4
refs/heads/snap-stage3: eb8fd119c65c67f3b1b8268cc7341c22d39b7b61
5
5
refs/heads/try: d324a424d8f84b1eb049b12cf34182bda91b0024
Original file line number Diff line number Diff line change @@ -2127,15 +2127,15 @@ This usage of traits is similar to Java interfaces.
2127
2127
2128
2128
We can write a trait declaration that _ inherits_ from other traits, called _ supertraits_ .
2129
2129
Types that implement a trait must also implement its supertraits.
2130
-
2131
- For example, we can define a ` Circle ` trait that only types that also have the ` Shape ` trait can have:
2130
+ For example,
2131
+ we can define a ` Circle ` trait that inherits from ` Shape ` .
2132
2132
2133
2133
~~~~
2134
2134
trait Shape { fn area(&self) -> float; }
2135
2135
trait Circle : Shape { fn radius(&self) -> float; }
2136
2136
~~~~
2137
2137
2138
- Now, implementations of ` Circle ` methods can call ` Shape ` methods:
2138
+ Now, we can implement ` Circle ` on a type only if we also implement ` Shape ` .
2139
2139
2140
2140
~~~~
2141
2141
# trait Shape { fn area(&self) -> float; }
@@ -2153,6 +2153,8 @@ impl CircleStruct: Shape {
2153
2153
}
2154
2154
~~~~
2155
2155
2156
+ Notice that methods of ` Circle ` can call methods on ` Shape ` , as our
2157
+ ` radius ` implementation calls the ` area ` method.
2156
2158
This is a silly way to compute the radius of a circle
2157
2159
(since we could just return the ` circle ` field), but you get the idea.
2158
2160
You can’t perform that action at this time.
0 commit comments