Skip to content

Commit 4703db5

Browse files
committed
---
yaml --- r: 138913 b: refs/heads/try2 c: 80c71c8 h: refs/heads/master i: 138911: adf739b v: v3
1 parent 1079d43 commit 4703db5

File tree

296 files changed

+2277
-2448
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

296 files changed

+2277
-2448
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: f4dba956ecec4667e6153691a6245dbac4a5f072
8+
refs/heads/try2: 80c71c839acde882e53ee9505a05b81e4af33ab7
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/doc/rust.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -889,10 +889,10 @@ declared, in an angle-bracket-enclosed, comma-separated list following
889889
the function name.
890890

891891
~~~~ {.xfail-test}
892-
fn iter<T>(seq: &[T], f: &fn(T)) {
892+
fn iter<T>(seq: &[T], f: fn(T)) {
893893
for seq.each |elt| { f(elt); }
894894
}
895-
fn map<T, U>(seq: &[T], f: &fn(T) -> U) -> ~[U] {
895+
fn map<T, U>(seq: &[T], f: fn(T) -> U) -> ~[U] {
896896
let mut acc = ~[];
897897
for seq.each |elt| { acc.push(f(elt)); }
898898
acc
@@ -1198,7 +1198,7 @@ These appear after the trait name, using the same syntax used in [generic functi
11981198
trait Seq<T> {
11991199
fn len() -> uint;
12001200
fn elt_at(n: uint) -> T;
1201-
fn iter(&fn(T));
1201+
fn iter(fn(T));
12021202
}
12031203
~~~~
12041204

@@ -2074,7 +2074,7 @@ and moving values from the environment into the lambda expression's captured env
20742074
An example of a lambda expression:
20752075

20762076
~~~~
2077-
fn ten_times(f: &fn(int)) {
2077+
fn ten_times(f: fn(int)) {
20782078
let mut i = 0;
20792079
while i < 10 {
20802080
f(i);
@@ -2177,7 +2177,7 @@ If the `expr` is a [field expression](#field-expressions), it is parsed as thoug
21772177
In this example, both calls to `f` are equivalent:
21782178

21792179
~~~~
2180-
# fn f(f: &fn(int)) { }
2180+
# fn f(f: fn(int)) { }
21812181
# fn g(i: int) { }
21822182
21832183
f(|j| g(j));
@@ -2755,7 +2755,7 @@ and the cast expression in `main`.
27552755
Within the body of an item that has type parameter declarations, the names of its type parameters are types:
27562756

27572757
~~~~~~~
2758-
fn map<A: Copy, B: Copy>(f: &fn(A) -> B, xs: &[A]) -> ~[B] {
2758+
fn map<A: Copy, B: Copy>(f: fn(A) -> B, xs: &[A]) -> ~[B] {
27592759
if xs.len() == 0 { return ~[]; }
27602760
let first: B = f(xs[0]);
27612761
let rest: ~[B] = map(f, xs.slice(1, xs.len()));

branches/try2/doc/tutorial.md

Lines changed: 53 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -681,6 +681,45 @@ the value of `North` is 0, `East` is 1, `South` is 2, and `West` is 3.
681681
When an enum is C-like, you can apply the `as` cast operator to
682682
convert it to its discriminator value as an `int`.
683683

684+
<a name="single_variant_enum"></a>
685+
686+
There is a special case for enums with a single variant, which are
687+
sometimes called "newtype-style enums" (after Haskell's "newtype"
688+
feature). These are used to define new types in such a way that the
689+
new name is not just a synonym for an existing type, but its own
690+
distinct type: `type` creates a structural synonym, while this form of
691+
`enum` creates a nominal synonym. If you say:
692+
693+
~~~~
694+
enum GizmoId = int;
695+
~~~~
696+
697+
That is a shorthand for this:
698+
699+
~~~~
700+
enum GizmoId { GizmoId(int) }
701+
~~~~
702+
703+
You can extract the contents of such an enum type with the
704+
dereference (`*`) unary operator:
705+
706+
~~~~
707+
# enum GizmoId = int;
708+
let my_gizmo_id: GizmoId = GizmoId(10);
709+
let id_int: int = *my_gizmo_id;
710+
~~~~
711+
712+
Types like this can be useful to differentiate between data that have
713+
the same type but must be used in different ways.
714+
715+
~~~~
716+
enum Inches = int;
717+
enum Centimeters = int;
718+
~~~~
719+
720+
The above definitions allow for a simple way for programs to avoid
721+
confusing numbers that correspond to different units.
722+
684723
For enum types with multiple variants, destructuring is the only way to
685724
get at their contents. All variant constructors can be used as
686725
patterns, as in this definition of `area`:
@@ -750,10 +789,10 @@ match mytup {
750789

751790
## Tuple structs
752791

753-
Rust also has _tuple structs_, which behave like both structs and tuples,
754-
except that, unlike tuples, tuple structs have names (so `Foo(1, 2)` has a
755-
different type from `Bar(1, 2)`), and tuple structs' _fields_ do not have
756-
names.
792+
Rust also has _nominal tuples_, which behave like both structs and tuples,
793+
except that nominal tuple types have names
794+
(so `Foo(1, 2)` has a different type from `Bar(1, 2)`),
795+
and nominal tuple types' _fields_ do not have names.
757796

758797
For example:
759798
~~~~
@@ -764,37 +803,6 @@ match mytup {
764803
}
765804
~~~~
766805

767-
<a name="newtype"></a>
768-
769-
There is a special case for tuple structs with a single field, which are
770-
sometimes called "newtypes" (after Haskell's "newtype" feature). These are
771-
used to define new types in such a way that the new name is not just a
772-
synonym for an existing type but is rather its own distinct type.
773-
774-
~~~~
775-
struct GizmoId(int);
776-
~~~~
777-
778-
For convenience, you can extract the contents of such a struct with the
779-
dereference (`*`) unary operator:
780-
781-
~~~~
782-
# struct GizmoId(int);
783-
let my_gizmo_id: GizmoId = GizmoId(10);
784-
let id_int: int = *my_gizmo_id;
785-
~~~~
786-
787-
Types like this can be useful to differentiate between data that have
788-
the same type but must be used in different ways.
789-
790-
~~~~
791-
struct Inches(int);
792-
struct Centimeters(int);
793-
~~~~
794-
795-
The above definitions allow for a simple way for programs to avoid
796-
confusing numbers that correspond to different units.
797-
798806
# Functions
799807

800808
We've already seen several function definitions. Like all other static
@@ -1361,7 +1369,7 @@ the enclosing scope.
13611369

13621370
~~~~
13631371
# use println = core::io::println;
1364-
fn call_closure_with_ten(b: &fn(int)) { b(10); }
1372+
fn call_closure_with_ten(b: fn(int)) { b(10); }
13651373
13661374
let captured_var = 20;
13671375
let closure = |arg| println(fmt!("captured_var=%d, arg=%d", captured_var, arg));
@@ -1447,7 +1455,7 @@ should almost always declare the type of that argument as `fn()`. That way,
14471455
callers may pass any kind of closure.
14481456

14491457
~~~~
1450-
fn call_twice(f: &fn()) { f(); f(); }
1458+
fn call_twice(f: fn()) { f(); f(); }
14511459
let closure = || { "I'm a closure, and it doesn't matter what type I am"; };
14521460
fn function() { "I'm a normal function"; }
14531461
call_twice(closure);
@@ -1467,7 +1475,7 @@ Consider this function that iterates over a vector of
14671475
integers, passing in a pointer to each integer in the vector:
14681476

14691477
~~~~
1470-
fn each(v: &[int], op: &fn(v: &int)) {
1478+
fn each(v: &[int], op: fn(v: &int)) {
14711479
let mut n = 0;
14721480
while n < v.len() {
14731481
op(&v[n]);
@@ -1488,7 +1496,7 @@ argument, we can write it in a way that has a pleasant, block-like
14881496
structure.
14891497

14901498
~~~~
1491-
# fn each(v: &[int], op: &fn(v: &int)) { }
1499+
# fn each(v: &[int], op: fn(v: &int)) { }
14921500
# fn do_some_work(i: &int) { }
14931501
each([1, 2, 3], |n| {
14941502
do_some_work(n);
@@ -1499,7 +1507,7 @@ This is such a useful pattern that Rust has a special form of function
14991507
call that can be written more like a built-in control structure:
15001508

15011509
~~~~
1502-
# fn each(v: &[int], op: &fn(v: &int)) { }
1510+
# fn each(v: &[int], op: fn(v: &int)) { }
15031511
# fn do_some_work(i: &int) { }
15041512
do each([1, 2, 3]) |n| {
15051513
do_some_work(n);
@@ -1546,7 +1554,7 @@ Consider again our `each` function, this time improved to
15461554
break early when the iteratee returns `false`:
15471555

15481556
~~~~
1549-
fn each(v: &[int], op: &fn(v: &int) -> bool) {
1557+
fn each(v: &[int], op: fn(v: &int) -> bool) {
15501558
let mut n = 0;
15511559
while n < v.len() {
15521560
if !op(&v[n]) {
@@ -1770,7 +1778,7 @@ vector consisting of the result of applying `function` to each element
17701778
of `vector`:
17711779

17721780
~~~~
1773-
fn map<T, U>(vector: &[T], function: &fn(v: &T) -> U) -> ~[U] {
1781+
fn map<T, U>(vector: &[T], function: fn(v: &T) -> U) -> ~[U] {
17741782
let mut accumulator = ~[];
17751783
for vec::each(vector) |element| {
17761784
accumulator.push(function(element));
@@ -1969,12 +1977,12 @@ types might look like the following:
19691977
~~~~
19701978
trait Seq<T> {
19711979
fn len(&self) -> uint;
1972-
fn iter(&self, b: &fn(v: &T));
1980+
fn iter(&self, b: fn(v: &T));
19731981
}
19741982
19751983
impl<T> Seq<T> for ~[T] {
19761984
fn len(&self) -> uint { vec::len(*self) }
1977-
fn iter(&self, b: &fn(v: &T)) {
1985+
fn iter(&self, b: fn(v: &T)) {
19781986
for vec::each(*self) |elt| { b(elt); }
19791987
}
19801988
}
@@ -2286,7 +2294,7 @@ struct level. Note that fields and methods are _public_ by default.
22862294
pub mod farm {
22872295
# pub type Chicken = int;
22882296
# type Cow = int;
2289-
# struct Human(int);
2297+
# enum Human = int;
22902298
# impl Human { fn rest(&self) { } }
22912299
# pub fn make_me_a_farm() -> Farm { Farm { chickens: ~[], cows: ~[], farmer: Human(0) } }
22922300
pub struct Farm {

branches/try2/src/compiletest/header.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ pub fn is_test_ignored(config: config, testfile: &Path) -> bool {
103103
}
104104
}
105105
106-
fn iter_header(testfile: &Path, it: &fn(~str) -> bool) -> bool {
106+
fn iter_header(testfile: &Path, it: fn(~str) -> bool) -> bool {
107107
let rdr = io::file_reader(testfile).get();
108108
while !rdr.eof() {
109109
let ln = rdr.read_line();

branches/try2/src/compiletest/runtest.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ fn compose_and_run(config: config, testfile: &Path,
530530
}
531531

532532
fn make_compile_args(config: config, props: TestProps, extras: ~[~str],
533-
xform: &fn(config, (&Path)) -> Path,
533+
xform: fn(config, (&Path)) -> Path,
534534
testfile: &Path) -> ProcArgs {
535535
let prog = config.rustc_path;
536536
let mut args = ~[testfile.to_str(),

branches/try2/src/etc/emacs/rust-mode.el

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
(require 'cm-mode)
99
(require 'cc-mode)
10-
(eval-when-compile (require 'cl))
1110

1211
(defun rust-electric-brace (arg)
1312
(interactive "*P")

branches/try2/src/etc/kate/rust.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
</list>
1818
<list name="keywords">
1919
<item> as </item>
20+
<item> assert </item>
2021
<item> break </item>
2122
<item> const </item>
2223
<item> copy </item>
@@ -68,7 +69,6 @@
6869
<item> Shl </item>
6970
<item> Shr </item>
7071
<item> Index </item>
71-
<item> Not </item>
7272
</list>
7373
<list name="types">
7474
<item> bool </item>

branches/try2/src/libcore/at_vec.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ pub pure fn capacity<T>(v: @[const T]) -> uint {
6161
*/
6262
#[inline(always)]
6363
pub pure fn build_sized<A>(size: uint,
64-
builder: &fn(push: &pure fn(v: A))) -> @[A] {
64+
builder: &fn(push: pure fn(v: A))) -> @[A] {
6565
let mut vec: @[const A] = @[];
6666
unsafe { raw::reserve(&mut vec, size); }
6767
builder(|+x| unsafe { raw::push(&mut vec, x) });
@@ -79,7 +79,7 @@ pub pure fn build_sized<A>(size: uint,
7979
* onto the vector being constructed.
8080
*/
8181
#[inline(always)]
82-
pub pure fn build<A>(builder: &fn(push: &pure fn(v: A))) -> @[A] {
82+
pub pure fn build<A>(builder: &fn(push: pure fn(v: A))) -> @[A] {
8383
build_sized(4, builder)
8484
}
8585

@@ -97,7 +97,7 @@ pub pure fn build<A>(builder: &fn(push: &pure fn(v: A))) -> @[A] {
9797
*/
9898
#[inline(always)]
9999
pub pure fn build_sized_opt<A>(size: Option<uint>,
100-
builder: &fn(push: &pure fn(v: A))) -> @[A] {
100+
builder: &fn(push: pure fn(v: A))) -> @[A] {
101101
build_sized(size.get_or_default(4), builder)
102102
}
103103

branches/try2/src/libcore/bool.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ pub pure fn to_str(v: bool) -> ~str { if v { ~"true" } else { ~"false" } }
6767
* Iterates over all truth values by passing them to `blk` in an unspecified
6868
* order
6969
*/
70-
pub fn all_values(blk: &fn(v: bool)) {
70+
pub fn all_values(blk: fn(v: bool)) {
7171
blk(true);
7272
blk(false);
7373
}

branches/try2/src/libcore/cell.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ use prelude::*;
1515
///
1616
/// Similar to a mutable option type, but friendlier.
1717
18-
#[deriving_eq]
1918
pub struct Cell<T> {
2019
mut value: Option<T>
2120
}
@@ -55,7 +54,7 @@ pub impl<T> Cell<T> {
5554
}
5655

5756
// Calls a closure with a reference to the value.
58-
fn with_ref<R>(&self, op: &fn(v: &T) -> R) -> R {
57+
fn with_ref<R>(&self, op: fn(v: &T) -> R) -> R {
5958
let v = self.take();
6059
let r = op(&v);
6160
self.put_back(v);

branches/try2/src/libcore/cleanup.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ struct AnnihilateStats {
124124
n_bytes_freed: uint
125125
}
126126

127-
unsafe fn each_live_alloc(f: &fn(box: *mut BoxRepr, uniq: bool) -> bool) {
127+
unsafe fn each_live_alloc(f: fn(box: *mut BoxRepr, uniq: bool) -> bool) {
128128
use managed;
129129

130130
let task: *Task = transmute(rustrt::rust_get_task());

branches/try2/src/libcore/clone.rs

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -19,31 +19,3 @@ impl Clone for () {
1919
#[inline(always)]
2020
fn clone(&self) -> () { () }
2121
}
22-
23-
macro_rules! clone_impl(
24-
($t:ty) => {
25-
impl Clone for $t {
26-
#[inline(always)]
27-
fn clone(&self) -> $t { *self }
28-
}
29-
}
30-
)
31-
32-
clone_impl!(int)
33-
clone_impl!(i8)
34-
clone_impl!(i16)
35-
clone_impl!(i32)
36-
clone_impl!(i64)
37-
38-
clone_impl!(uint)
39-
clone_impl!(u8)
40-
clone_impl!(u16)
41-
clone_impl!(u32)
42-
clone_impl!(u64)
43-
44-
clone_impl!(float)
45-
clone_impl!(f32)
46-
clone_impl!(f64)
47-
48-
clone_impl!(bool)
49-
clone_impl!(char)

0 commit comments

Comments
 (0)