Skip to content

Commit 89783e5

Browse files
committed
---
yaml --- r: 139165 b: refs/heads/try2 c: 5f2d410 h: refs/heads/master i: 139163: e59d43e v: v3
1 parent eddf2aa commit 89783e5

File tree

22 files changed

+385
-556
lines changed

22 files changed

+385
-556
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: 0a47cd5ef183d5a7e763484e211f4b3aed6d72de
8+
refs/heads/try2: 5f2d4102c5dabde915f1f6cb99c38b9274790cda
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/doc/tutorial.md

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -579,21 +579,30 @@ Structs are quite similar to C structs and are even laid out the same way in
579579
memory (so you can read from a Rust struct in C, and vice-versa). Use the dot
580580
operator to access struct fields, as in `mypoint.x`.
581581

582-
Inherited mutability means that any field of a struct may be mutable, if the
583-
struct is in a mutable slot (or a field of a struct in a mutable slot, and
584-
so forth).
585-
586582
~~~~
587-
struct Stack {
588-
content: ~[int],
589-
head: uint
583+
struct Point {
584+
x: float,
585+
y: float
590586
}
591587
~~~~
592588

593-
With a value (say, `mystack`) of such a type in a mutable location, you can do
594-
`mystack.head += 1`. But in an immutable location, such an assignment to a
589+
Inherited mutability means that any field of a struct may be mutable, if the
590+
struct is in a mutable slot (or a field of a struct in a mutable slot, and
591+
so forth).
592+
593+
With a value (say, `mypoint`) of such a type in a mutable location, you can do
594+
`mypoint.y += 1.0`. But in an immutable location, such an assignment to a
595595
struct without inherited mutability would result in a type error.
596596

597+
~~~~ {.xfail-test}
598+
# struct Point { x: float, y: float }
599+
let mut mypoint = Point { x: 1.0, y: 1.0 };
600+
let origin = Point { x: 0.0, y: 0.0 };
601+
602+
mypoint.y += 1.0; // mypoint is mutable, and its fields as well
603+
origin.y += 1.0; // ERROR: assigning to immutable field
604+
~~~~
605+
597606
`match` patterns destructure structs. The basic syntax is
598607
`Name { fieldname: pattern, ... }`:
599608

branches/try2/src/libcore/char.rs

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -288,16 +288,16 @@ fn test_is_whitespace() {
288288

289289
#[test]
290290
fn test_to_digit() {
291-
fail_unless!(to_digit('0', 10u) == Some(0u));
292-
fail_unless!(to_digit('1', 2u) == Some(1u));
293-
fail_unless!(to_digit('2', 3u) == Some(2u));
294-
fail_unless!(to_digit('9', 10u) == Some(9u));
295-
fail_unless!(to_digit('a', 16u) == Some(10u));
296-
fail_unless!(to_digit('A', 16u) == Some(10u));
297-
fail_unless!(to_digit('b', 16u) == Some(11u));
298-
fail_unless!(to_digit('B', 16u) == Some(11u));
299-
fail_unless!(to_digit('z', 36u) == Some(35u));
300-
fail_unless!(to_digit('Z', 36u) == Some(35u));
291+
assert_eq!(to_digit('0', 10u), Some(0u));
292+
assert_eq!(to_digit('1', 2u), Some(1u));
293+
assert_eq!(to_digit('2', 3u), Some(2u));
294+
assert_eq!(to_digit('9', 10u), Some(9u));
295+
assert_eq!(to_digit('a', 16u), Some(10u));
296+
assert_eq!(to_digit('A', 16u), Some(10u));
297+
assert_eq!(to_digit('b', 16u), Some(11u));
298+
assert_eq!(to_digit('B', 16u), Some(11u));
299+
assert_eq!(to_digit('z', 36u), Some(35u));
300+
assert_eq!(to_digit('Z', 36u), Some(35u));
301301

302302
fail_unless!(to_digit(' ', 10u).is_none());
303303
fail_unless!(to_digit('$', 36u).is_none());
@@ -321,28 +321,28 @@ fn test_is_digit() {
321321
322322
#[test]
323323
fn test_escape_default() {
324-
fail_unless!(escape_default('\n') == ~"\\n");
325-
fail_unless!(escape_default('\r') == ~"\\r");
326-
fail_unless!(escape_default('\'') == ~"\\'");
327-
fail_unless!(escape_default('"') == ~"\\\"");
328-
fail_unless!(escape_default(' ') == ~" ");
329-
fail_unless!(escape_default('a') == ~"a");
330-
fail_unless!(escape_default('~') == ~"~");
331-
fail_unless!(escape_default('\x00') == ~"\\x00");
332-
fail_unless!(escape_default('\x1f') == ~"\\x1f");
333-
fail_unless!(escape_default('\x7f') == ~"\\x7f");
334-
fail_unless!(escape_default('\xff') == ~"\\xff");
335-
fail_unless!(escape_default('\u011b') == ~"\\u011b");
336-
fail_unless!(escape_default('\U0001d4b6') == ~"\\U0001d4b6");
324+
assert_eq!(escape_default('\n'), ~"\\n");
325+
assert_eq!(escape_default('\r'), ~"\\r");
326+
assert_eq!(escape_default('\''), ~"\\'");
327+
assert_eq!(escape_default('"'), ~"\\\"");
328+
assert_eq!(escape_default(' '), ~" ");
329+
assert_eq!(escape_default('a'), ~"a");
330+
assert_eq!(escape_default('~'), ~"~");
331+
assert_eq!(escape_default('\x00'), ~"\\x00");
332+
assert_eq!(escape_default('\x1f'), ~"\\x1f");
333+
assert_eq!(escape_default('\x7f'), ~"\\x7f");
334+
assert_eq!(escape_default('\xff'), ~"\\xff");
335+
assert_eq!(escape_default('\u011b'), ~"\\u011b");
336+
assert_eq!(escape_default('\U0001d4b6'), ~"\\U0001d4b6");
337337
}
338338
339339
340340
#[test]
341341
fn test_escape_unicode() {
342-
fail_unless!(escape_unicode('\x00') == ~"\\x00");
343-
fail_unless!(escape_unicode('\n') == ~"\\x0a");
344-
fail_unless!(escape_unicode(' ') == ~"\\x20");
345-
fail_unless!(escape_unicode('a') == ~"\\x61");
346-
fail_unless!(escape_unicode('\u011b') == ~"\\u011b");
347-
fail_unless!(escape_unicode('\U0001d4b6') == ~"\\U0001d4b6");
342+
assert_eq!(escape_unicode('\x00'), ~"\\x00");
343+
assert_eq!(escape_unicode('\n'), ~"\\x0a");
344+
assert_eq!(escape_unicode(' '), ~"\\x20");
345+
assert_eq!(escape_unicode('a'), ~"\\x61");
346+
assert_eq!(escape_unicode('\u011b'), ~"\\u011b");
347+
assert_eq!(escape_unicode('\U0001d4b6'), ~"\\U0001d4b6");
348348
}

branches/try2/src/libcore/cmp.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,10 @@ pub pure fn max<T:Ord>(v1: T, v2: T) -> T {
172172
mod test {
173173
#[test]
174174
fn test_int() {
175-
fail_unless!(5.cmp(&10) == Less);
176-
fail_unless!(10.cmp(&5) == Greater);
177-
fail_unless!(5.cmp(&5) == Equal);
178-
fail_unless!((-5).cmp(&12) == Less);
179-
fail_unless!(12.cmp(-5) == Greater);
175+
assert_eq!(5.cmp(&10), Less);
176+
assert_eq!(10.cmp(&5), Greater);
177+
assert_eq!(5.cmp(&5), Equal);
178+
assert_eq!((-5).cmp(&12), Less);
179+
assert_eq!(12.cmp(-5), Greater);
180180
}
181181
}

0 commit comments

Comments
 (0)