File tree Expand file tree Collapse file tree 2 files changed +7
-7
lines changed Expand file tree Collapse file tree 2 files changed +7
-7
lines changed Original file line number Diff line number Diff line change 2
2
refs/heads/master: 09bb07bed9166105ea961a42b5fff7739ae0d2e9
3
3
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4
4
refs/heads/snap-stage3: eb8fd119c65c67f3b1b8268cc7341c22d39b7b61
5
- refs/heads/try: 4b3dd4b9204171d0777749eaf1053fa240be24ec
5
+ refs/heads/try: 4be7310be0a2f35a5a73825b0718aa643c740c8b
6
6
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
7
7
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8
8
refs/heads/try2: a810c03263670238bccd64cabb12a23a46e3a278
Original file line number Diff line number Diff line change @@ -733,22 +733,22 @@ fn point_from_direction(dir: Direction) -> Point {
733
733
}
734
734
~~~~
735
735
736
- A special kind of enum variant, called _ struct-like enums_ ,
737
- can have its fields extracted with dot notation and not just destructuring.
738
- For example:
736
+ Enum variants may also be structs. For example:
739
737
740
738
~~~~
741
739
# use core::float;
742
740
# struct Point {x: float, y: float}
743
741
# fn square(x: float) -> float { x * x }
744
742
enum Shape {
745
743
Circle { center: Point, radius: float },
746
- Rectangle { left : Point, right : Point }
744
+ Rectangle { top_left : Point, bottom_right : Point }
747
745
}
748
746
fn area(sh: Shape) -> float {
749
747
match sh {
750
- Circle(c) => float::consts::pi * square(c.radius),
751
- Rectangle(r) => r.right.x - r.left.x * r.right.y - r.right.y
748
+ Circle { radius: radius, _ } => float::consts::pi * square(radius),
749
+ Rectangle { top_left: top_left, bottom_right: bottom_right } => {
750
+ (bottom_right.x - top_left.x) * (bottom_right.y - top_left.y)
751
+ }
752
752
}
753
753
}
754
754
~~~~
You can’t perform that action at this time.
0 commit comments