Skip to content

Commit 0a2d5b3

Browse files
committed
---
yaml --- r: 149045 b: refs/heads/try2 c: e30fd30 h: refs/heads/master i: 149043: bacb7e5 v: v3
1 parent 7b1ca2a commit 0a2d5b3

File tree

4 files changed

+46
-49
lines changed

4 files changed

+46
-49
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 35b4115ef8dc4d78559c492d7251235c17cdb4e7
8+
refs/heads/try2: e30fd3067ee03e8bbd776895b738792fcdac25fc
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/mk/target.mk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ $$(TLIB$(1)_T_$(2)_H_$(3))/stamp.$(4): \
7474
$$(CRATE_FULLDEPS_$(1)_T_$(2)_H_$(3)_$(4)) \
7575
$$(TSREQ$(1)_T_$(2)_H_$(3)) \
7676
| $$(TLIB$(1)_T_$(2)_H_$(3))/
77-
@$$(call E, oxidize: $$(@D)/lib$(4))
77+
@$$(call E, compile_and_link: $$(@D)/lib$(4))
7878
$$(call REMOVE_ALL_OLD_GLOB_MATCHES,\
7979
$$(dir $$@)$$(call CFG_LIB_GLOB_$(2),$(4)))
8080
$$(call REMOVE_ALL_OLD_GLOB_MATCHES,\
@@ -113,7 +113,7 @@ $$(TBIN$(1)_T_$(2)_H_$(3))/$(4)$$(X_$(2)): \
113113
$$(TLIB$(1)_T_$(2)_H_$(3))/stamp.$$(dep)) \
114114
$$(TSREQ$(1)_T_$(2)_H_$(3)) \
115115
| $$(TBIN$(1)_T_$(4)_H_$(3))/
116-
@$$(call E, oxidize: $$@)
116+
@$$(call E, compile_and_link: $$@)
117117
$$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --cfg $(4)
118118

119119
endef

branches/try2/mk/tests.mk

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ $(3)/stage$(1)/test/$(4)test-$(2)$$(X_$(2)): \
347347
$$(CRATEFILE_$(4)) \
348348
$$(CRATE_FULLDEPS_$(1)_T_$(2)_H_$(3)_$(4)) \
349349
$$(STDTESTDEP_$(1)_$(2)_$(3)_$(4))
350-
@$$(call E, oxidize: $$@)
350+
@$$(call E, compile_and_link: $$@)
351351
$$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --test \
352352
-L "$$(RT_OUTPUT_DIR_$(2))" \
353353
-L "$$(LLVM_LIBDIR_$(2))"
@@ -835,15 +835,15 @@ define DEF_CHECK_FAST_FOR_T_H
835835
$$(TLIB2_T_$(2)_H_$(3))/$$(FT_LIB): \
836836
tmp/$$(FT).rc \
837837
$$(SREQ2_T_$(2)_H_$(3))
838-
@$$(call E, oxidize: $$@)
838+
@$$(call E, compile_and_link: $$@)
839839
$$(STAGE2_T_$(2)_H_$(3)) --crate-type=dylib --out-dir $$(@D) $$< \
840840
-L "$$(RT_OUTPUT_DIR_$(2))"
841841

842842
$(3)/test/$$(FT_DRIVER)-$(2)$$(X_$(2)): \
843843
tmp/$$(FT_DRIVER).rs \
844844
$$(TLIB2_T_$(2)_H_$(3))/$$(FT_LIB) \
845845
$$(SREQ2_T_$(2)_H_$(3))
846-
@$$(call E, oxidize: $$@ $$<)
846+
@$$(call E, compile_and_link: $$@ $$<)
847847
$$(STAGE2_T_$(2)_H_$(3)) -o $$@ $$< \
848848
-L "$$(RT_OUTPUT_DIR_$(2))"
849849

branches/try2/src/doc/tutorial.md

