diff options
| author | Brian Anderson <banderson@mozilla.com> | 2012-08-06 12:34:08 -0700 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2012-08-06 15:36:30 -0700 |
| commit | ecaf9e39c9435fa2de4fe393c4b263be36eb2d99 (patch) | |
| tree | 775f69be65adff65551d96173dd797e32e2c3157 /src/libcore | |
| parent | d3a9bb1bd4a1d510bbaca2ab1121e4c85a239247 (diff) | |
| download | rust-ecaf9e39c9435fa2de4fe393c4b263be36eb2d99.tar.gz rust-ecaf9e39c9435fa2de4fe393c4b263be36eb2d99.zip | |
Convert alt to match. Stop parsing alt
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/bool.rs | 2 | ||||
| -rw-r--r-- | src/libcore/char.rs | 4 | ||||
| -rw-r--r-- | src/libcore/comm.rs | 2 | ||||
| -rw-r--r-- | src/libcore/dlist.rs | 20 | ||||
| -rw-r--r-- | src/libcore/dvec.rs | 2 | ||||
| -rw-r--r-- | src/libcore/either.rs | 16 | ||||
| -rw-r--r-- | src/libcore/extfmt.rs | 24 | ||||
| -rw-r--r-- | src/libcore/float.rs | 14 | ||||
| -rw-r--r-- | src/libcore/future.rs | 4 | ||||
| -rw-r--r-- | src/libcore/int-template.rs | 2 | ||||
| -rw-r--r-- | src/libcore/io.rs | 18 | ||||
| -rw-r--r-- | src/libcore/iter-trait/option.rs | 4 | ||||
| -rw-r--r-- | src/libcore/iter.rs | 8 | ||||
| -rw-r--r-- | src/libcore/option.rs | 18 | ||||
| -rw-r--r-- | src/libcore/os.rs | 8 | ||||
| -rw-r--r-- | src/libcore/path.rs | 2 | ||||
| -rw-r--r-- | src/libcore/pipes.rs | 42 | ||||
| -rw-r--r-- | src/libcore/priv.rs | 2 | ||||
| -rw-r--r-- | src/libcore/result.rs | 40 | ||||
| -rw-r--r-- | src/libcore/run.rs | 8 | ||||
| -rw-r--r-- | src/libcore/send_map.rs | 12 | ||||
| -rw-r--r-- | src/libcore/str.rs | 16 | ||||
| -rw-r--r-- | src/libcore/task.rs | 28 | ||||
| -rw-r--r-- | src/libcore/uint-template.rs | 4 | ||||
| -rw-r--r-- | src/libcore/unicode.rs | 64 | ||||
| -rw-r--r-- | src/libcore/vec.rs | 10 |
26 files changed, 187 insertions, 187 deletions
diff --git a/src/libcore/bool.rs b/src/libcore/bool.rs index 91b268bc703..f8eb96996d0 100644 --- a/src/libcore/bool.rs +++ b/src/libcore/bool.rs @@ -39,7 +39,7 @@ pure fn is_false(v: bool) -> bool { !v } /// Parse logic value from `s` pure fn from_str(s: ~str) -> option<bool> { - alt check s { + match check s { ~"true" => some(true), ~"false" => some(false), _ => none diff --git a/src/libcore/char.rs b/src/libcore/char.rs index 97a484b491f..98aeddcf273 100644 --- a/src/libcore/char.rs +++ b/src/libcore/char.rs @@ -113,7 +113,7 @@ pure fn is_digit(c: char) -> bool { * refer to a digit in the given radix. */ pure fn to_digit(c: char, radix: uint) -> option<uint> { - let val = alt c { + let val = match c { '0' to '9' => c as uint - ('0' as uint), 'a' to 'z' => c as uint + 10u - ('a' as uint), 'A' to 'Z' => c as uint + 10u - ('A' as uint), @@ -158,7 +158,7 @@ fn escape_unicode(c: char) -> ~str { * - Any other chars are given hex unicode escapes; see `escape_unicode`. */ fn escape_default(c: char) -> ~str { - alt c { + match c { '\t' => ~"\\t", '\r' => ~"\\r", '\n' => ~"\\n", diff --git a/src/libcore/comm.rs b/src/libcore/comm.rs index 86bcfad89dd..794bdc90885 100644 --- a/src/libcore/comm.rs +++ b/src/libcore/comm.rs @@ -409,7 +409,7 @@ fn test_select2_stress() { let mut as = 0; let mut bs = 0; for iter::repeat(msgs * times * 2u) { - alt check select2(po_a, po_b) { + match check select2(po_a, po_b) { either::left(~"a") => as += 1, either::right(~"b") => bs += 1 } diff --git a/src/libcore/dlist.rs b/src/libcore/dlist.rs index 7b9d4432e54..9d410c03d6a 100644 --- a/src/libcore/dlist.rs +++ b/src/libcore/dlist.rs @@ -26,8 +26,8 @@ enum dlist<T> = @{ impl private_methods<T> for dlist_node<T> { pure fn assert_links() { - alt self.next { - some(neighbour) => alt neighbour.prev { + match self.next { + some(neighbour) => match neighbour.prev { some(me) => if !box::ptr_eq(*self, *me) { fail ~"Asymmetric next-link in dlist node." } @@ -35,8 +35,8 @@ impl private_methods<T> for dlist_node<T> { } none => () } - alt self.prev { - some(neighbour) => alt neighbour.next { + match self.prev { + some(neighbour) => match neighbour.next { some(me) => if !box::ptr_eq(*me, *self) { fail ~"Asymmetric prev-link in dlist node." } @@ -55,7 +55,7 @@ impl extensions<T> for dlist_node<T> { } /// Get the next node in the list, failing if there isn't one. pure fn next_node() -> dlist_node<T> { - alt self.next_link() { + match self.next_link() { some(nobe) => nobe, none => fail ~"This dlist node has no next neighbour." } @@ -67,7 +67,7 @@ impl extensions<T> for dlist_node<T> { } /// Get the previous node in the list, failing if there isn't one. pure fn prev_node() -> dlist_node<T> { - alt self.prev_link() { + match self.prev_link() { some(nobe) => nobe, none => fail ~"This dlist node has no previous neighbour." } @@ -138,11 +138,11 @@ impl private_methods<T> for dlist<T> { // the head and/or tail pointers appropriately. #[inline(always)] fn link(+before: dlist_link<T>, +after: dlist_link<T>) { - alt before { + match before { some(neighbour) => neighbour.next = after, none => self.hd = after } - alt after { + match after { some(neighbour) => neighbour.prev = before, none => self.tl = before } @@ -286,14 +286,14 @@ impl extensions<T> for dlist<T> { /// Get the node at the list's head, failing if empty. O(1). pure fn head_n() -> dlist_node<T> { - alt self.hd { + match self.hd { some(nobe) => nobe, none => fail ~"Attempted to get the head of an empty dlist." } } /// Get the node at the list's tail, failing if empty. O(1). pure fn tail_n() -> dlist_node<T> { - alt self.tl { + match self.tl { some(nobe) => nobe, none => fail ~"Attempted to get the tail of an empty dlist." } diff --git a/src/libcore/dvec.rs b/src/libcore/dvec.rs index 4f1e02d674d..a05df4e608a 100644 --- a/src/libcore/dvec.rs +++ b/src/libcore/dvec.rs @@ -222,7 +222,7 @@ impl extensions<A:copy> for dvec<A> { */ fn append_iter<A, I:iter::base_iter<A>>(ts: I) { do self.swap |v| { - let mut v = alt ts.size_hint() { + let mut v = match ts.size_hint() { none { v } some(h) { let len = v.len() + h; diff --git a/src/libcore/either.rs b/src/libcore/either.rs index d07b126bb5d..06999513889 100644 --- a/src/libcore/either.rs +++ b/src/libcore/either.rs @@ -18,7 +18,7 @@ fn either<T, U, V>(f_left: fn(T) -> V, * result is returned. */ - alt value { + match value { left(l) => f_left(l), right(r) => f_right(r) } @@ -29,7 +29,7 @@ fn lefts<T: copy, U>(eithers: ~[either<T, U>]) -> ~[T] { let mut result: ~[T] = ~[]; for vec::each(eithers) |elt| { - alt elt { + match elt { left(l) => vec::push(result, l), _ => { /* fallthrough */ } } @@ -42,7 +42,7 @@ fn rights<T, U: copy>(eithers: ~[either<T, U>]) -> ~[U] { let mut result: ~[U] = ~[]; for vec::each(eithers) |elt| { - alt elt { + match elt { right(r) => vec::push(result, r), _ => { /* fallthrough */ } } @@ -62,7 +62,7 @@ fn partition<T: copy, U: copy>(eithers: ~[either<T, U>]) let mut lefts: ~[T] = ~[]; let mut rights: ~[U] = ~[]; for vec::each(eithers) |elt| { - alt elt { + match elt { left(l) => vec::push(lefts, l), right(r) => vec::push(rights, r) } @@ -73,7 +73,7 @@ fn partition<T: copy, U: copy>(eithers: ~[either<T, U>]) pure fn flip<T: copy, U: copy>(eith: either<T, U>) -> either<U, T> { //! Flips between left and right of a given either - alt eith { + match eith { right(r) => left(r), left(l) => right(l) } @@ -88,7 +88,7 @@ pure fn to_result<T: copy, U: copy>( * an ok result, and the "left" choice a fail */ - alt eith { + match eith { right(r) => result::ok(r), left(l) => result::err(l) } @@ -97,13 +97,13 @@ pure fn to_result<T: copy, U: copy>( pure fn is_left<T, U>(eith: either<T, U>) -> bool { //! Checks whether the given value is a left - alt eith { left(_) => true, _ => false } + match eith { left(_) => true, _ => false } } pure fn is_right<T, U>(eith: either<T, U>) -> bool { //! Checks whether the given value is a right - alt eith { right(_) => true, _ => false } + match eith { right(_) => true, _ => false } } #[test] diff --git a/src/libcore/extfmt.rs b/src/libcore/extfmt.rs index 251bc2d18e1..fba8968103c 100644 --- a/src/libcore/extfmt.rs +++ b/src/libcore/extfmt.rs @@ -122,7 +122,7 @@ mod ct { let c = s[i]; if !('0' as u8 <= c && c <= '9' as u8) { return option::none; } let n = (c - ('0' as u8)) as uint; - return alt peek_num(s, i + 1u, lim) { + return match peek_num(s, i + 1u, lim) { none => some({num: n, next: i + 1u}), some(next) => { let m = next.num; @@ -150,7 +150,7 @@ mod ct { {param: option<int>, next: uint} { if i >= lim { return {param: none, next: i}; } let num = peek_num(s, i, lim); - return alt num { + return match num { none => {param: none, next: i}, some(t) => { let n = t.num; @@ -195,13 +195,13 @@ mod ct { } else if s[i] == '*' as u8 { let param = parse_parameter(s, i + 1u, lim); let j = param.next; - alt param.param { + match param.param { none => {count: count_is_next_param, next: j}, some(n) => {count: count_is_param(n), next: j} } } else { let num = peek_num(s, i, lim); - alt num { + match num { none => {count: count_implied, next: i}, some(num) => { count: count_is(num.num as int), @@ -220,7 +220,7 @@ mod ct { // If there were no digits specified, i.e. the precision // was ".", then the precision is 0 - alt count.count { + match count.count { count_implied => {count: count_is(0), next: count.next}, _ => count } @@ -294,7 +294,7 @@ mod rt { pure fn conv_uint(cv: conv, u: uint) -> ~str { let prec = get_int_precision(cv); let mut rs = - alt cv.ty { + match cv.ty { ty_default => uint_to_str_prec(u, 10u, prec), ty_hex_lower => uint_to_str_prec(u, 16u, prec), ty_hex_upper => str::to_upper(uint_to_str_prec(u, 16u, prec)), @@ -316,7 +316,7 @@ mod rt { pure fn conv_str(cv: conv, s: &str) -> ~str { // For strings, precision is the maximum characters // displayed - let mut unpadded = alt cv.precision { + let mut unpadded = match cv.precision { count_implied => s.to_unique(), count_is(max) => if max as uint < str::char_len(s) { str::substr(s, 0u, max as uint) @@ -327,7 +327,7 @@ mod rt { return unchecked { pad(cv, unpadded, pad_nozero) }; } pure fn conv_float(cv: conv, f: float) -> ~str { - let (to_str, digits) = alt cv.precision { + let (to_str, digits) = match cv.precision { count_is(c) => (float::to_str_exact, c as uint), count_implied => (float::to_str, 6u) }; @@ -371,14 +371,14 @@ mod rt { }; } pure fn get_int_precision(cv: conv) -> uint { - return alt cv.precision { + return match cv.precision { count_is(c) => c as uint, count_implied => 1u }; } enum pad_mode { pad_signed, pad_unsigned, pad_nozero, pad_float } fn pad(cv: conv, &s: ~str, mode: pad_mode) -> ~str { - let uwidth : uint = alt cv.width { + let uwidth : uint = match cv.width { count_implied => return s, count_is(width) => { // FIXME: width should probably be uint (see Issue #1996) @@ -393,14 +393,14 @@ mod rt { let padstr = str::from_chars(vec::from_elem(diff, padchar)); return s + padstr; } - let {might_zero_pad, signed} = alt mode { + let {might_zero_pad, signed} = match mode { pad_nozero => {might_zero_pad:false, signed:false}, pad_signed => {might_zero_pad:true, signed:true }, pad_float => {might_zero_pad:true, signed:true}, pad_unsigned => {might_zero_pad:true, signed:false} }; pure fn have_precision(cv: conv) -> bool { - return alt cv.precision { count_implied => false, _ => true }; + return match cv.precision { count_implied => false, _ => true }; } let zero_padding = { if might_zero_pad && have_flag(cv.flags, flag_left_zero_pad) && diff --git a/src/libcore/float.rs b/src/libcore/float.rs index 02133205be9..4269ef41f4d 100644 --- a/src/libcore/float.rs +++ b/src/libcore/float.rs @@ -256,14 +256,14 @@ fn from_str(num: ~str) -> option<float> { let mut c = 'z'; //Latest char. //The string must start with one of the following characters. - alt str::char_at(num, 0u) { + match str::char_at(num, 0u) { '-' | '+' | '0' to '9' | '.' => (), _ => return none } //Determine if first char is '-'/'+'. Set [pos] and [neg] accordingly. let mut neg = false; //Sign of the result - alt str::char_at(num, 0u) { + match str::char_at(num, 0u) { '-' => { neg = true; pos = 1u; @@ -279,7 +279,7 @@ fn from_str(num: ~str) -> option<float> { let char_range = str::char_range_at(num, pos); c = char_range.ch; pos = char_range.next; - alt c { + match c { '0' to '9' => { total = total * 10f; total += ((c as int) - ('0' as int)) as float; @@ -295,7 +295,7 @@ fn from_str(num: ~str) -> option<float> { let char_range = str::char_range_at(num, pos); c = char_range.ch; pos = char_range.next; - alt c { + match c { '0' | '1' | '2' | '3' | '4' | '5' | '6'| '7' | '8' | '9' => { decimal /= 10f; total += (((c as int) - ('0' as int)) as float)*decimal; @@ -312,7 +312,7 @@ fn from_str(num: ~str) -> option<float> { if(pos < len) { let char_range = str::char_range_at(num, pos); c = char_range.ch; - alt c { + match c { '+' => { pos = char_range.next; } @@ -325,7 +325,7 @@ fn from_str(num: ~str) -> option<float> { while(pos < len) { let char_range = str::char_range_at(num, pos); c = char_range.ch; - alt c { + match c { '0' | '1' | '2' | '3' | '4' | '5' | '6'| '7' | '8' | '9' => { exponent *= 10u; exponent += ((c as uint) - ('0' as uint)); @@ -447,7 +447,7 @@ fn test_from_str() { assert from_str(~"inf") == some(infinity); assert from_str(~"-inf") == some(neg_infinity); // note: NaN != NaN, hence this slightly complex test - alt from_str(~"NaN") { + match from_str(~"NaN") { some(f) => assert is_NaN(f), none => fail } diff --git a/src/libcore/future.rs b/src/libcore/future.rs index 1f6b259c467..8b7b51eef58 100644 --- a/src/libcore/future.rs +++ b/src/libcore/future.rs @@ -77,7 +77,7 @@ fn from_port<A:send>(-port: future_pipe::client::waiting<A>) -> future<A> { let mut port_ = none; port_ <-> *port; let port = option::unwrap(port_); - alt recv(port) { + match recv(port) { future_pipe::completed(data) => move_it!{data} } } @@ -119,7 +119,7 @@ fn get<A:copy>(future: future<A>) -> A { fn with<A,B>(future: future<A>, blk: fn(A) -> B) -> B { //! Work with the value without copying it - let v = alt copy future.v { + let v = match copy future.v { either::left(v) => v, either::right(f) => { let v = @f(); diff --git a/src/libcore/int-template.rs b/src/libcore/int-template.rs index 02ef14c5366..897f4030a47 100644 --- a/src/libcore/int-template.rs +++ b/src/libcore/int-template.rs @@ -144,7 +144,7 @@ fn parse_buf(buf: ~[u8], radix: uint) -> option<T> { } let mut n = 0 as T; loop { - alt char::to_digit(buf[i] as char, radix) { + match char::to_digit(buf[i] as char, radix) { some(d) => n += (d as T) * power, none => return none } diff --git a/src/libcore/io.rs b/src/libcore/io.rs index cf2c51625d8..2946700f832 100644 --- a/src/libcore/io.rs +++ b/src/libcore/io.rs @@ -196,7 +196,7 @@ impl reader_util for reader { // Reader implementations fn convert_whence(whence: seek_style) -> i32 { - return alt whence { + return match whence { seek_set => 0i32, seek_cur => 1i32, seek_end => 2i32 @@ -440,7 +440,7 @@ fn mk_file_writer(path: ~str, flags: ~[fileflag]) let mut fflags: c_int = wb(); for vec::each(flags) |f| { - alt f { + match f { append => fflags |= O_APPEND as c_int, create => fflags |= O_CREAT as c_int, truncate => fflags |= O_TRUNC as c_int, @@ -460,7 +460,7 @@ fn mk_file_writer(path: ~str, flags: ~[fileflag]) fn u64_to_le_bytes<T>(n: u64, size: uint, f: fn(v: &[u8]) -> T) -> T { assert size <= 8u; - alt size { + match size { 1u => f(&[n as u8]), 2u => f(&[n as u8, (n >> 8) as u8]), @@ -491,7 +491,7 @@ fn u64_to_le_bytes<T>(n: u64, size: uint, f: fn(v: &[u8]) -> T) -> T { fn u64_to_be_bytes<T>(n: u64, size: uint, f: fn(v: &[u8]) -> T) -> T { assert size <= 8u; - alt size { + match size { 1u => f(&[n as u8]), 2u => f(&[(n >> 8) as u8, n as u8]), @@ -717,7 +717,7 @@ fn seek_in_buf(offset: int, pos: uint, len: uint, whence: seek_style) -> uint { let mut bpos = pos as int; let blen = len as int; - alt whence { + match whence { seek_set => bpos = offset, seek_cur => bpos += offset, seek_end => bpos = blen + offset @@ -767,7 +767,7 @@ mod fsync { let arg: arg<t>; new(-arg: arg<t>) { self.arg <- arg; } drop { - alt self.arg.opt_level { + match self.arg.opt_level { option::none => (), option::some(level) => { // fail hard if not succesful @@ -891,7 +891,7 @@ mod tests { #[test] fn file_reader_not_exist() { - alt io::file_reader(~"not a file") { + match io::file_reader(~"not a file") { result::err(e) => { assert e == ~"error opening not a file"; } @@ -901,7 +901,7 @@ mod tests { #[test] fn file_writer_bad_name() { - alt io::file_writer(~"?/?", ~[]) { + match io::file_writer(~"?/?", ~[]) { result::err(e) => { assert str::starts_with(e, ~"error opening ?/?"); } @@ -911,7 +911,7 @@ mod tests { #[test] fn buffered_file_writer_bad_name() { - alt io::buffered_file_writer(~"?/?") { + match io::buffered_file_writer(~"?/?") { result::err(e) => { assert e == ~"error opening ?/?"; } diff --git a/src/libcore/iter-trait/option.rs b/src/libcore/iter-trait/option.rs index a150afa36e1..2bcb7bba56e 100644 --- a/src/libcore/iter-trait/option.rs +++ b/src/libcore/iter-trait/option.rs @@ -1,14 +1,14 @@ type IMPL_T<A> = option<A>; pure fn EACH<A>(self: IMPL_T<A>, f: fn(A) -> bool) { - alt self { + match self { none => (), some(a) => { f(a); } } } fn SIZE_HINT<A>(self: IMPL_T<A>) -> option<uint> { - alt self { + match self { none => some(0u), some(_) => some(1u) } diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs index 541c19aa3a5..2cb3369dbc7 100644 --- a/src/libcore/iter.rs +++ b/src/libcore/iter.rs @@ -134,8 +134,8 @@ fn repeat(times: uint, blk: fn() -> bool) { } fn min<A:copy,IA:base_iter<A>>(self: IA) -> A { - alt do foldl::<A,option<A>,IA>(self, none) |a, b| { - alt a { + match do foldl::<A,option<A>,IA>(self, none) |a, b| { + match a { some(a_) if a_ < b => { // FIXME (#2005): Not sure if this is successfully optimized to // a move @@ -150,8 +150,8 @@ fn min<A:copy,IA:base_iter<A>>(self: IA) -> A { } fn max<A:copy,IA:base_iter<A>>(self: IA) -> A { - alt do foldl::<A,option<A>,IA>(self, none) |a, b| { - alt a { + match do foldl::<A,option<A>,IA>(self, none) |a, b| { + match a { some(a_) if a_ > b => { // FIXME (#2005): Not sure if this is successfully optimized to // a move. diff --git a/src/libcore/option.rs b/src/libcore/option.rs index b2ae670ec05..d64b89c2f04 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -23,7 +23,7 @@ pure fn get<T: copy>(opt: option<T>) -> T { * Fails if the value equals `none` */ - alt opt { + match opt { some(x) => return x, none => fail ~"option::get none" } @@ -37,13 +37,13 @@ pure fn expect<T: copy>(opt: option<T>, reason: ~str) -> T { Fails if the value equals `none` "]; - alt opt { some(x) => x, none => fail reason } + match opt { some(x) => x, none => fail reason } } pure fn map<T, U>(opt: option<T>, f: fn(T) -> U) -> option<U> { //! Maps a `some` value from one type to another - alt opt { some(x) => some(f(x)), none => none } + match opt { some(x) => some(f(x)), none => none } } pure fn map_consume<T, U>(-opt: option<T>, f: fn(-T) -> U) -> option<U> { @@ -60,7 +60,7 @@ pure fn chain<T, U>(opt: option<T>, f: fn(T) -> option<U>) -> option<U> { * function that returns an option. */ - alt opt { some(x) => f(x), none => none } + match opt { some(x) => f(x), none => none } } #[inline(always)] @@ -76,7 +76,7 @@ pure fn while_some<T>(+x: option<T>, blk: fn(+T) -> option<T>) { pure fn is_none<T>(opt: option<T>) -> bool { //! Returns true if the option equals `none` - alt opt { none => true, some(_) => false } + match opt { none => true, some(_) => false } } pure fn is_some<T>(opt: option<T>) -> bool { @@ -88,19 +88,19 @@ pure fn is_some<T>(opt: option<T>) -> bool { pure fn get_default<T: copy>(opt: option<T>, def: T) -> T { //! Returns the contained value or a default - alt opt { some(x) => x, none => def } + match opt { some(x) => x, none => def } } pure fn map_default<T, U>(opt: option<T>, +def: U, f: fn(T) -> U) -> U { //! Applies a function to the contained value or returns a default - alt opt { none => def, some(t) => f(t) } + match opt { none => def, some(t) => f(t) } } pure fn iter<T>(opt: option<T>, f: fn(T)) { //! Performs an operation on the contained value or does nothing - alt opt { none => (), some(t) => f(t) } + match opt { none => (), some(t) => f(t) } } #[inline(always)] @@ -113,7 +113,7 @@ pure fn unwrap<T>(-opt: option<T>) -> T { */ unsafe { - let addr = alt opt { + let addr = match opt { some(x) => ptr::addr_of(x), none => fail ~"option::unwrap none" }; diff --git a/src/libcore/os.rs b/src/libcore/os.rs index fba4e7acac5..07bbff42b94 100644 --- a/src/libcore/os.rs +++ b/src/libcore/os.rs @@ -178,7 +178,7 @@ mod global_env { unsafe { do priv::weaken_task |weak_po| { loop { - alt comm::select2(msg_po, weak_po) { + match comm::select2(msg_po, weak_po) { either::left(msg_getenv(n, resp_ch)) => { comm::send(resp_ch, impl::getenv(n)) } @@ -282,7 +282,7 @@ fn fsync_fd(fd: c_int, _level: io::fsync::level) -> c_int { #[cfg(target_os = "linux")] fn fsync_fd(fd: c_int, level: io::fsync::level) -> c_int { import libc::funcs::posix01::unistd::*; - alt level { + match level { io::fsync::fsync | io::fsync::fullfsync => return fsync(fd), io::fsync::fdatasync => return fdatasync(fd) @@ -294,7 +294,7 @@ fn fsync_fd(fd: c_int, level: io::fsync::level) -> c_int { import libc::consts::os::extra::*; import libc::funcs::posix88::fcntl::*; import libc::funcs::posix01::unistd::*; - alt level { + match level { io::fsync::fsync => return fsync(fd), _ => { // According to man fnctl, the ok retval is only specified to be !=-1 @@ -440,7 +440,7 @@ fn self_exe_path() -> option<path> { * Otherwise, homedir returns option::none. */ fn homedir() -> option<path> { - return alt getenv(~"HOME") { + return match getenv(~"HOME") { some(p) => if !str::is_empty(p) { some(p) } else { diff --git a/src/libcore/path.rs b/src/libcore/path.rs index dc541b14a4b..1f239605131 100644 --- a/src/libcore/path.rs +++ b/src/libcore/path.rs @@ -61,7 +61,7 @@ fn path_is_absolute(p: ~str) -> bool { fn path_sep() -> ~str { return str::from_char(consts::path_sep); } fn split_dirname_basename (pp: path) -> {dirname: ~str, basename: ~str} { - alt str::rfind(pp, |ch| + match str::rfind(pp, |ch| ch == consts::path_sep || ch == consts::alt_path_sep ) { some(i) => { diff --git a/src/libcore/pipes.rs b/src/libcore/pipes.rs index ce72a6edca9..33ee3cc52fb 100644 --- a/src/libcore/pipes.rs +++ b/src/libcore/pipes.rs @@ -136,7 +136,7 @@ struct packet_header { unsafe fn unblock() { let old_task = swap_task(self.blocked_task, ptr::null()); if !old_task.is_null() { rustrt::rust_task_deref(old_task) } - alt swap_state_acq(self.state, empty) { + match swap_state_acq(self.state, empty) { empty | blocked => (), terminated => self.state = terminated, full => self.state = full @@ -345,7 +345,7 @@ fn send<T: send, Tbuffer: send>(-p: send_packet_buffered<T, Tbuffer>, assert p.payload == none; p.payload <- some(payload); let old_state = swap_state_rel(p.header.state, full); - alt old_state { + match old_state { empty => { // Yay, fastpath. @@ -403,7 +403,7 @@ fn try_recv<T: send, Tbuffer: send>(-p: recv_packet_buffered<T, Tbuffer>) rustrt::task_clear_event_reject(this); let old_state = swap_state_acq(p.header.state, blocked); - alt old_state { + match old_state { empty => { debug!{"no data available on %?, going to sleep.", p_}; if count == 0 { @@ -451,7 +451,7 @@ fn try_recv<T: send, Tbuffer: send>(-p: recv_packet_buffered<T, Tbuffer>) /// Returns true if messages are available. pure fn peek<T: send, Tb: send>(p: recv_packet_buffered<T, Tb>) -> bool { - alt unsafe {(*p.header()).state} { + match unsafe {(*p.header()).state} { empty => false, blocked => fail ~"peeking on blocked packet", full | terminated => true @@ -467,7 +467,7 @@ impl peek<T: send, Tb: send> for recv_packet_buffered<T, Tb> { #[doc(hidden)] fn sender_terminate<T: send>(p: *packet<T>) { let p = unsafe { &*p }; - alt swap_state_rel(p.header.state, terminated) { + match swap_state_rel(p.header.state, terminated) { empty => { assert p.header.blocked_task.is_null(); // The receiver will eventually clean up. @@ -500,7 +500,7 @@ fn sender_terminate<T: send>(p: *packet<T>) { fn receiver_terminate<T: send>(p: *packet<T>) { let p = unsafe { &*p }; assert p.header.blocked_task.is_null(); - alt swap_state_rel(p.header.state, terminated) { + match swap_state_rel(p.header.state, terminated) { empty => { // the sender will clean up //unsafe { forget(p) } @@ -534,7 +534,7 @@ fn wait_many(pkts: &[*packet_header]) -> uint { for pkts.eachi |i, p| unsafe { let p = unsafe { &*p }; let old = p.mark_blocked(this); - alt old { + match old { full | terminated => { data_avail = true; ready_packet = i; @@ -551,7 +551,7 @@ fn wait_many(pkts: &[*packet_header]) -> uint { let event = wait_event(this) as *packet_header; let pos = vec::position(pkts, |p| p == event); - alt pos { + match pos { some(i) => { ready_packet = i; data_avail = true; @@ -611,7 +611,7 @@ fn select2<A: send, Ab: send, B: send, Bb: send>( let i = wait_many([a.header(), b.header()]/_); unsafe { - alt i { + match i { 0 => left((try_recv(a), b)), 1 => right((a, try_recv(b))), _ => fail ~"select2 return an invalid packet" @@ -631,7 +631,7 @@ fn selecti<T: selectable>(endpoints: &[T]) -> uint { /// Returns 0 or 1 depending on which endpoint is ready to receive fn select2i<A: selectable, B: selectable>(a: A, b: B) -> either<(), ()> { - alt wait_many([a.header(), b.header()]/_) { + match wait_many([a.header(), b.header()]/_) { 0 => left(()), 1 => right(()), _ => fail ~"wait returned unexpected index" @@ -704,7 +704,7 @@ struct send_packet_buffered<T: send, Tbuffer: send> { } pure fn header() -> *packet_header { - alt self.p { + match self.p { some(packet) => unsafe { let packet = &*packet; let header = ptr::addr_of(packet.header); @@ -765,7 +765,7 @@ struct recv_packet_buffered<T: send, Tbuffer: send> : selectable { } pure fn header() -> *packet_header { - alt self.p { + match self.p { some(packet) => unsafe { let packet = &*packet; let header = ptr::addr_of(packet.header); @@ -924,7 +924,7 @@ impl port<T: send> of recv<T> for port<T> { fn try_recv() -> option<T> { let mut endp = none; endp <-> self.endp; - alt move pipes::try_recv(unwrap(endp)) { + match move pipes::try_recv(unwrap(endp)) { some(streamp::data(x, endp)) => { self.endp = some(move_it!{endp}); some(move_it!{x}) @@ -936,7 +936,7 @@ impl port<T: send> of recv<T> for port<T> { pure fn peek() -> bool unchecked { let mut endp = none; endp <-> self.endp; - let peek = alt endp { + let peek = match endp { some(endp) => pipes::peek(endp), none => fail ~"peeking empty stream" }; @@ -969,7 +969,7 @@ struct port_set<T: send> : recv<T> { ports <-> self.ports; while result == none && ports.len() > 0 { let i = wait_many(ports.map(|p| p.header())); - alt move ports[i].try_recv() { + match move ports[i].try_recv() { some(copy m) => { result = some(move m); } @@ -1007,7 +1007,7 @@ struct port_set<T: send> : recv<T> { impl<T: send> of selectable for port<T> { pure fn header() -> *packet_header unchecked { - alt self.endp { + match self.endp { some(endp) => endp.header(), none => fail ~"peeking empty stream" } @@ -1045,8 +1045,8 @@ impl<T: send, U: send, Left: selectable recv<T>, Right: selectable recv<U>> of select2<T, U> for (Left, Right) { fn select() -> either<T, U> { - alt self { - (lp, rp) => alt select2i(lp, rp) { + match self { + (lp, rp) => match select2i(lp, rp) { left(()) => left (lp.recv()), right(()) => right(rp.recv()) } @@ -1054,8 +1054,8 @@ impl<T: send, U: send, Left: selectable recv<T>, Right: selectable recv<U>> } fn try_select() -> either<option<T>, option<U>> { - alt self { - (lp, rp) => alt select2i(lp, rp) { + match self { + (lp, rp) => match select2i(lp, rp) { left(()) => left (lp.try_recv()), right(()) => right(rp.try_recv()) } @@ -1072,7 +1072,7 @@ mod test { c1.send(~"abc"); - alt (p1, p2).select() { + match (p1, p2).select() { right(_) => fail, _ => () } diff --git a/src/libcore/priv.rs b/src/libcore/priv.rs index 5d7123f1bba..ac286da79f6 100644 --- a/src/libcore/priv.rs +++ b/src/libcore/priv.rs @@ -49,7 +49,7 @@ unsafe fn chan_from_global_ptr<T: send>( // Wait to hear if we are the official instance of // this global task - alt comm::recv::<msg>(setup_po) { + match comm::recv::<msg>(setup_po) { proceed => f(po), abort => () } diff --git a/src/libcore/result.rs b/src/libcore/result.rs index a74ac589b93..417841f3323 100644 --- a/src/libcore/result.rs +++ b/src/libcore/result.rs @@ -18,7 +18,7 @@ enum result<T, U> { * If the result is an error */ pure fn get<T: copy, U>(res: result<T, U>) -> T { - alt res { + match res { ok(t) => t, err(the_err) => unchecked { fail fmt!{"get called on error result: %?", the_err} @@ -34,7 +34,7 @@ pure fn get<T: copy, U>(res: result<T, U>) -> T { * If the result is not an error */ pure fn get_err<T, U: copy>(res: result<T, U>) -> U { - alt res { + match res { err(u) => u, ok(_) => fail ~"get_error called on ok result" } @@ -42,7 +42,7 @@ pure fn get_err<T, U: copy>(res: result<T, U>) -> U { /// Returns true if the result is `ok` pure fn is_ok<T, U>(res: result<T, U>) -> bool { - alt res { + match res { ok(_) => true, err(_) => false } @@ -60,7 +60,7 @@ pure fn is_err<T, U>(res: result<T, U>) -> bool { * result variants are converted to `either::left`. */ pure fn to_either<T: copy, U: copy>(res: result<U, T>) -> either<T, U> { - alt res { + match res { ok(res) => either::right(res), err(fail_) => either::left(fail_) } @@ -82,7 +82,7 @@ pure fn to_either<T: copy, U: copy>(res: result<U, T>) -> either<T, U> { */ fn chain<T, U: copy, V: copy>(res: result<T, V>, op: fn(T) -> result<U, V>) -> result<U, V> { - alt res { + match res { ok(t) => op(t), err(e) => err(e) } @@ -100,7 +100,7 @@ fn chain_err<T: copy, U: copy, V: copy>( res: result<T, V>, op: fn(V) -> result<T, U>) -> result<T, U> { - alt res { + match res { ok(t) => ok(t), err(v) => op(v) } @@ -121,7 +121,7 @@ fn chain_err<T: copy, U: copy, V: copy>( * } */ fn iter<T, E>(res: result<T, E>, f: fn(T)) { - alt res { + match res { ok(t) => f(t), err(_) => () } @@ -136,7 +136,7 @@ fn iter<T, E>(res: result<T, E>, f: fn(T)) { * handling an error. */ fn iter_err<T, E>(res: result<T, E>, f: fn(E)) { - alt res { + match res { ok(_) => (), err(e) => f(e) } @@ -158,7 +158,7 @@ fn iter_err<T, E>(res: result<T, E>, f: fn(E)) { */ fn map<T, E: copy, U: copy>(res: result<T, E>, op: fn(T) -> U) -> result<U, E> { - alt res { + match res { ok(t) => ok(op(t)), err(e) => err(e) } @@ -174,7 +174,7 @@ fn map<T, E: copy, U: copy>(res: result<T, E>, op: fn(T) -> U) */ fn map_err<T: copy, E, F: copy>(res: result<T, E>, op: fn(E) -> F) -> result<T, F> { - alt res { + match res { ok(t) => ok(t), err(e) => err(op(e)) } @@ -186,14 +186,14 @@ impl extensions<T, E> for result<T, E> { fn is_err() -> bool { is_err(self) } fn iter(f: fn(T)) { - alt self { + match self { ok(t) => f(t), err(_) => () } } fn iter_err(f: fn(E)) { - alt self { + match self { ok(_) => (), err(e) => f(e) } @@ -204,7 +204,7 @@ impl extensions<T:copy, E> for result<T, E> { fn get() -> T { get(self) } fn map_err<F:copy>(op: fn(E) -> F) -> result<T,F> { - alt self { + match self { ok(t) => ok(t), err(e) => err(op(e)) } @@ -215,7 +215,7 @@ impl extensions<T, E:copy> for result<T, E> { fn get_err() -> E { get_err(self) } fn map<U:copy>(op: fn(T) -> U) -> result<U,E> { - alt self { + match self { ok(t) => ok(op(t)), err(e) => err(e) } @@ -255,7 +255,7 @@ fn map_vec<T,U:copy,V:copy>( let mut vs: ~[V] = ~[]; vec::reserve(vs, vec::len(ts)); for vec::each(ts) |t| { - alt op(t) { + match op(t) { ok(v) => vec::push(vs, v), err(u) => return err(u) } @@ -266,9 +266,9 @@ fn map_vec<T,U:copy,V:copy>( fn map_opt<T,U:copy,V:copy>( o_t: option<T>, op: fn(T) -> result<V,U>) -> result<option<V>,U> { - alt o_t { + match o_t { none => ok(none), - some(t) => alt op(t) { + some(t) => match op(t) { ok(v) => ok(some(v)), err(e) => err(e) } @@ -293,7 +293,7 @@ fn map_vec2<S,T,U:copy,V:copy>(ss: ~[S], ts: ~[T], vec::reserve(vs, n); let mut i = 0u; while i < n { - alt op(ss[i],ts[i]) { + match op(ss[i],ts[i]) { ok(v) => vec::push(vs, v), err(u) => return err(u) } @@ -314,7 +314,7 @@ fn iter_vec2<S,T,U:copy>(ss: ~[S], ts: ~[T], let n = vec::len(ts); let mut i = 0u; while i < n { - alt op(ss[i],ts[i]) { + match op(ss[i],ts[i]) { ok(()) => (), err(u) => return err(u) } @@ -326,7 +326,7 @@ fn iter_vec2<S,T,U:copy>(ss: ~[S], ts: ~[T], /// Unwraps a result, assuming it is an `ok(T)` fn unwrap<T, U>(-res: result<T, U>) -> T { unsafe { - let addr = alt res { + let addr = match res { ok(x) => ptr::addr_of(x), err(_) => fail ~"error result" }; diff --git a/src/libcore/run.rs b/src/libcore/run.rs index 60527e786bd..92e89d8a7c8 100644 --- a/src/libcore/run.rs +++ b/src/libcore/run.rs @@ -96,7 +96,7 @@ fn with_envp<T>(env: option<~[(~str,~str)]>, cb: fn(*c_void) -> T) -> T { // On posixy systems we can pass a char** for envp, which is // a null-terminated array of "k=v\n" strings. - alt env { + match env { some(es) if !vec::is_empty(es) => { let mut tmps = ~[]; let mut ptrs = ~[]; @@ -123,7 +123,7 @@ fn with_envp<T>(env: option<~[(~str,~str)]>, // rather a concatenation of null-terminated k=v\0 sequences, with a final // \0 to terminate. unsafe { - alt env { + match env { some(es) if !vec::is_empty(es) => { let mut blk : ~[u8] = ~[]; for vec::each(es) |e| { @@ -143,7 +143,7 @@ fn with_envp<T>(env: option<~[(~str,~str)]>, fn with_dirp<T>(d: option<~str>, cb: fn(*libc::c_char) -> T) -> T { - alt d { + match d { some(dir) => str::as_c_str(dir, cb), none => cb(ptr::null()) } @@ -309,7 +309,7 @@ fn program_output(prog: ~str, args: ~[~str]) -> let mut count = 2; while count > 0 { let stream = comm::recv(p); - alt check stream { + match check stream { (1, s) => { outs = s; } diff --git a/src/libcore/send_map.rs b/src/libcore/send_map.rs index a242587a21c..04dc25a2c11 100644 --- a/src/libcore/send_map.rs +++ b/src/libcore/send_map.rs @@ -115,7 +115,7 @@ mod linear { k: &K) -> search_result { let _ = for self.bucket_sequence(hash) |i| { - alt buckets[i] { + match buckets[i] { some(bkt) => if bkt.hash == hash && self.eqfn(k, &bkt.key) { return found_entry(i); } @@ -155,7 +155,7 @@ mod linear { /// Assumes that there will be a bucket. /// True if there was no previous entry with that key fn insert_internal(hash: uint, +k: K, +v: V) -> bool { - alt self.bucket_for_key_with_hash(self.buckets, hash, + match self.bucket_for_key_with_hash(self.buckets, hash, unsafe{borrow(k)}) { table_full => {fail ~"Internal logic error";} found_hole(idx) => { @@ -207,7 +207,7 @@ mod linear { // I found this explanation elucidating: // http://www.maths.lse.ac.uk/Courses/MA407/del-hash.pdf - let mut idx = alt self.bucket_for_key(self.buckets, k) { + let mut idx = match self.bucket_for_key(self.buckets, k) { table_full | found_hole(_) => { return false; } @@ -246,7 +246,7 @@ mod linear { } fn contains_key(k: &K) -> bool { - alt self.bucket_for_key(self.buckets, k) { + match self.bucket_for_key(self.buckets, k) { found_entry(_) => {true} table_full | found_hole(_) => {false} } @@ -255,9 +255,9 @@ mod linear { impl public_methods<K,V: copy> for &const linear_map<K,V> { fn find(k: &K) -> option<V> { - alt self.bucket_for_key(self.buckets, k) { + match self.bucket_for_key(self.buckets, k) { found_entry(idx) => { - alt check self.buckets[idx] { + match check self.buckets[idx] { some(bkt) => {some(copy bkt.value)} } } diff --git a/src/libcore/str.rs b/src/libcore/str.rs index cec8ec52ee4..4a13c1d9354 100644 --- a/src/libcore/str.rs +++ b/src/libcore/str.rs @@ -341,7 +341,7 @@ fn unshift_char(&s: ~str, ch: char) { s = from_char(ch) + s; } /// Returns a string with leading whitespace removed pure fn trim_left(s: &str) -> ~str { - alt find(s, |c| !char::is_whitespace(c)) { + match find(s, |c| !char::is_whitespace(c)) { none => ~"", some(first) => unsafe { unsafe::slice_bytes(s, first, len(s)) } } @@ -349,7 +349,7 @@ pure fn trim_left(s: &str) -> ~str { /// Returns a string with trailing whitespace removed pure fn trim_right(s: &str) -> ~str { - alt rfind(s, |c| !char::is_whitespace(c)) { + match rfind(s, |c| !char::is_whitespace(c)) { none => ~"", some(last) => { let {next, _} = char_range_at(s, last); @@ -2776,7 +2776,7 @@ mod tests { fn test_chars_iter() { let mut i = 0; do chars_iter(~"x\u03c0y") |ch| { - alt check i { + match check i { 0 => assert ch == 'x', 1 => assert ch == '\u03c0', 2 => assert ch == 'y' @@ -2792,7 +2792,7 @@ mod tests { let mut i = 0; do bytes_iter(~"xyz") |bb| { - alt check i { + match check i { 0 => assert bb == 'x' as u8, 1 => assert bb == 'y' as u8, 2 => assert bb == 'z' as u8 @@ -2810,7 +2810,7 @@ mod tests { let mut ii = 0; do split_char_iter(data, ' ') |xx| { - alt ii { + match ii { 0 => assert ~"\nMary" == xx, 1 => assert ~"had" == xx, 2 => assert ~"a" == xx, @@ -2828,7 +2828,7 @@ mod tests { let mut ii = 0; do splitn_char_iter(data, ' ', 2u) |xx| { - alt ii { + match ii { 0 => assert ~"\nMary" == xx, 1 => assert ~"had" == xx, 2 => assert ~"a little lamb\nLittle lamb\n" == xx, @@ -2845,7 +2845,7 @@ mod tests { let mut ii = 0; do words_iter(data) |ww| { - alt ii { + match ii { 0 => assert ~"Mary" == ww, 1 => assert ~"had" == ww, 2 => assert ~"a" == ww, @@ -2865,7 +2865,7 @@ mod tests { let mut ii = 0; do lines_iter(lf) |x| { - alt ii { + match ii { 0 => assert ~"" == x, 1 => assert ~"Mary had a little lamb" == x, 2 => assert ~"Little lamb" == x, diff --git a/src/libcore/task.rs b/src/libcore/task.rs index cf354f0f809..422d62862ea 100644 --- a/src/libcore/task.rs +++ b/src/libcore/task.rs @@ -279,7 +279,7 @@ impl task_builder for task_builder { let ch = comm::chan(po); blk(do future::from_fn { - alt comm::recv(po) { + match comm::recv(po) { exit(_, result) => result } }); @@ -502,7 +502,7 @@ fn try<T:send>(+f: fn~() -> T) -> result<T,()> { do task().unlinked().future_result(|-r| { result = some(r); }).spawn { comm::send(ch, f()); } - alt future::get(option::unwrap(result)) { + match future::get(option::unwrap(result)) { success => result::ok(comm::recv(po)), failure => result::err(()) } @@ -991,7 +991,7 @@ fn gen_child_taskgroup(linked: bool, supervised: bool) /*######################################################################* * Step 1. Get spawner's taskgroup info. *######################################################################*/ - let spawner_group = alt unsafe { local_get(spawner, taskgroup_key()) } { + let spawner_group = match unsafe { local_get(spawner, taskgroup_key()) } { none => { // Main task, doing first spawn ever. Lazily initialise here. let mut members = new_taskset(); @@ -1028,7 +1028,7 @@ fn gen_child_taskgroup(linked: bool, supervised: bool) // assertion, but initialising it requires locking a mutex. Hence // it should be enabled only in debug builds. let new_generation = - alt *old_ancestors { + match *old_ancestors { some(arc) => access_ancestors(arc, |a| a.generation+1), none => 0 // the actual value doesn't really matter. }; @@ -1047,7 +1047,7 @@ fn gen_child_taskgroup(linked: bool, supervised: bool) fn share_ancestors(ancestors: &mut ancestor_list) -> ancestor_list { // Appease the borrow-checker. Really this wants to be written as: - // alt ancestors + // match ancestors // some(ancestor_arc) { ancestor_list(some(ancestor_arc.clone())) } // none { ancestor_list(none) } let tmp = util::replace(&mut **ancestors, none); @@ -1073,7 +1073,7 @@ fn spawn_raw(opts: task_opts, +f: fn~()) { // Agh. Get move-mode items into the closure. FIXME (#2829) let (child_tg, ancestors, f) = option::swap_unwrap(child_data); // Create child task. - let new_task = alt opts.sched { + let new_task = match opts.sched { none => rustrt::new_task(), some(sched_opts) => new_task_in_new_sched(sched_opts) }; @@ -1162,7 +1162,7 @@ fn spawn_raw(opts: task_opts, +f: fn~()) { fail ~"foreign_stack_size scheduler option unimplemented"; } - let num_threads = alt opts.mode { + let num_threads = match opts.mode { single_threaded => 1u, thread_per_core => { fail ~"thread_per_core scheduling mode unimplemented" @@ -1273,7 +1273,7 @@ unsafe fn local_data_lookup<T: owned>( let key_value = key_to_key_value(key); let map_pos = (*map).position(|entry| - alt entry { + match entry { some((k,_,_)) => k == key_value, none => false } @@ -1336,7 +1336,7 @@ unsafe fn local_set<T: owned>( // Construct new entry to store in the map. let new_entry = some((keyval, data_ptr, data_box)); // Find a place to put it. - alt local_data_lookup(map, key) { + match local_data_lookup(map, key) { some((index, _old_data_ptr)) => { // Key already had a value set, _old_data_ptr, whose reference // will get dropped when the local_data box is overwritten. @@ -1344,7 +1344,7 @@ unsafe fn local_set<T: owned>( } none => { // Find an empty slot. If not, grow the vector. - alt (*map).position(|x| x == none) { + match (*map).position(|x| x == none) { some(empty_index) => (*map).set_elt(empty_index, new_entry), none => (*map).push(new_entry) } @@ -1694,7 +1694,7 @@ fn test_spawn_listiner_bidi() { #[test] fn test_try_success() { - alt do try { + match do try { ~"Success!" } { result::ok(~"Success!") => (), @@ -1705,7 +1705,7 @@ fn test_try_success() { #[test] #[ignore(cfg(windows))] fn test_try_fail() { - alt do try { + match do try { fail } { result::err(()) => (), @@ -2052,13 +2052,13 @@ fn test_tls_pop() unsafe { fn test_tls_modify() unsafe { fn my_key(+_x: @~str) { } local_data_modify(my_key, |data| { - alt data { + match data { some(@val) => fail ~"unwelcome value: " + val, none => some(@~"first data") } }); local_data_modify(my_key, |data| { - alt data { + match data { some(@~"first data") => some(@~"next data"), some(@val) => fail ~"wrong value: " + val, none => fail ~"missing value" diff --git a/src/libcore/uint-template.rs b/src/libcore/uint-template.rs index d3b0e8cea24..a0feaf3ed9d 100644 --- a/src/libcore/uint-template.rs +++ b/src/libcore/uint-template.rs @@ -127,7 +127,7 @@ fn parse_buf(buf: ~[u8], radix: uint) -> option<T> { let mut power = 1u as T; let mut n = 0u as T; loop { - alt char::to_digit(buf[i] as char, radix) { + match char::to_digit(buf[i] as char, radix) { some(d) => n += d as T * power, none => return none } @@ -146,7 +146,7 @@ fn from_str_radix(buf: ~str, radix: u64) -> option<u64> { let mut i = str::len(buf) - 1u; let mut power = 1u64, n = 0u64; loop { - alt char::to_digit(buf[i] as char, radix as uint) { + match char::to_digit(buf[i] as char, radix as uint) { some(d) => n += d as u64 * power, none => return none } diff --git a/src/libcore/unicode.rs b/src/libcore/unicode.rs index 343bf7954e6..c7f0c9bfa17 100644 --- a/src/libcore/unicode.rs +++ b/src/libcore/unicode.rs @@ -1,6 +1,6 @@ mod general_category { pure fn Cc(c: char) -> bool { - return alt c { + return match c { '\x00' to '\x1f' | '\x7f' to '\x9f' => true, _ => false @@ -8,7 +8,7 @@ mod general_category { } pure fn Cf(c: char) -> bool { - return alt c { + return match c { '\xad' | '\u0600' to '\u0603' | '\u06dd' @@ -27,21 +27,21 @@ mod general_category { } pure fn Co(c: char) -> bool { - return alt c { + return match c { '\ue000' to '\uf8ff' => true, _ => false }; } pure fn Cs(c: char) -> bool { - return alt c { + return match c { '\ud800' to '\udfff' => true, _ => false }; } pure fn Ll(c: char) -> bool { - return alt c { + return match c { '\x61' to '\x7a' | '\xaa' | '\xb5' @@ -646,7 +646,7 @@ mod general_category { } pure fn Lm(c: char) -> bool { - return alt c { + return match c { '\u02b0' to '\u02c1' | '\u02c6' to '\u02d1' | '\u02e0' to '\u02e4' @@ -702,7 +702,7 @@ mod general_category { } pure fn Lo(c: char) -> bool { - return alt c { + return match c { '\u01bb' | '\u01c0' to '\u01c3' | '\u0294' @@ -888,7 +888,7 @@ mod general_category { } pure fn Lt(c: char) -> bool { - return alt c { + return match c { '\u01c5' | '\u01c8' | '\u01cb' @@ -905,7 +905,7 @@ mod general_category { } pure fn Lu(c: char) -> bool { - return alt c { + return match c { '\x41' to '\x5a' | '\xc0' to '\xd6' | '\xd8' to '\xde' @@ -1497,7 +1497,7 @@ mod general_category { } pure fn Mc(c: char) -> bool { - return alt c { + return match c { '\u0903' | '\u093b' | '\u093e' to '\u0940' @@ -1608,7 +1608,7 @@ mod general_category { } pure fn Me(c: char) -> bool { - return alt c { + return match c { '\u0488' to '\u0489' | '\u20dd' to '\u20e0' | '\u20e2' to '\u20e4' @@ -1619,7 +1619,7 @@ mod general_category { } pure fn Mn(c: char) -> bool { - return alt c { + return match c { '\u0300' to '\u036f' | '\u0483' to '\u0487' | '\u0591' to '\u05bd' @@ -1812,7 +1812,7 @@ mod general_category { } pure fn Nd(c: char) -> bool { - return alt c { + return match c { '\x30' to '\x39' | '\u0660' to '\u0669' | '\u06f0' to '\u06f9' @@ -1856,7 +1856,7 @@ mod general_category { } pure fn Nl(c: char) -> bool { - return alt c { + return match c { '\u16ee' to '\u16f0' | '\u2160' to '\u2182' | '\u2185' to '\u2188' @@ -1875,7 +1875,7 @@ mod general_category { } pure fn No(c: char) -> bool { - return alt c { + return match c { '\xb2' to '\xb3' | '\xb9' | '\xbc' to '\xbe' @@ -1923,7 +1923,7 @@ mod general_category { } pure fn Pc(c: char) -> bool { - return alt c { + return match c { '\x5f' | '\u203f' to '\u2040' | '\u2054' @@ -1936,7 +1936,7 @@ mod general_category { } pure fn Pd(c: char) -> bool { - return alt c { + return match c { '\x2d' | '\u058a' | '\u05be' @@ -1958,7 +1958,7 @@ mod general_category { } pure fn Pe(c: char) -> bool { - return alt c { + return match c { '\x29' | '\x5d' | '\x7d' @@ -2035,7 +2035,7 @@ mod general_category { } pure fn Pf(c: char) -> bool { - return alt c { + return match c { '\xbb' | '\u2019' | '\u201d' @@ -2052,7 +2052,7 @@ mod general_category { } pure fn Pi(c: char) -> bool { - return alt c { + return match c { '\xab' | '\u2018' | '\u201b' to '\u201c' @@ -2070,7 +2070,7 @@ mod general_category { } pure fn Po(c: char) -> bool { - return alt c { + return match c { '\x21' to '\x23' | '\x25' to '\x27' | '\x2a' @@ -2203,7 +2203,7 @@ mod general_category { } pure fn Ps(c: char) -> bool { - return alt c { + return match c { '\x28' | '\x5b' | '\x7b' @@ -2282,7 +2282,7 @@ mod general_category { } pure fn Sc(c: char) -> bool { - return alt c { + return match c { '\x24' | '\xa2' to '\xa5' | '\u060b' @@ -2305,7 +2305,7 @@ mod general_category { } pure fn Sk(c: char) -> bool { - return alt c { + return match c { '\x5e' | '\x60' | '\xa8' @@ -2339,7 +2339,7 @@ mod general_category { } pure fn Sm(c: char) -> bool { - return alt c { + return match c { '\x2b' | '\x3c' to '\x3e' | '\x7c' @@ -2410,7 +2410,7 @@ mod general_category { } pure fn So(c: char) -> bool { - return alt c { + return match c { '\xa6' to '\xa7' | '\xa9' | '\xae' @@ -2529,21 +2529,21 @@ mod general_category { } pure fn Zl(c: char) -> bool { - return alt c { + return match c { '\u2028' => true, _ => false }; } pure fn Zp(c: char) -> bool { - return alt c { + return match c { '\u2029' => true, _ => false }; } pure fn Zs(c: char) -> bool { - return alt c { + return match c { '\x20' | '\xa0' | '\u1680' @@ -2561,7 +2561,7 @@ mod general_category { mod derived_property { /// Check if a character has the alphabetic unicode property pure fn Alphabetic(c: char) -> bool { - return alt c { + return match c { '\x41' to '\x5a' | '\x61' to '\x7a' | '\xaa' @@ -3299,7 +3299,7 @@ mod derived_property { } pure fn XID_Continue(c: char) -> bool { - return alt c { + return match c { '\x30' to '\x39' | '\x41' to '\x5a' | '\x5f' @@ -4170,7 +4170,7 @@ mod derived_property { } pure fn XID_Start(c: char) -> bool { - return alt c { + return match c { '\x41' to '\x5a' | '\x61' to '\x7a' | '\xaa' diff --git a/src/libcore/vec.rs b/src/libcore/vec.rs index 93bdd53d90d..fcfbb3ea135 100644 --- a/src/libcore/vec.rs +++ b/src/libcore/vec.rs @@ -356,7 +356,7 @@ fn split<T: copy>(v: &[T], f: fn(T) -> bool) -> ~[~[T]] { let mut start = 0u; let mut result = ~[]; while start < ln { - alt position_between(v, start, ln, f) { + match position_between(v, start, ln, f) { none => break, some(i) => { push(result, slice(v, start, i)); @@ -380,7 +380,7 @@ fn splitn<T: copy>(v: &[T], n: uint, f: fn(T) -> bool) -> ~[~[T]] { let mut count = n; let mut result = ~[]; while start < ln && count > 0u { - alt position_between(v, start, ln, f) { + match position_between(v, start, ln, f) { none => break, some(i) => { push(result, slice(v, start, i)); @@ -405,7 +405,7 @@ fn rsplit<T: copy>(v: &[T], f: fn(T) -> bool) -> ~[~[T]] { let mut end = ln; let mut result = ~[]; while end > 0u { - alt rposition_between(v, 0u, end, f) { + match rposition_between(v, 0u, end, f) { none => break, some(i) => { push(result, slice(v, i + 1u, end)); @@ -429,7 +429,7 @@ fn rsplitn<T: copy>(v: &[T], n: uint, f: fn(T) -> bool) -> ~[~[T]] { let mut count = n; let mut result = ~[]; while end > 0u && count > 0u { - alt rposition_between(v, 0u, end, f) { + match rposition_between(v, 0u, end, f) { none => break, some(i) => { push(result, slice(v, i + 1u, end)); @@ -713,7 +713,7 @@ pure fn filter_map<T, U: copy>(v: &[T], f: fn(T) -> option<U>) -> ~[U] { let mut result = ~[]; for each(v) |elem| { - alt f(elem) { + match f(elem) { none => {/* no-op */ } some(result_elem) => unsafe { push(result, result_elem); } } |
