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
|
|
@ -48,7 +48,7 @@ tag t<T> {
|
|||
|
||||
resource dtor_res(dtor: option::t<fn@()>) {
|
||||
alt dtor {
|
||||
option::none. { }
|
||||
option::none { }
|
||||
option::some(f) { f(); }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ fn maybe_get_doc(d: doc, tg: uint) -> option::t<doc> {
|
|||
fn get_doc(d: doc, tg: uint) -> doc {
|
||||
alt maybe_get_doc(d, tg) {
|
||||
some(d) { ret d; }
|
||||
none. {
|
||||
none {
|
||||
#error("failed to find block with tag %u", tg);
|
||||
fail;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -119,7 +119,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;
|
||||
|
|
@ -147,7 +147,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;
|
||||
|
|
@ -193,13 +193,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}
|
||||
}
|
||||
|
|
@ -217,7 +217,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} };
|
||||
|
|
@ -297,11 +297,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);
|
||||
}
|
||||
|
|
@ -322,7 +322,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)
|
||||
|
|
@ -334,7 +334,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 {
|
||||
|
|
@ -374,7 +374,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 }
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -388,7 +388,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
|
||||
|
||||
|
|
@ -406,15 +406,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) &&
|
||||
|
|
|
|||
|
|
@ -433,7 +433,7 @@ fn homedir() -> option<path> {
|
|||
secondary()
|
||||
}
|
||||
}
|
||||
none. {
|
||||
none {
|
||||
secondary()
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ Insert a value into the map
|
|||
*/
|
||||
fn insert<K: copy, V: copy>(m: treemap<K, V>, k: K, v: V) -> treemap<K, V> {
|
||||
@alt m {
|
||||
@empty. { node(@k, @v, @empty, @empty) }
|
||||
@empty { node(@k, @v, @empty, @empty) }
|
||||
@node(@kk, vv, left, right) {
|
||||
if k < kk {
|
||||
node(@kk, vv, insert(left, k, v), right)
|
||||
|
|
@ -70,7 +70,7 @@ Find a value based on the key
|
|||
*/
|
||||
fn find<K, V: copy>(m: treemap<K, V>, k: K) -> option<V> {
|
||||
alt *m {
|
||||
empty. { none }
|
||||
empty { none }
|
||||
node(@kk, @v, left, right) {
|
||||
if k == kk {
|
||||
some(v)
|
||||
|
|
@ -86,7 +86,7 @@ Visit all pairs in the map in order.
|
|||
*/
|
||||
fn traverse<K, V: copy>(m: treemap<K, V>, f: block(K, V)) {
|
||||
alt *m {
|
||||
empty. { }
|
||||
empty { }
|
||||
node(@k, @v, _, _) {
|
||||
// copy v to make aliases work out
|
||||
let v1 = v;
|
||||
|
|
|
|||
|
|
@ -255,16 +255,16 @@ fn getopts(args: [str], opts: [opt]) -> result {
|
|||
let optid;
|
||||
alt find_opt(opts, nm) {
|
||||
some(id) { optid = id; }
|
||||
none. { ret err(unrecognized_option(name_str(nm))); }
|
||||
none { ret err(unrecognized_option(name_str(nm))); }
|
||||
}
|
||||
alt opts[optid].hasarg {
|
||||
no. {
|
||||
no {
|
||||
if !option::is_none::<str>(i_arg) {
|
||||
ret err(unexpected_argument(name_str(nm)));
|
||||
}
|
||||
vals[optid] += [given];
|
||||
}
|
||||
maybe. {
|
||||
maybe {
|
||||
if !option::is_none::<str>(i_arg) {
|
||||
vals[optid] += [val(option::get(i_arg))];
|
||||
} else if name_pos < vec::len::<name>(names) ||
|
||||
|
|
@ -272,7 +272,7 @@ fn getopts(args: [str], opts: [opt]) -> result {
|
|||
vals[optid] += [given];
|
||||
} else { i += 1u; vals[optid] += [val(args[i])]; }
|
||||
}
|
||||
yes. {
|
||||
yes {
|
||||
if !option::is_none::<str>(i_arg) {
|
||||
vals[optid] += [val(option::get::<str>(i_arg))];
|
||||
} else if i + 1u == l {
|
||||
|
|
@ -306,7 +306,7 @@ fn getopts(args: [str], opts: [opt]) -> result {
|
|||
fn opt_vals(m: match, nm: str) -> [optval] {
|
||||
ret alt find_opt(m.opts, mkname(nm)) {
|
||||
some(id) { m.vals[id] }
|
||||
none. { #error("No option '%s' defined", nm); fail }
|
||||
none { #error("No option '%s' defined", nm); fail }
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -160,9 +160,9 @@ impl reader_util for reader {
|
|||
|
||||
fn convert_whence(whence: seek_style) -> i32 {
|
||||
ret alt whence {
|
||||
seek_set. { 0i32 }
|
||||
seek_cur. { 1i32 }
|
||||
seek_end. { 2i32 }
|
||||
seek_set { 0i32 }
|
||||
seek_cur { 1i32 }
|
||||
seek_end { 2i32 }
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -347,10 +347,10 @@ fn mk_file_writer(path: str, flags: [fileflag])
|
|||
os::libc_constants::O_WRONLY | os::libc_constants::O_BINARY;
|
||||
for f: fileflag in flags {
|
||||
alt f {
|
||||
append. { fflags |= os::libc_constants::O_APPEND; }
|
||||
create. { fflags |= os::libc_constants::O_CREAT; }
|
||||
truncate. { fflags |= os::libc_constants::O_TRUNC; }
|
||||
none. { }
|
||||
append { fflags |= os::libc_constants::O_APPEND; }
|
||||
create { fflags |= os::libc_constants::O_CREAT; }
|
||||
truncate { fflags |= os::libc_constants::O_TRUNC; }
|
||||
none { }
|
||||
}
|
||||
}
|
||||
let fd = str::as_buf(path, {|pathbuf|
|
||||
|
|
@ -469,9 +469,9 @@ fn seek_in_buf(offset: int, pos: uint, len: uint, whence: seek_style) ->
|
|||
let bpos = pos as int;
|
||||
let blen = len as int;
|
||||
alt whence {
|
||||
seek_set. { bpos = offset; }
|
||||
seek_cur. { bpos += offset; }
|
||||
seek_end. { bpos = blen + offset; }
|
||||
seek_set { bpos = offset; }
|
||||
seek_cur { bpos += offset; }
|
||||
seek_end { bpos = blen + offset; }
|
||||
}
|
||||
if bpos < 0 { bpos = 0; } else if bpos > blen { bpos = blen; }
|
||||
ret bpos as uint;
|
||||
|
|
@ -512,7 +512,7 @@ mod fsync {
|
|||
// Resource of artifacts that need to fsync on destruction
|
||||
resource res<t>(arg: arg<t>) {
|
||||
alt arg.opt_level {
|
||||
option::none. { }
|
||||
option::none { }
|
||||
option::some(level) {
|
||||
// fail hard if not succesful
|
||||
assert(arg.fsync_fn(arg.val, level) != -1);
|
||||
|
|
|
|||
|
|
@ -67,9 +67,9 @@ fn find<T: copy, U: copy>(ls: list<T>, f: block(T) -> option::t<U>)
|
|||
while true {
|
||||
alt ls {
|
||||
cons(hd, tl) {
|
||||
alt f(hd) { none. { ls = *tl; } some(rs) { ret some(rs); } }
|
||||
alt f(hd) { none { ls = *tl; } some(rs) { ret some(rs); } }
|
||||
}
|
||||
nil. { break; }
|
||||
nil { break; }
|
||||
}
|
||||
}
|
||||
ret none;
|
||||
|
|
@ -85,7 +85,7 @@ fn has<T: copy>(ls: list<T>, elt: T) -> bool {
|
|||
while true {
|
||||
alt ls {
|
||||
cons(hd, tl) { if elt == hd { ret true; } else { ls = *tl; } }
|
||||
nil. { break; }
|
||||
nil { break; }
|
||||
}
|
||||
}
|
||||
ret false;
|
||||
|
|
@ -98,7 +98,7 @@ Returns true if the list is empty.
|
|||
*/
|
||||
pure fn is_empty<T: copy>(ls: list<T>) -> bool {
|
||||
alt ls {
|
||||
nil. { true }
|
||||
nil { true }
|
||||
_ { false }
|
||||
}
|
||||
}
|
||||
|
|
@ -131,7 +131,7 @@ Returns all but the first element of a list
|
|||
pure fn tail<T: copy>(ls: list<T>) : is_not_empty(ls) -> list<T> {
|
||||
alt ls {
|
||||
cons(_, tl) { ret *tl; }
|
||||
nil. { fail "list empty" }
|
||||
nil { fail "list empty" }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -143,7 +143,7 @@ Returns the first element of a list
|
|||
pure fn head<T: copy>(ls: list<T>) : is_not_empty(ls) -> T {
|
||||
alt ls {
|
||||
cons(hd, _) { ret hd; }
|
||||
nil. { fail "list empty" }
|
||||
nil { fail "list empty" }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -154,7 +154,7 @@ Appends one list to another
|
|||
*/
|
||||
pure fn append<T: copy>(l: list<T>, m: list<T>) -> list<T> {
|
||||
alt l {
|
||||
nil. { ret m; }
|
||||
nil { ret m; }
|
||||
cons(x, xs) { let rest = append(*xs, m); ret cons(x, @rest); }
|
||||
}
|
||||
}
|
||||
|
|
@ -175,11 +175,11 @@ fn iter<T>(l: list<T>, f: block(T)) {
|
|||
f(hd);
|
||||
cur = tl;
|
||||
}
|
||||
nil. { break; }
|
||||
nil { break; }
|
||||
}
|
||||
}
|
||||
}
|
||||
nil. {}
|
||||
nil {}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -137,7 +137,7 @@ mod chained {
|
|||
let comp = 1u; // for logging
|
||||
while true {
|
||||
alt e0.next {
|
||||
absent. {
|
||||
absent {
|
||||
#debug("search_tbl: absent, comp %u, hash %u, idx %u",
|
||||
comp, h, idx);
|
||||
ret not_found;
|
||||
|
|
@ -162,7 +162,7 @@ mod chained {
|
|||
tbl: t<K,V>, k: K, h: uint) -> search_result<K,V> {
|
||||
let idx = h % vec::len(tbl.chains);
|
||||
alt tbl.chains[idx] {
|
||||
absent. {
|
||||
absent {
|
||||
#debug("search_tbl: absent, comp %u, hash %u, idx %u",
|
||||
0u, h, idx);
|
||||
ret not_found;
|
||||
|
|
@ -183,7 +183,7 @@ mod chained {
|
|||
fn insert<K: copy, V: copy>(tbl: t<K,V>, k: K, v: V) -> bool {
|
||||
let hash = tbl.hasher(k);
|
||||
alt search_tbl(tbl, k, hash) {
|
||||
not_found. {
|
||||
not_found {
|
||||
tbl.size += 1u;
|
||||
let idx = hash % vec::len(tbl.chains);
|
||||
let old_chain = tbl.chains[idx];
|
||||
|
|
@ -207,7 +207,7 @@ mod chained {
|
|||
|
||||
fn get<K: copy, V: copy>(tbl: t<K,V>, k: K) -> core::option::t<V> {
|
||||
alt search_tbl(tbl, k, tbl.hasher(k)) {
|
||||
not_found. {
|
||||
not_found {
|
||||
ret core::option::none;
|
||||
}
|
||||
|
||||
|
|
@ -223,7 +223,7 @@ mod chained {
|
|||
|
||||
fn remove<K: copy, V: copy>(tbl: t<K,V>, k: K) -> core::option::t<V> {
|
||||
alt search_tbl(tbl, k, tbl.hasher(k)) {
|
||||
not_found. {
|
||||
not_found {
|
||||
ret core::option::none;
|
||||
}
|
||||
|
||||
|
|
@ -250,7 +250,7 @@ mod chained {
|
|||
let chain = chain0;
|
||||
while true {
|
||||
alt chain {
|
||||
absent. { ret; }
|
||||
absent { ret; }
|
||||
present(entry) {
|
||||
let next = entry.next;
|
||||
blk(entry); // may modify entry.next!
|
||||
|
|
@ -569,7 +569,7 @@ mod tests {
|
|||
let v = hm.remove(i);
|
||||
alt v {
|
||||
option::some(u) { assert (u == i * i); }
|
||||
option::none. { fail; }
|
||||
option::none { fail; }
|
||||
}
|
||||
i += 2u;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -156,10 +156,10 @@ Concatenate two ropes
|
|||
*/
|
||||
fn append_rope(left: rope, right: rope) -> rope {
|
||||
alt(left) {
|
||||
node::empty. { ret right; }
|
||||
node::empty { ret right; }
|
||||
node::content(left_content) {
|
||||
alt(right) {
|
||||
node::empty. { ret left; }
|
||||
node::empty { ret left; }
|
||||
node::content(right_content) {
|
||||
ret node::content(node::concat2(left_content, right_content));
|
||||
}
|
||||
|
|
@ -224,10 +224,10 @@ to rebalance your rope at some point, before using it for other purposes.
|
|||
*/
|
||||
fn bal(rope:rope) -> rope {
|
||||
alt(rope) {
|
||||
node::empty. { ret rope }
|
||||
node::empty { ret rope }
|
||||
node::content(x) {
|
||||
alt(node::bal(x)) {
|
||||
option::none. { rope }
|
||||
option::none { rope }
|
||||
option::some(y) { node::content(y) }
|
||||
}
|
||||
}
|
||||
|
|
@ -255,7 +255,7 @@ valid positions in rope
|
|||
fn sub_chars(rope: rope, char_offset: uint, char_len: uint) -> rope {
|
||||
if char_len == 0u { ret node::empty; }
|
||||
alt(rope) {
|
||||
node::empty. { fail }
|
||||
node::empty { fail }
|
||||
node::content(node) {
|
||||
if char_len > node::char_len(node) { fail }
|
||||
else {
|
||||
|
|
@ -281,7 +281,7 @@ valid positions in rope
|
|||
fn sub_bytes(rope: rope, byte_offset: uint, byte_len: uint) -> rope {
|
||||
if byte_len == 0u { ret node::empty; }
|
||||
alt(rope) {
|
||||
node::empty. { fail }
|
||||
node::empty { fail }
|
||||
node::content(node) {
|
||||
if byte_len > node::byte_len(node) { fail }
|
||||
else {
|
||||
|
|
@ -309,9 +309,9 @@ value if `left > right`
|
|||
*/
|
||||
fn cmp(left: rope, right: rope) -> int {
|
||||
alt((left, right)) {
|
||||
(node::empty., node::empty.) { ret 0; }
|
||||
(node::empty., _) { ret -1;}
|
||||
(_, node::empty.) { ret 1;}
|
||||
(node::empty, node::empty) { ret 0; }
|
||||
(node::empty, _) { ret -1;}
|
||||
(_, node::empty) { ret 1;}
|
||||
(node::content(a), node::content(b)) {
|
||||
ret node::cmp(a, b);
|
||||
}
|
||||
|
|
@ -421,7 +421,7 @@ that is if `it` returned `false` at any point.
|
|||
*/
|
||||
fn loop_chars(rope: rope, it: block(char) -> bool) -> bool {
|
||||
alt(rope) {
|
||||
node::empty. { ret true }
|
||||
node::empty { ret true }
|
||||
node::content(x) { ret node::loop_chars(x, it) }
|
||||
}
|
||||
}
|
||||
|
|
@ -432,7 +432,7 @@ Function: iter_chars
|
|||
Loop through a rope, char by char, until the end.
|
||||
|
||||
Parameters:
|
||||
rope - A rope to traverse. It may be empty.
|
||||
rope - A rope to traverse. It may be empty
|
||||
it - A block to execute with each consecutive character of the rope.
|
||||
*/
|
||||
fn iter_chars(rope: rope, it: block(char)) {
|
||||
|
|
@ -457,9 +457,9 @@ use `traverse`.
|
|||
|
||||
Parameters:
|
||||
|
||||
rope - A rope to traverse. It may be empty.
|
||||
rope - A rope to traverse. It may be empty
|
||||
it - A block to execute with each consecutive string component of the rope.
|
||||
Return `true` to continue, `false` to stop.
|
||||
Return `true` to continue, `false` to stop
|
||||
|
||||
Returns:
|
||||
|
||||
|
|
@ -468,7 +468,7 @@ that is if `it` returned `false` at any point.
|
|||
*/
|
||||
fn loop_leaves(rope: rope, it: block(node::leaf) -> bool) -> bool{
|
||||
alt(rope) {
|
||||
node::empty. { ret true }
|
||||
node::empty { ret true }
|
||||
node::content(x) {ret node::loop_leaves(x, it)}
|
||||
}
|
||||
}
|
||||
|
|
@ -477,7 +477,7 @@ mod iterator {
|
|||
mod leaf {
|
||||
fn start(rope: rope) -> node::leaf_iterator::t {
|
||||
alt(rope) {
|
||||
node::empty. { ret node::leaf_iterator::empty() }
|
||||
node::empty { ret node::leaf_iterator::empty() }
|
||||
node::content(x) { ret node::leaf_iterator::start(x) }
|
||||
}
|
||||
}
|
||||
|
|
@ -488,7 +488,7 @@ mod iterator {
|
|||
mod char {
|
||||
fn start(rope: rope) -> node::char_iterator::t {
|
||||
alt(rope) {
|
||||
node::empty. { ret node::char_iterator::empty() }
|
||||
node::empty { ret node::char_iterator::empty() }
|
||||
node::content(x) { ret node::char_iterator::start(x) }
|
||||
}
|
||||
}
|
||||
|
|
@ -513,7 +513,7 @@ finding the leaf in which a character is contained.
|
|||
*/
|
||||
fn height(rope: rope) -> uint {
|
||||
alt(rope) {
|
||||
node::empty. { ret 0u; }
|
||||
node::empty { ret 0u; }
|
||||
node::content(x) { ret node::height(x); }
|
||||
}
|
||||
}
|
||||
|
|
@ -529,7 +529,7 @@ fn height(rope: rope) -> uint {
|
|||
*/
|
||||
pure fn char_len(rope: rope) -> uint {
|
||||
alt(rope) {
|
||||
node::empty. { ret 0u; }
|
||||
node::empty { ret 0u; }
|
||||
node::content(x) { ret node::char_len(x) }
|
||||
}
|
||||
}
|
||||
|
|
@ -543,7 +543,7 @@ pure fn char_len(rope: rope) -> uint {
|
|||
*/
|
||||
pure fn byte_len(rope: rope) -> uint {
|
||||
alt(rope) {
|
||||
node::empty. { ret 0u; }
|
||||
node::empty { ret 0u; }
|
||||
node::content(x) { ret node::byte_len(x) }
|
||||
}
|
||||
}
|
||||
|
|
@ -565,7 +565,7 @@ pure fn byte_len(rope: rope) -> uint {
|
|||
*/
|
||||
fn char_at(rope: rope, pos: uint) -> char {
|
||||
alt(rope) {
|
||||
node::empty. { fail }
|
||||
node::empty { fail }
|
||||
node::content(x) { ret node::char_at(x, pos) }
|
||||
}
|
||||
}
|
||||
|
|
@ -730,7 +730,7 @@ mod node {
|
|||
|
||||
If the slice is longer than `max_leaf_char_len`, it is logically split
|
||||
between as many leaves as necessary. Regardless, the string itself
|
||||
is not copied.
|
||||
is not copied
|
||||
|
||||
Parameters:
|
||||
byte_start - The byte offset where the slice of `str` starts.
|
||||
|
|
@ -752,7 +752,7 @@ mod node {
|
|||
|
||||
If the slice is longer than `max_leaf_char_len`, it is logically split
|
||||
between as many leaves as necessary. Regardless, the string itself
|
||||
is not copied.
|
||||
is not copied
|
||||
|
||||
byte_start - The byte offset where the slice of `str` starts.
|
||||
byte_len - The number of bytes from `str` to use.
|
||||
|
|
@ -897,7 +897,7 @@ mod node {
|
|||
let it = leaf_iterator::start(node);
|
||||
while true {
|
||||
alt(leaf_iterator::next(it)) {
|
||||
option::none. { break; }
|
||||
option::none { break; }
|
||||
option::some(x) {
|
||||
//TODO: Replace with memcpy or something similar
|
||||
let local_buf: [u8] = unsafe::reinterpret_cast(*x.content);
|
||||
|
|
@ -959,7 +959,7 @@ mod node {
|
|||
let it = leaf_iterator::start(node);
|
||||
while true {
|
||||
alt (leaf_iterator::next(it)) {
|
||||
option::none. { break; }
|
||||
option::none { break; }
|
||||
option::some(x) { forest += [mutable @leaf(x)]; }
|
||||
}
|
||||
}
|
||||
|
|
@ -1117,7 +1117,7 @@ mod node {
|
|||
let pos = 0u;
|
||||
while result == 0 {
|
||||
alt((char_iterator::next(ita), char_iterator::next(itb))) {
|
||||
(option::none., option::none.) {
|
||||
(option::none, option::none) {
|
||||
break;
|
||||
}
|
||||
(option::some(chara), option::some(charb)) {
|
||||
|
|
@ -1152,7 +1152,7 @@ mod node {
|
|||
|
||||
rope - A node to traverse.
|
||||
it - A block to execute with each consecutive leaf of the node.
|
||||
Return `true` to continue, `false` to stop.
|
||||
Return `true` to continue, `false` to stop
|
||||
|
||||
Returns:
|
||||
|
||||
|
|
@ -1277,11 +1277,11 @@ mod node {
|
|||
fn next(it: t) -> option::t<char> {
|
||||
while true {
|
||||
alt(get_current_or_next_leaf(it)) {
|
||||
option::none. { ret option::none; }
|
||||
option::none { ret option::none; }
|
||||
option::some(_) {
|
||||
let next_char = get_next_char_in_leaf(it);
|
||||
alt(next_char) {
|
||||
option::none. {
|
||||
option::none {
|
||||
cont;
|
||||
}
|
||||
option::some(_) {
|
||||
|
|
@ -1297,10 +1297,10 @@ mod node {
|
|||
fn get_current_or_next_leaf(it: t) -> option::t<leaf> {
|
||||
alt(it.leaf) {
|
||||
option::some(_) { ret it.leaf }
|
||||
option::none. {
|
||||
option::none {
|
||||
let next = leaf_iterator::next(it.leaf_iterator);
|
||||
alt(next) {
|
||||
option::none. { ret option::none }
|
||||
option::none { ret option::none }
|
||||
option::some(_) {
|
||||
it.leaf = next;
|
||||
it.leaf_byte_pos = 0u;
|
||||
|
|
@ -1313,7 +1313,7 @@ mod node {
|
|||
|
||||
fn get_next_char_in_leaf(it: t) -> option::t<char> {
|
||||
alt(it.leaf) {
|
||||
option::none. { ret option::none }
|
||||
option::none { ret option::none }
|
||||
option::some(aleaf) {
|
||||
if it.leaf_byte_pos >= aleaf.byte_len {
|
||||
//We are actually past the end of the leaf
|
||||
|
|
@ -1338,7 +1338,7 @@ mod tests {
|
|||
//Utility function, used for sanity check
|
||||
fn rope_to_string(r: rope) -> str {
|
||||
alt(r) {
|
||||
node::empty. { ret "" }
|
||||
node::empty { ret "" }
|
||||
node::content(x) {
|
||||
let str = @mutable "";
|
||||
fn aux(str: @mutable str, node: @node::node) {
|
||||
|
|
@ -1392,7 +1392,7 @@ mod tests {
|
|||
let pos = 0u;
|
||||
while equal {
|
||||
alt(node::char_iterator::next(rope_iter)) {
|
||||
option::none. {
|
||||
option::none {
|
||||
if string_iter < string_len {
|
||||
equal = false;
|
||||
} break; }
|
||||
|
|
@ -1420,7 +1420,7 @@ mod tests {
|
|||
let it = iterator::char::start(r);
|
||||
while true {
|
||||
alt(node::char_iterator::next(it)) {
|
||||
option::none. { break; }
|
||||
option::none { break; }
|
||||
option::some(_) { len += 1u; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ fn insert<T: copy>(m: smallintmap<T>, key: uint, val: T) {
|
|||
Function: find
|
||||
|
||||
Get the value for the specified key. If the key does not exist
|
||||
in the map then returns none.
|
||||
in the map then returns none
|
||||
*/
|
||||
fn find<T: copy>(m: smallintmap<T>, key: uint) -> option::t<T> {
|
||||
if key < vec::len::<option::t<T>>(m.v) { ret m.v[key]; }
|
||||
|
|
@ -56,7 +56,7 @@ If the key does not exist in the map
|
|||
*/
|
||||
fn get<T: copy>(m: smallintmap<T>, key: uint) -> T {
|
||||
alt find(m, key) {
|
||||
none. { #error("smallintmap::get(): key not present"); fail; }
|
||||
none { #error("smallintmap::get(): key not present"); fail; }
|
||||
some(v) { ret v; }
|
||||
}
|
||||
}
|
||||
|
|
@ -117,7 +117,7 @@ impl <V: copy> of map::map<uint, V> for smallintmap<V> {
|
|||
some(elt) {
|
||||
it(idx, elt);
|
||||
}
|
||||
none. { }
|
||||
none { }
|
||||
}
|
||||
idx += 1u;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ fn color_supported() -> bool {
|
|||
}
|
||||
false
|
||||
}
|
||||
option::none. { false }
|
||||
option::none { false }
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -131,18 +131,18 @@ fn run_tests_console_<T: copy>(opts: test_opts, tests: [test_desc<T>],
|
|||
te_wait(test) { st.out.write_str(#fmt["test %s ... ", test.name]); }
|
||||
te_result(test, result) {
|
||||
alt result {
|
||||
tr_ok. {
|
||||
tr_ok {
|
||||
st.passed += 1u;
|
||||
write_ok(st.out, st.use_color);
|
||||
st.out.write_line("");
|
||||
}
|
||||
tr_failed. {
|
||||
tr_failed {
|
||||
st.failed += 1u;
|
||||
write_failed(st.out, st.use_color);
|
||||
st.out.write_line("");
|
||||
st.failures += [test];
|
||||
}
|
||||
tr_ignored. {
|
||||
tr_ignored {
|
||||
st.ignored += 1u;
|
||||
write_ignored(st.out, st.use_color);
|
||||
st.out.write_line("");
|
||||
|
|
@ -260,7 +260,7 @@ fn filter_tests<T: copy>(opts: test_opts,
|
|||
let filter_str =
|
||||
alt opts.filter {
|
||||
option::some(f) { f }
|
||||
option::none. { "" }
|
||||
option::none { "" }
|
||||
};
|
||||
|
||||
fn filter_fn<T: copy>(test: test_desc<T>, filter_str: str) ->
|
||||
|
|
@ -315,11 +315,11 @@ fn run_test<T: copy>(test: test_desc<T>,
|
|||
ret {test: test,
|
||||
wait: fn@() -> test_result {
|
||||
alt task::join(test_task) {
|
||||
task::tr_success. {
|
||||
task::tr_success {
|
||||
if test.should_fail { tr_failed }
|
||||
else { tr_ok }
|
||||
}
|
||||
task::tr_failure. {
|
||||
task::tr_failure {
|
||||
if test.should_fail { tr_ok }
|
||||
else { tr_failed }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ Insert a value into the map
|
|||
*/
|
||||
fn insert<K: copy, V: copy>(m: treemap<K, V>, k: K, v: V) {
|
||||
alt m {
|
||||
@empty. { *m = node(@k, @v, @mutable empty, @mutable empty); }
|
||||
@empty { *m = node(@k, @v, @mutable empty, @mutable empty); }
|
||||
@node(@kk, _, _, _) {
|
||||
|
||||
// We have to name left and right individually, because
|
||||
|
|
@ -65,7 +65,7 @@ Find a value based on the key
|
|||
*/
|
||||
fn find<K: copy, V: copy>(m: treemap<K, V>, k: K) -> option<V> {
|
||||
alt *m {
|
||||
empty. { none }
|
||||
empty { none }
|
||||
node(@kk, @v, _, _) {
|
||||
if k == kk {
|
||||
some(v)
|
||||
|
|
@ -85,7 +85,7 @@ Visit all pairs in the map in order.
|
|||
*/
|
||||
fn traverse<K, V>(m: treemap<K, V>, f: block(K, V)) {
|
||||
alt *m {
|
||||
empty. { }
|
||||
empty { }
|
||||
node(k, v, _, _) {
|
||||
let k1 = k, v1 = v;
|
||||
alt *m { node(_, _, left, _) { traverse(left, f); } }
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ fn grow(ufnd: ufind, n: uint) {
|
|||
|
||||
fn find(ufnd: ufind, n: uint) -> uint {
|
||||
alt ufnd.nodes[n] {
|
||||
none. { ret n; }
|
||||
none { ret n; }
|
||||
some(m) { let m_ = m; be find(ufnd, m_); }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue