Remove '.' after nullary tags in patterns
Does what it says on the tin. The next commit will remove support for this syntax.
This commit is contained in:
parent
ca7cfbe3d0
commit
04a2887f87
96 changed files with 1410 additions and 1410 deletions
|
|
@ -95,7 +95,7 @@ pure fn is_alphanumeric(c: char) -> bool {
|
|||
pure fn to_digit(c: char) -> u8 unsafe {
|
||||
alt maybe_digit(c) {
|
||||
option::some(x) { x }
|
||||
option::none. { fail; }
|
||||
option::none { fail; }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ mod ct {
|
|||
if !('0' as u8 <= c && c <= '9' as u8) { ret option::none; }
|
||||
let n = c - ('0' as u8) as uint;
|
||||
ret alt peek_num(s, i + 1u, lim) {
|
||||
none. { some({num: n, next: i + 1u}) }
|
||||
none { some({num: n, next: i + 1u}) }
|
||||
some(next) {
|
||||
let m = next.num;
|
||||
let j = next.next;
|
||||
|
|
@ -148,7 +148,7 @@ mod ct {
|
|||
if i >= lim { ret {param: none, next: i}; }
|
||||
let num = peek_num(s, i, lim);
|
||||
ret alt num {
|
||||
none. { {param: none, next: i} }
|
||||
none { {param: none, next: i} }
|
||||
some(t) {
|
||||
let n = t.num;
|
||||
let j = t.next;
|
||||
|
|
@ -194,13 +194,13 @@ mod ct {
|
|||
let param = parse_parameter(s, i + 1u, lim);
|
||||
let j = param.next;
|
||||
alt param.param {
|
||||
none. { {count: count_is_next_param, next: j} }
|
||||
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 {
|
||||
none. { {count: count_implied, next: i} }
|
||||
none { {count: count_implied, next: i} }
|
||||
some(num) {
|
||||
{count: count_is(num.num as int), next: num.next}
|
||||
}
|
||||
|
|
@ -218,7 +218,7 @@ mod ct {
|
|||
// If there were no digits specified, i.e. the precision
|
||||
// was ".", then the precision is 0
|
||||
alt count.count {
|
||||
count_implied. { {count: count_is(0), next: count.next} }
|
||||
count_implied { {count: count_is(0), next: count.next} }
|
||||
_ { count }
|
||||
}
|
||||
} else { {count: count_implied, next: i} };
|
||||
|
|
@ -300,11 +300,11 @@ mod rt {
|
|||
let prec = get_int_precision(cv);
|
||||
let rs =
|
||||
alt 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)) }
|
||||
ty_bits. { uint_to_str_prec(u, 2u, prec) }
|
||||
ty_octal. { uint_to_str_prec(u, 8u, prec) }
|
||||
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)) }
|
||||
ty_bits { uint_to_str_prec(u, 2u, prec) }
|
||||
ty_octal { uint_to_str_prec(u, 8u, prec) }
|
||||
};
|
||||
ret pad(cv, rs, pad_unsigned);
|
||||
}
|
||||
|
|
@ -325,7 +325,7 @@ mod rt {
|
|||
// FIXME: substr works on bytes, not chars!
|
||||
let unpadded =
|
||||
alt cv.precision {
|
||||
count_implied. { s }
|
||||
count_implied { s }
|
||||
count_is(max) {
|
||||
if max as uint < str::char_len(s) {
|
||||
str::substr(s, 0u, max as uint)
|
||||
|
|
@ -337,7 +337,7 @@ mod rt {
|
|||
fn conv_float(cv: conv, f: float) -> str {
|
||||
let (to_str, digits) = alt cv.precision {
|
||||
count_is(c) { (float::to_str_exact, c as uint) }
|
||||
count_implied. { (float::to_str, 6u) }
|
||||
count_implied { (float::to_str, 6u) }
|
||||
};
|
||||
let s = to_str(f, digits);
|
||||
if 0.0 <= f {
|
||||
|
|
@ -381,7 +381,7 @@ mod rt {
|
|||
fn get_int_precision(cv: conv) -> uint {
|
||||
ret alt cv.precision {
|
||||
count_is(c) { c as uint }
|
||||
count_implied. { 1u }
|
||||
count_implied { 1u }
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -395,7 +395,7 @@ mod rt {
|
|||
fn pad(cv: conv, s: str, mode: pad_mode) -> str {
|
||||
let uwidth;
|
||||
alt cv.width {
|
||||
count_implied. { ret s; }
|
||||
count_implied { ret s; }
|
||||
count_is(width) {
|
||||
// FIXME: Maybe width should be uint
|
||||
|
||||
|
|
@ -413,15 +413,15 @@ mod rt {
|
|||
let might_zero_pad = false;
|
||||
let signed = false;
|
||||
alt mode {
|
||||
pad_nozero. {
|
||||
pad_nozero {
|
||||
// fallthrough
|
||||
|
||||
}
|
||||
pad_signed. { might_zero_pad = true; signed = true; }
|
||||
pad_unsigned. { might_zero_pad = true; }
|
||||
pad_signed { might_zero_pad = true; signed = true; }
|
||||
pad_unsigned { might_zero_pad = true; }
|
||||
}
|
||||
fn have_precision(cv: conv) -> bool {
|
||||
ret alt cv.precision { count_implied. { false } _ { true } };
|
||||
ret alt cv.precision { count_implied { false } _ { true } };
|
||||
}
|
||||
let zero_padding = false;
|
||||
if might_zero_pad && have_flag(cv.flags, flag_left_zero_pad) &&
|
||||
|
|
|
|||
|
|
@ -31,13 +31,13 @@ Failure:
|
|||
Fails if the value equals `none`.
|
||||
*/
|
||||
pure fn get<T: copy>(opt: t<T>) -> T {
|
||||
alt opt { some(x) { ret x; } none. { fail "option none"; } }
|
||||
alt opt { some(x) { ret x; } none { fail "option none"; } }
|
||||
}
|
||||
|
||||
/*
|
||||
*/
|
||||
fn map<T, U: copy>(opt: t<T>, f: block(T) -> U) -> t<U> {
|
||||
alt opt { some(x) { some(f(x)) } none. { none } }
|
||||
alt opt { some(x) { some(f(x)) } none { none } }
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -46,7 +46,7 @@ Function: is_none
|
|||
Returns true if the option equals none
|
||||
*/
|
||||
pure fn is_none<T>(opt: t<T>) -> bool {
|
||||
alt opt { none. { true } some(_) { false } }
|
||||
alt opt { none { true } some(_) { false } }
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -62,7 +62,7 @@ Function: from_maybe
|
|||
Returns the contained value or a default
|
||||
*/
|
||||
pure fn from_maybe<T: copy>(def: T, opt: t<T>) -> T {
|
||||
alt opt { some(x) { x } none. { def } }
|
||||
alt opt { some(x) { x } none { def } }
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -71,7 +71,7 @@ Function: maybe
|
|||
Applies a function to the contained value or returns a default
|
||||
*/
|
||||
fn maybe<T, U: copy>(def: U, opt: t<T>, f: block(T) -> U) -> U {
|
||||
alt opt { none. { def } some(t) { f(t) } }
|
||||
alt opt { none { def } some(t) { f(t) } }
|
||||
}
|
||||
|
||||
// FIXME: Can be defined in terms of the above when/if we have const bind.
|
||||
|
|
@ -81,7 +81,7 @@ Function: may
|
|||
Performs an operation on the contained value or does nothing
|
||||
*/
|
||||
fn may<T>(opt: t<T>, f: block(T)) {
|
||||
alt opt { none. {/* nothing */ } some(t) { f(t); } }
|
||||
alt opt { none {/* nothing */ } some(t) { f(t); } }
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
|||
|
|
@ -369,8 +369,8 @@ fn try<T:send>(+f: fn~() -> T) -> result::t<T,()> {
|
|||
unsupervise();
|
||||
comm::send(ch, f());
|
||||
}) {
|
||||
tr_success. { result::ok(comm::recv(p)) }
|
||||
tr_failure. { result::err(()) }
|
||||
tr_success { result::ok(comm::recv(p)) }
|
||||
tr_failure { result::err(()) }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -405,7 +405,7 @@ mod tests {
|
|||
|
||||
let t = spawn_joinable {|| winner();};
|
||||
alt join(t) {
|
||||
tr_success. {/* yay! */ }
|
||||
tr_success {/* yay! */ }
|
||||
_ { fail "invalid task status received" }
|
||||
}
|
||||
}
|
||||
|
|
@ -418,7 +418,7 @@ mod tests {
|
|||
|
||||
let t = spawn_joinable {|| failer();};
|
||||
alt join(t) {
|
||||
tr_failure. {/* yay! */ }
|
||||
tr_failure {/* yay! */ }
|
||||
_ { fail "invalid task status received" }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue