Skip to content

Commit 7bafdc6

Browse files
committed
---
yaml --- r: 2735 b: refs/heads/master c: 443e1e4 h: refs/heads/master i: 2733: 8db1703 2731: 7e380f0 2727: bc360dd 2719: 3569053 v: v3
1 parent 5299190 commit 7bafdc6

File tree

2 files changed

+17
-19
lines changed

2 files changed

+17
-19
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 820ccf4a1335dd3940118e41f72a11bd654bac99
2+
refs/heads/master: 443e1e455756df60c93a71b13dc132e289b7f032

trunk/src/lib/option.rs

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,34 +8,32 @@ tag t[T] {
88
type operator[T, U] = fn(&T) -> U;
99

1010
fn get[T](&t[T] opt) -> T {
11-
alt (opt) {
11+
ret alt (opt) {
1212
case (some[T](?x)) {
13-
ret x;
13+
x
1414
}
1515
case (none[T]) {
16-
fail;
16+
fail
1717
}
18-
}
19-
fail; // FIXME: remove me when exhaustiveness checking works
18+
};
2019
}
2120

2221
fn map[T, U](&operator[T, U] f, &t[T] opt) -> t[U] {
23-
alt (opt) {
22+
ret alt (opt) {
2423
case (some[T](?x)) {
25-
ret some[U](f(x));
24+
some[U](f(x))
2625
}
2726
case (none[T]) {
28-
ret none[U];
27+
none[U]
2928
}
30-
}
31-
fail; // FIXME: remove me when exhaustiveness checking works
29+
};
3230
}
3331

3432
fn is_none[T](&t[T] opt) -> bool {
35-
alt (opt) {
36-
case (none[T]) { ret true; }
37-
case (some[T](_)) { ret false; }
38-
}
33+
ret alt (opt) {
34+
case (none[T]) { true }
35+
case (some[T](_)) { false }
36+
};
3937
}
4038

4139
fn from_maybe[T](&T def, &t[T] opt) -> T {
@@ -44,10 +42,10 @@ fn from_maybe[T](&T def, &t[T] opt) -> T {
4442
}
4543

4644
fn maybe[T, U](&U def, fn(&T) -> U f, &t[T] opt) -> U {
47-
alt (opt) {
48-
case (none[T]) { ret def; }
49-
case (some[T](?t)) { ret f(t); }
50-
}
45+
ret alt (opt) {
46+
case (none[T]) { def }
47+
case (some[T](?t)) { f(t) }
48+
};
5149
}
5250

5351
// Can be defined in terms of the above when/if we have const bind.

0 commit comments

Comments
 (0)