Lines changed: 40 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -647,31 +647,8 @@ match mypoint {
647647

648648
## Enums
649649

650-
Enums are datatypes that have several alternate representations. For
651-
example, consider the following type:
652-
653-
~~~~
654-
# struct Point { x: f64, y: f64 }
655-
enum Shape {
656-
Circle(Point, f64),
657-
Rectangle(Point, Point)
658-
}
659-
~~~~
660-
661-
A value of this type is either a `Circle`, in which case it contains a
662-
`Point` struct and a f64, or a `Rectangle`, in which case it contains
663-
two `Point` structs. The run-time representation of such a value
664-
includes an identifier of the actual form that it holds, much like the
665-
"tagged union" pattern in C, but with better static guarantees.
666-
667-
The above declaration will define a type `Shape` that can refer to
668-
such shapes, and two functions, `Circle` and `Rectangle`, which can be
669-
used to construct values of the type (taking arguments of the
670-
specified types). So `Circle(Point { x: 0.0, y: 0.0 }, 10.0)` is the way to
671-
create a new circle.
672-
673-
Enum variants need not have parameters. This `enum` declaration,
674-
for example, is equivalent to a C enum:
650+
Enums are datatypes with several alternate representations. A simple `enum`
651+
defines one or more constants, all of which have the same type:
675652

676653
~~~~
677654
enum Direction {
@@ -682,12 +659,21 @@ enum Direction {
682659
}
683660
~~~~
684661

685-
This declaration defines `North`, `East`, `South`, and `West` as constants,
686-
all of which have type `Direction`.
662+
Each variant of this enum has a unique and constant integral discriminator
663+
value. If no explicit discriminator is specified for a variant, the value
664+
defaults to the value of the previous variant plus one. If the first variant
665+
does not have a discriminator, it defaults to 0. For example, the value of
666+
`North` is 0, `East` is 1, `South` is 2, and `West` is 3.
687667

688-
When an enum is C-like (that is, when none of the variants have
689-
parameters), it is possible to explicitly set the discriminator values
690-
to a constant value:
668+
When an enum has simple integer discriminators, you can apply the `as` cast
669+
operator to convert a variant to its discriminator value as an `int`:
670+
671+
~~~~
672+
# enum Direction { North }
673+
println!( "{:?} => {}", North, North as int );
674+
~~~~
675+
676+
It is possible to set the discriminator values to chosen constant values:
691677

692678
~~~~
693679
enum Color {
@@ -697,17 +683,30 @@ enum Color {
697683
}
698684
~~~~
699685

700-
If an explicit discriminator is not specified for a variant, the value
701-
defaults to the value of the previous variant plus one. If the first
702-
variant does not have a discriminator, it defaults to 0. For example,
703-
the value of `North` is 0, `East` is 1, `South` is 2, and `West` is 3.
686+
Variants do not have to be simple values; they may be more complex:
704687

705-
When an enum is C-like, you can apply the `as` cast operator to
706-
convert it to its discriminator value as an `int`.
688+
~~~~
689+
# struct Point { x: f64, y: f64 }
690+
enum Shape {
691+
Circle(Point, f64),
692+
Rectangle(Point, Point)
693+
}
694+
~~~~
707695

708-
For enum types with multiple variants, destructuring is the only way to
709-
get at their contents. All variant constructors can be used as
710-
patterns, as in this definition of `area`:
696+
A value of this type is either a `Circle`, in which case it contains a
697+
`Point` struct and a f64, or a `Rectangle`, in which case it contains
698+
two `Point` structs. The run-time representation of such a value
699+
includes an identifier of the actual form that it holds, much like the
700+
"tagged union" pattern in C, but with better static guarantees.
701+
702+
This declaration defines a type `Shape` that can refer to such shapes, and two
703+
functions, `Circle` and `Rectangle`, which can be used to construct values of
704+
the type. To create a new Circle, write `Circle(Point { x: 0.0, y: 0.0 },
705+
10.0)`.
706+
707+
All of these variant constructors may be used as patterns. The only way to
708+
access the contents of an enum instance is the destructuring of a match. For
709+
example:
711710

712711
~~~~
713712
use std::f64;
@@ -721,10 +720,8 @@ fn area(sh: Shape) -> f64 {
721720
}
722721
~~~~
723722

724-
You can write a lone `_` to ignore an individual field, and can
725-
ignore all fields of a variant like: `Circle(..)`. As in their
726-
introduction form, nullary enum patterns are written without
727-
parentheses.
723+
Use a lone `_` to ignore an individual field. Ignore all fields of a variant
724+
like: `Circle(..)`. Nullary enum patterns are written without parentheses:
728725

729726
~~~~
730727
# struct Point { x: f64, y: f64 }

0 commit comments

Comments
 (0)