Skip to content

Commit ccf88d8

Browse files
committed
---
yaml --- r: 49569 b: refs/heads/master c: 5b10f4e h: refs/heads/master i: 49567: 82b04cb v: v3
1 parent a709694 commit ccf88d8

File tree

3 files changed

+34
-5
lines changed

3 files changed

+34
-5
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 51eb7dc8a719f6ae05a563109b3bbccee319263e
2+
refs/heads/master: 5b10f4e117479afbf1cd69e471e4a63995187db5
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: f7a2371c176663d59062ec5158f39faecba45768
55
refs/heads/try: 2a8fb58d79e685d5ca07b039badcf2ae3ef077ea

trunk/RELEASES.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,6 @@ Version 0.6 (March 2013)
4141
* Pattern matching over vectors improved and expanded
4242
* `const` renamed to `static` to correspond to lifetime name,
4343
and make room for future `static mut` unsafe mutable globals.
44-
* Replaced `#[deriving_eq]` with `#[deriving(Eq)]`
45-
* `Clone` implementations can be automatically generated with
46-
`#[deriving(Clone)]`
4744

4845
* Semantic changes
4946
* Types with owned pointers or custom destructors move by default,

trunk/doc/rust.md

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1671,6 +1671,12 @@ vec_elems : [expr [',' expr]*] | [expr ',' ".." expr]
16711671
A [_vector_](#vector-types) _expression_ is written by enclosing zero or
16721672
more comma-separated expressions of uniform type in square brackets.
16731673

1674+
In the `[expr ',' ".." expr]` form, the expression after the `".."`
1675+
must be an expression form that can be evaluated at compile time, such
1676+
as a [literal](#literals) or a [constant](#constants).
1677+
1678+
<!--- TODO: elaborate the actual subgrammar for constant expressions -->
1679+
16741680
~~~~
16751681
[1, 2, 3, 4];
16761682
["a", "b", "c", "d"];
@@ -2156,6 +2162,19 @@ do f |j| {
21562162
}
21572163
~~~~
21582164

2165+
In this example, both calls to the (binary) function `k` are equivalent:
2166+
2167+
~~~~
2168+
# fn k(x:int, f: &fn(int)) { }
2169+
# fn l(i: int) { }
2170+
2171+
k(3, |j| l(j));
2172+
2173+
do k(3) |j| {
2174+
l(j);
2175+
}
2176+
~~~~
2177+
21592178

21602179
### For expressions
21612180

@@ -2184,7 +2203,7 @@ and early boolean-valued returns from the `block` function,
21842203
such that the meaning of `break` and `loop` is preserved in a primitive loop
21852204
when rewritten as a `for` loop controlled by a higher order function.
21862205

2187-
An example a for loop:
2206+
An example of a for loop over the contents of a vector:
21882207

21892208
~~~~
21902209
# type foo = int;
@@ -2198,6 +2217,14 @@ for v.each |e| {
21982217
}
21992218
~~~~
22002219

2220+
An example of a for loop over a series of integers:
2221+
2222+
~~~~
2223+
# fn bar(b:uint) { }
2224+
for uint::range(0, 256) |i| {
2225+
bar(i);
2226+
}
2227+
~~~~
22012228

22022229
### If expressions
22032230

@@ -2474,6 +2501,7 @@ fail_unless!(b != "world");
24742501

24752502
The vector type constructor represents a homogeneous array of values of a given type.
24762503
A vector has a fixed size.
2504+
(Operations like `vec::push` operate solely on owned vectors.)
24772505
A vector type can be annotated with a _definite_ size,
24782506
written with a trailing asterisk and integer literal, such as `[int * 10]`.
24792507
Such a definite-sized vector type is a first-class type, since its size is known statically.
@@ -2484,6 +2512,10 @@ such as `&[T]`, `@[T]` or `~[T]`.
24842512
The kind of a vector type depends on the kind of its element type,
24852513
as with other simple structural types.
24862514

2515+
Expressions producing vectors of definite size cannot be evaluated in a
2516+
context expecting a vector of indefinite size; one must copy the
2517+
definite-sized vector contents into a distinct vector of indefinite size.
2518+
24872519
An example of a vector type and its use:
24882520

24892521
~~~~

0 commit comments

Comments
 (0)