diff options
| author | Michael Sullivan <sully@msully.net> | 2012-06-25 20:00:46 -0700 |
|---|---|---|
| committer | Michael Sullivan <sully@msully.net> | 2012-06-25 20:00:46 -0700 |
| commit | 329eca6044fdf376a7a89ec7a96dba7a8b884cf7 (patch) | |
| tree | 7008814278a066914b6ba36818388d5212ffda9f /src/libstd | |
| parent | c087aaf56b1109163126fea4c2760f8414ffbe56 (diff) | |
| download | rust-329eca6044fdf376a7a89ec7a96dba7a8b884cf7.tar.gz rust-329eca6044fdf376a7a89ec7a96dba7a8b884cf7.zip | |
Make vectors uglier ([]/~). Sorry. Should be temporary. Closes #2725.
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/arena.rs | 4 | ||||
| -rw-r--r-- | src/libstd/bitv.rs | 56 | ||||
| -rw-r--r-- | src/libstd/deque.rs | 6 | ||||
| -rw-r--r-- | src/libstd/ebml.rs | 12 | ||||
| -rw-r--r-- | src/libstd/getopts.rs | 219 | ||||
| -rw-r--r-- | src/libstd/json.rs | 70 | ||||
| -rw-r--r-- | src/libstd/list.rs | 24 | ||||
| -rw-r--r-- | src/libstd/map.rs | 24 | ||||
| -rw-r--r-- | src/libstd/md4.rs | 10 | ||||
| -rw-r--r-- | src/libstd/net_tcp.rs | 48 | ||||
| -rw-r--r-- | src/libstd/par.rs | 25 | ||||
| -rw-r--r-- | src/libstd/rope.rs | 16 | ||||
| -rw-r--r-- | src/libstd/serialization.rs | 8 | ||||
| -rw-r--r-- | src/libstd/sha1.rs | 40 | ||||
| -rw-r--r-- | src/libstd/sort.rs | 91 | ||||
| -rw-r--r-- | src/libstd/term.rs | 10 | ||||
| -rw-r--r-- | src/libstd/test.rs | 38 | ||||
| -rw-r--r-- | src/libstd/time.rs | 36 | ||||
| -rw-r--r-- | src/libstd/timer.rs | 2 | ||||
| -rw-r--r-- | src/libstd/uv_ll.rs | 16 |
20 files changed, 379 insertions, 376 deletions
diff --git a/src/libstd/arena.rs b/src/libstd/arena.rs index 163deef0640..ede119bb459 100644 --- a/src/libstd/arena.rs +++ b/src/libstd/arena.rs @@ -5,11 +5,11 @@ export arena, arena_with_size; import list; import list::{list, cons, nil}; -type chunk = {data: [u8], mut fill: uint}; +type chunk = {data: [u8]/~, mut fill: uint}; type arena = {mut chunks: @list<@chunk>}; fn chunk(size: uint) -> @chunk { - let mut v = []; + let mut v = []/~; vec::reserve(v, size); @{ data: v, mut fill: 0u } } diff --git a/src/libstd/bitv.rs b/src/libstd/bitv.rs index 254ed4d4ede..2cbc9ae0187 100644 --- a/src/libstd/bitv.rs +++ b/src/libstd/bitv.rs @@ -22,7 +22,7 @@ export eq_vec; // for the case where nbits <= 32. #[doc = "The bitvector type"] -type bitv = @{storage: [mut uint], nbits: uint}; +type bitv = @{storage: [mut uint]/~, nbits: uint}; const uint_bits: uint = 32u + (1u << 32u >> 27u); @@ -183,7 +183,7 @@ Converts the bitvector to a vector of uint with the same length. Each uint in the resulting vector has either value 0u or 1u. "] -fn to_vec(v: bitv) -> [uint] { +fn to_vec(v: bitv) -> [uint]/~ { let sub = {|x|init_to_vec(v, x)}; ret vec::from_fn::<uint>(v.nbits, sub); } @@ -225,7 +225,7 @@ Compare a bitvector to a vector of uint The uint vector is expected to only contain the values 0u and 1u. Both the bitvector and vector must have the same length "] -fn eq_vec(v0: bitv, v1: [uint]) -> bool { +fn eq_vec(v0: bitv, v1: [uint]/~) -> bool { assert (v0.nbits == vec::len::<uint>(v1)); let len = v0.nbits; let mut i = 0u; @@ -262,9 +262,9 @@ mod tests { fn test_1_element() { let mut act; act = bitv(1u, false); - assert (eq_vec(act, [0u])); + assert (eq_vec(act, [0u]/~)); act = bitv(1u, true); - assert (eq_vec(act, [1u])); + assert (eq_vec(act, [1u]/~)); } #[test] @@ -273,11 +273,11 @@ mod tests { // all 0 act = bitv(10u, false); - assert (eq_vec(act, [0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u])); + assert (eq_vec(act, [0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u]/~)); // all 1 act = bitv(10u, true); - assert (eq_vec(act, [1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u])); + assert (eq_vec(act, [1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u]/~)); // mixed act = bitv(10u, false); @@ -286,7 +286,7 @@ mod tests { set(act, 2u, true); set(act, 3u, true); set(act, 4u, true); - assert (eq_vec(act, [1u, 1u, 1u, 1u, 1u, 0u, 0u, 0u, 0u, 0u])); + assert (eq_vec(act, [1u, 1u, 1u, 1u, 1u, 0u, 0u, 0u, 0u, 0u]/~)); // mixed act = bitv(10u, false); @@ -295,7 +295,7 @@ mod tests { set(act, 7u, true); set(act, 8u, true); set(act, 9u, true); - assert (eq_vec(act, [0u, 0u, 0u, 0u, 0u, 1u, 1u, 1u, 1u, 1u])); + assert (eq_vec(act, [0u, 0u, 0u, 0u, 0u, 1u, 1u, 1u, 1u, 1u]/~)); // mixed act = bitv(10u, false); @@ -303,7 +303,7 @@ mod tests { set(act, 3u, true); set(act, 6u, true); set(act, 9u, true); - assert (eq_vec(act, [1u, 0u, 0u, 1u, 0u, 0u, 1u, 0u, 0u, 1u])); + assert (eq_vec(act, [1u, 0u, 0u, 1u, 0u, 0u, 1u, 0u, 0u, 1u]/~)); } #[test] @@ -315,14 +315,14 @@ mod tests { assert (eq_vec(act, [0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, - 0u, 0u, 0u, 0u, 0u])); + 0u, 0u, 0u, 0u, 0u]/~)); // all 1 act = bitv(31u, true); assert (eq_vec(act, [1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, - 1u, 1u, 1u, 1u, 1u])); + 1u, 1u, 1u, 1u, 1u]/~)); // mixed act = bitv(31u, false); @@ -337,7 +337,7 @@ mod tests { assert (eq_vec(act, [1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, - 0u, 0u, 0u, 0u, 0u])); + 0u, 0u, 0u, 0u, 0u]/~)); // mixed act = bitv(31u, false); @@ -352,7 +352,7 @@ mod tests { assert (eq_vec(act, [0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 0u, 0u, - 0u, 0u, 0u, 0u, 0u])); + 0u, 0u, 0u, 0u, 0u]/~)); // mixed act = bitv(31u, false); @@ -366,7 +366,7 @@ mod tests { assert (eq_vec(act, [0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 1u, 1u, - 1u, 1u, 1u, 1u, 1u])); + 1u, 1u, 1u, 1u, 1u]/~)); // mixed act = bitv(31u, false); @@ -376,7 +376,7 @@ mod tests { assert (eq_vec(act, [0u, 0u, 0u, 1u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 1u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, - 0u, 0u, 0u, 0u, 1u])); + 0u, 0u, 0u, 0u, 1u]/~)); } #[test] @@ -388,14 +388,14 @@ mod tests { assert (eq_vec(act, [0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, - 0u, 0u, 0u, 0u, 0u, 0u])); + 0u, 0u, 0u, 0u, 0u, 0u]/~)); // all 1 act = bitv(32u, true); assert (eq_vec(act, [1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, - 1u, 1u, 1u, 1u, 1u, 1u])); + 1u, 1u, 1u, 1u, 1u, 1u]/~)); // mixed act = bitv(32u, false); @@ -410,7 +410,7 @@ mod tests { assert (eq_vec(act, [1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, - 0u, 0u, 0u, 0u, 0u, 0u])); + 0u, 0u, 0u, 0u, 0u, 0u]/~)); // mixed act = bitv(32u, false); @@ -425,7 +425,7 @@ mod tests { assert (eq_vec(act, [0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 0u, 0u, - 0u, 0u, 0u, 0u, 0u, 0u])); + 0u, 0u, 0u, 0u, 0u, 0u]/~)); // mixed act = bitv(32u, false); @@ -440,7 +440,7 @@ mod tests { assert (eq_vec(act, [0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 1u, 1u, - 1u, 1u, 1u, 1u, 1u, 1u])); + 1u, 1u, 1u, 1u, 1u, 1u]/~)); // mixed act = bitv(32u, false); @@ -451,7 +451,7 @@ mod tests { assert (eq_vec(act, [0u, 0u, 0u, 1u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 1u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, - 0u, 0u, 0u, 0u, 1u, 1u])); + 0u, 0u, 0u, 0u, 1u, 1u]/~)); } #[test] @@ -463,14 +463,14 @@ mod tests { assert (eq_vec(act, [0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, - 0u, 0u, 0u, 0u, 0u, 0u, 0u])); + 0u, 0u, 0u, 0u, 0u, 0u, 0u]/~)); // all 1 act = bitv(33u, true); assert (eq_vec(act, [1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, - 1u, 1u, 1u, 1u, 1u, 1u, 1u])); + 1u, 1u, 1u, 1u, 1u, 1u, 1u]/~)); // mixed act = bitv(33u, false); @@ -485,7 +485,7 @@ mod tests { assert (eq_vec(act, [1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, - 0u, 0u, 0u, 0u, 0u, 0u, 0u])); + 0u, 0u, 0u, 0u, 0u, 0u, 0u]/~)); // mixed act = bitv(33u, false); @@ -500,7 +500,7 @@ mod tests { assert (eq_vec(act, [0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 0u, 0u, - 0u, 0u, 0u, 0u, 0u, 0u, 0u])); + 0u, 0u, 0u, 0u, 0u, 0u, 0u]/~)); // mixed act = bitv(33u, false); @@ -515,7 +515,7 @@ mod tests { assert (eq_vec(act, [0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 1u, 1u, - 1u, 1u, 1u, 1u, 1u, 1u, 0u])); + 1u, 1u, 1u, 1u, 1u, 1u, 0u]/~)); // mixed act = bitv(33u, false); @@ -527,7 +527,7 @@ mod tests { assert (eq_vec(act, [0u, 0u, 0u, 1u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 1u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, 0u, - 0u, 0u, 0u, 0u, 1u, 1u, 1u])); + 0u, 0u, 0u, 0u, 1u, 1u, 1u]/~)); } #[test] diff --git a/src/libstd/deque.rs b/src/libstd/deque.rs index f57d2a21af6..2a9e663a08c 100644 --- a/src/libstd/deque.rs +++ b/src/libstd/deque.rs @@ -24,10 +24,10 @@ fn create<T: copy>() -> t<T> { * Grow is only called on full elts, so nelts is also len(elts), unlike * elsewhere. */ - fn grow<T: copy>(nelts: uint, lo: uint, -elts: [mut cell<T>]) -> - [mut cell<T>] { + fn grow<T: copy>(nelts: uint, lo: uint, -elts: [mut cell<T>]/~) -> + [mut cell<T>]/~ { assert (nelts == vec::len(elts)); - let mut rv = [mut]; + let mut rv = [mut]/~; let mut i = 0u; let nalloc = uint::next_power_of_two(nelts + 1u); diff --git a/src/libstd/ebml.rs b/src/libstd/ebml.rs index d02c498025c..3a7b88ae7a9 100644 --- a/src/libstd/ebml.rs +++ b/src/libstd/ebml.rs @@ -35,7 +35,7 @@ type ebml_state = {ebml_tag: ebml_tag, tag_pos: uint, data_pos: uint}; // modules within this file. // ebml reading -type doc = {data: @[u8], start: uint, end: uint}; +type doc = {data: @[u8]/~, start: uint, end: uint}; type tagged_doc = {tag: uint, doc: doc}; @@ -62,11 +62,11 @@ fn vuint_at(data: [u8]/&, start: uint) -> {val: uint, next: uint} { } else { #error("vint too big"); fail; } } -fn doc(data: @[u8]) -> doc { +fn doc(data: @[u8]/~) -> doc { ret {data: data, start: 0u, end: vec::len::<u8>(*data)}; } -fn doc_at(data: @[u8], start: uint) -> tagged_doc { +fn doc_at(data: @[u8]/~, start: uint) -> tagged_doc { let elt_tag = vuint_at(*data, start); let elt_size = vuint_at(*data, elt_tag.next); let end = elt_size.next + elt_size.val; @@ -119,7 +119,7 @@ fn tagged_docs(d: doc, tg: uint, it: fn(doc)) { } } -fn doc_data(d: doc) -> [u8] { ret vec::slice::<u8>(*d.data, d.start, d.end); } +fn doc_data(d: doc) -> [u8]/~ { vec::slice::<u8>(*d.data, d.start, d.end) } fn doc_as_str(d: doc) -> str { ret str::from_bytes(doc_data(d)); } @@ -149,7 +149,7 @@ fn doc_as_i32(d: doc) -> i32 { doc_as_u32(d) as i32 } fn doc_as_i64(d: doc) -> i64 { doc_as_u64(d) as i64 } // ebml writing -type writer = {writer: io::writer, mut size_positions: [uint]}; +type writer = {writer: io::writer, mut size_positions: [uint]/~}; fn write_sized_vuint(w: io::writer, n: uint, size: uint) { alt size { @@ -180,7 +180,7 @@ fn write_vuint(w: io::writer, n: uint) { } fn writer(w: io::writer) -> writer { - let size_positions: [uint] = []; + let size_positions: [uint]/~ = []/~; ret {writer: w, mut size_positions: size_positions}; } diff --git a/src/libstd/getopts.rs b/src/libstd/getopts.rs index a08536f9441..351542111ef 100644 --- a/src/libstd/getopts.rs +++ b/src/libstd/getopts.rs @@ -28,12 +28,12 @@ name following -o, and accepts both -h and --help as optional flags. } fn print_usage(program: str) { - io::println(\"Usage: \" + program + \" [options]\"); + io::println(\"Usage: \" + program + \" [options]/~\"); io::println(\"-o\t\tOutput\"); io::println(\"-h --help\tUsage\"); } - fn main(args: [str]) { + fn main(args: [str]/~) { check vec::is_not_empty(args); let program : str = vec::head(args); @@ -42,7 +42,7 @@ name following -o, and accepts both -h and --help as optional flags. optopt(\"o\"), optflag(\"h\"), optflag(\"help\") - ]; + ]/~; let match = alt getopts(vec::tail(args), opts) { result::ok(m) { m } result::err(f) { fail fail_str(f) } @@ -134,7 +134,7 @@ enum optval { val(str), given, } The result of checking command line arguments. Contains a vector of matches and a vector of free strings. "] -type match = {opts: [opt], vals: [[optval]], free: [str]}; +type match = {opts: [opt]/~, vals: [[optval]/~]/~, free: [str]/~}; fn is_arg(arg: str) -> bool { ret str::len(arg) > 1u && arg[0] == '-' as u8; @@ -144,7 +144,7 @@ fn name_str(nm: name) -> str { ret alt nm { short(ch) { str::from_char(ch) } long(s) { s } }; } -fn find_opt(opts: [opt], nm: name) -> option<uint> { +fn find_opt(opts: [opt]/~, nm: name) -> option<uint> { vec::position(opts, { |opt| opt.name == nm }) } @@ -188,21 +188,21 @@ On success returns `ok(opt)`. Use functions such as `opt_present` `opt_str`, etc. to interrogate results. Returns `err(fail_)` on failure. Use <fail_str> to get an error message. "] -fn getopts(args: [str], opts: [opt]) -> result unsafe { +fn getopts(args: [str]/~, opts: [opt]/~) -> result unsafe { let n_opts = vec::len::<opt>(opts); - fn f(_x: uint) -> [optval] { ret []; } + fn f(_x: uint) -> [optval]/~ { ret []/~; } let vals = vec::to_mut(vec::from_fn(n_opts, f)); - let mut free: [str] = []; + let mut free: [str]/~ = []/~; let l = vec::len(args); let mut i = 0u; while i < l { let cur = args[i]; let curlen = str::len(cur); if !is_arg(cur) { - free += [cur]; + free += [cur]/~; } else if str::eq(cur, "--") { let mut j = i + 1u; - while j < l { free += [args[j]]; j += 1u; } + while j < l { vec::push(free, args[j]); j += 1u; } break; } else { let mut names; @@ -211,19 +211,19 @@ fn getopts(args: [str], opts: [opt]) -> result unsafe { let tail = str::slice(cur, 2u, curlen); let tail_eq = str::splitn_char(tail, '=', 1u); if vec::len(tail_eq) <= 1u { - names = [long(tail)]; + names = [long(tail)]/~; } else { names = - [long(tail_eq[0])]; + [long(tail_eq[0])]/~; i_arg = option::some::<str>(tail_eq[1]); } } else { let mut j = 1u; - names = []; + names = []/~; while j < curlen { let range = str::char_range_at(cur, j); - names += [short(range.ch)]; + names += [short(range.ch)]/~; j = range.next; } } @@ -239,22 +239,23 @@ fn getopts(args: [str], opts: [opt]) -> result unsafe { if !option::is_none::<str>(i_arg) { ret err(unexpected_argument(name_str(nm))); } - vals[optid] += [given]; + vec::push(vals[optid], given); } maybe { if !option::is_none::<str>(i_arg) { - vals[optid] += [val(option::get(i_arg))]; + vec::push(vals[optid], val(option::get(i_arg))); } else if name_pos < vec::len::<name>(names) || i + 1u == l || is_arg(args[i + 1u]) { - vals[optid] += [given]; - } else { i += 1u; vals[optid] += [val(args[i])]; } + vec::push(vals[optid], given); + } else { i += 1u; vec::push(vals[optid], val(args[i])); } } yes { if !option::is_none::<str>(i_arg) { - vals[optid] += [val(option::get::<str>(i_arg))]; + vec::push(vals[optid], + val(option::get::<str>(i_arg))); } else if i + 1u == l { ret err(argument_missing(name_str(nm))); - } else { i += 1u; vals[optid] += [val(args[i])]; } + } else { i += 1u; vec::push(vals[optid], val(args[i])); } } } } @@ -280,7 +281,7 @@ fn getopts(args: [str], opts: [opt]) -> result unsafe { ret ok({opts: opts, vals: vec::from_mut(vals), free: free}); } -fn opt_vals(m: match, nm: str) -> [optval] { +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 } @@ -295,7 +296,7 @@ fn opt_present(m: match, nm: str) -> bool { } #[doc = "Returns true if any of several options were matched"] -fn opts_present(m: match, names: [str]) -> bool { +fn opts_present(m: match, names: [str]/~) -> bool { for vec::each(names) {|nm| alt find_opt(m.opts, mkname(nm)) { some(_) { ret true; } @@ -321,7 +322,7 @@ Returns the string argument supplied to one of several matching options Fails if the no option was provided from the given list, or if the no such option took an argument "] -fn opts_str(m: match, names: [str]) -> str { +fn opts_str(m: match, names: [str]/~) -> str { for vec::each(names) {|nm| alt opt_val(m, nm) { val(s) { ret s } @@ -337,10 +338,10 @@ Returns a vector of the arguments provided to all matches of the given option. Used when an option accepts multiple values. "] -fn opt_strs(m: match, nm: str) -> [str] { - let mut acc: [str] = []; +fn opt_strs(m: match, nm: str) -> [str]/~ { + let mut acc: [str]/~ = []/~; for vec::each(opt_vals(m, nm)) {|v| - alt v { val(s) { acc += [s]; } _ { } } + alt v { val(s) { acc += [s]/~; } _ { } } } ret acc; } @@ -395,8 +396,8 @@ mod tests { // Tests for reqopt #[test] fn test_reqopt_long() { - let args = ["--test=20"]; - let opts = [reqopt("test")]; + let args = ["--test=20"]/~; + let opts = [reqopt("test")]/~; let rs = getopts(args, opts); alt check rs { ok(m) { @@ -408,8 +409,8 @@ mod tests { #[test] fn test_reqopt_long_missing() { - let args = ["blah"]; - let opts = [reqopt("test")]; + let args = ["blah"]/~; + let opts = [reqopt("test")]/~; let rs = getopts(args, opts); alt rs { err(f) { check_fail_type(f, option_missing_); } @@ -419,8 +420,8 @@ mod tests { #[test] fn test_reqopt_long_no_arg() { - let args = ["--test"]; - let opts = [reqopt("test")]; + let args = ["--test"]/~; + let opts = [reqopt("test")]/~; let rs = getopts(args, opts); alt rs { err(f) { check_fail_type(f, argument_missing_); } @@ -430,8 +431,8 @@ mod tests { #[test] fn test_reqopt_long_multi() { - let args = ["--test=20", "--test=30"]; - let opts = [reqopt("test")]; + let args = ["--test=20", "--test=30"]/~; + let opts = [reqopt("test")]/~; let rs = getopts(args, opts); alt rs { err(f) { check_fail_type(f, option_duplicated_); } @@ -441,8 +442,8 @@ mod tests { #[test] fn test_reqopt_short() { - let args = ["-t", "20"]; - let opts = [reqopt("t")]; + let args = ["-t", "20"]/~; + let opts = [reqopt("t")]/~; let rs = getopts(args, opts); alt rs { ok(m) { @@ -455,8 +456,8 @@ mod tests { #[test] fn test_reqopt_short_missing() { - let args = ["blah"]; - let opts = [reqopt("t")]; + let args = ["blah"]/~; + let opts = [reqopt("t")]/~; let rs = getopts(args, opts); alt rs { err(f) { check_fail_type(f, option_missing_); } @@ -466,8 +467,8 @@ mod tests { #[test] fn test_reqopt_short_no_arg() { - let args = ["-t"]; - let opts = [reqopt("t")]; + let args = ["-t"]/~; + let opts = [reqopt("t")]/~; let rs = getopts(args, opts); alt rs { err(f) { check_fail_type(f, argument_missing_); } @@ -477,8 +478,8 @@ mod tests { #[test] fn test_reqopt_short_multi() { - let args = ["-t", "20", "-t", "30"]; - let opts = [reqopt("t")]; + let args = ["-t", "20", "-t", "30"]/~; + let opts = [reqopt("t")]/~; let rs = getopts(args, opts); alt rs { err(f) { check_fail_type(f, option_duplicated_); } @@ -490,8 +491,8 @@ mod tests { // Tests for optopt #[test] fn test_optopt_long() { - let args = ["--test=20"]; - let opts = [optopt("test")]; + let args = ["--test=20"]/~; + let opts = [optopt("test")]/~; let rs = getopts(args, opts); alt rs { ok(m) { @@ -504,8 +505,8 @@ mod tests { #[test] fn test_optopt_long_missing() { - let args = ["blah"]; - let opts = [optopt("test")]; + let args = ["blah"]/~; + let opts = [optopt("test")]/~; let rs = getopts(args, opts); alt rs { ok(m) { assert (!opt_present(m, "test")); } @@ -515,8 +516,8 @@ mod tests { #[test] fn test_optopt_long_no_arg() { - let args = ["--test"]; - let opts = [optopt("test")]; + let args = ["--test"]/~; + let opts = [optopt("test")]/~; let rs = getopts(args, opts); alt rs { err(f) { check_fail_type(f, argument_missing_); } @@ -526,8 +527,8 @@ mod tests { #[test] fn test_optopt_long_multi() { - let args = ["--test=20", "--test=30"]; - let opts = [optopt("test")]; + let args = ["--test=20", "--test=30"]/~; + let opts = [optopt("test")]/~; let rs = getopts(args, opts); alt rs { err(f) { check_fail_type(f, option_duplicated_); } @@ -537,8 +538,8 @@ mod tests { #[test] fn test_optopt_short() { - let args = ["-t", "20"]; - let opts = [optopt("t")]; + let args = ["-t", "20"]/~; + let opts = [optopt("t")]/~; let rs = getopts(args, opts); alt rs { ok(m) { @@ -551,8 +552,8 @@ mod tests { #[test] fn test_optopt_short_missing() { - let args = ["blah"]; - let opts = [optopt("t")]; + let args = ["blah"]/~; + let opts = [optopt("t")]/~; let rs = getopts(args, opts); alt rs { ok(m) { assert (!opt_present(m, "t")); } @@ -562,8 +563,8 @@ mod tests { #[test] fn test_optopt_short_no_arg() { - let args = ["-t"]; - let opts = [optopt("t")]; + let args = ["-t"]/~; + let opts = [optopt("t")]/~; let rs = getopts(args, opts); alt rs { err(f) { check_fail_type(f, argument_missing_); } @@ -573,8 +574,8 @@ mod tests { #[test] fn test_optopt_short_multi() { - let args = ["-t", "20", "-t", "30"]; - let opts = [optopt("t")]; + let args = ["-t", "20", "-t", "30"]/~; + let opts = [optopt("t")]/~; let rs = getopts(args, opts); alt rs { err(f) { check_fail_type(f, option_duplicated_); } @@ -586,8 +587,8 @@ mod tests { // Tests for optflag #[test] fn test_optflag_long() { - let args = ["--test"]; - let opts = [optflag("test")]; + let args = ["--test"]/~; + let opts = [optflag("test")]/~; let rs = getopts(args, opts); alt rs { ok(m) { assert (opt_present(m, "test")); } @@ -597,8 +598,8 @@ mod tests { #[test] fn test_optflag_long_missing() { - let args = ["blah"]; - let opts = [optflag("test")]; + let args = ["blah"]/~; + let opts = [optflag("test")]/~; let rs = getopts(args, opts); alt rs { ok(m) { assert (!opt_present(m, "test")); } @@ -608,8 +609,8 @@ mod tests { #[test] fn test_optflag_long_arg() { - let args = ["--test=20"]; - let opts = [optflag("test")]; + let args = ["--test=20"]/~; + let opts = [optflag("test")]/~; let rs = getopts(args, opts); alt rs { err(f) { @@ -622,8 +623,8 @@ mod tests { #[test] fn test_optflag_long_multi() { - let args = ["--test", "--test"]; - let opts = [optflag("test")]; + let args = ["--test", "--test"]/~; + let opts = [optflag("test")]/~; let rs = getopts(args, opts); alt rs { err(f) { check_fail_type(f, option_duplicated_); } @@ -633,8 +634,8 @@ mod tests { #[test] fn test_optflag_short() { - let args = ["-t"]; - let opts = [optflag("t")]; + let args = ["-t"]/~; + let opts = [optflag("t")]/~; let rs = getopts(args, opts); alt rs { ok(m) { assert (opt_present(m, "t")); } @@ -644,8 +645,8 @@ mod tests { #[test] fn test_optflag_short_missing() { - let args = ["blah"]; - let opts = [optflag("t")]; + let args = ["blah"]/~; + let opts = [optflag("t")]/~; let rs = getopts(args, opts); alt rs { ok(m) { assert (!opt_present(m, "t")); } @@ -655,8 +656,8 @@ mod tests { #[test] fn test_optflag_short_arg() { - let args = ["-t", "20"]; - let opts = [optflag("t")]; + let args = ["-t", "20"]/~; + let opts = [optflag("t")]/~; let rs = getopts(args, opts); alt rs { ok(m) { @@ -670,8 +671,8 @@ mod tests { #[test] fn test_optflag_short_multi() { - let args = ["-t", "-t"]; - let opts = [optflag("t")]; + let args = ["-t", "-t"]/~; + let opts = [optflag("t")]/~; let rs = getopts(args, opts); alt rs { err(f) { check_fail_type(f, option_duplicated_); } @@ -683,8 +684,8 @@ mod tests { // Tests for optmulti #[test] fn test_optmulti_long() { - let args = ["--test=20"]; - let opts = [optmulti("test")]; + let args = ["--test=20"]/~; + let opts = [optmulti("test")]/~; let rs = getopts(args, opts); alt rs { ok(m) { @@ -697,8 +698,8 @@ mod tests { #[test] fn test_optmulti_long_missing() { - let args = ["blah"]; - let opts = [optmulti("test")]; + let args = ["blah"]/~; + let opts = [optmulti("test")]/~; let rs = getopts(args, opts); alt rs { ok(m) { assert (!opt_present(m, "test")); } @@ -708,8 +709,8 @@ mod tests { #[test] fn test_optmulti_long_no_arg() { - let args = ["--test"]; - let opts = [optmulti("test")]; + let args = ["--test"]/~; + let opts = [optmulti("test")]/~; let rs = getopts(args, opts); alt rs { err(f) { check_fail_type(f, argument_missing_); } @@ -719,8 +720,8 @@ mod tests { #[test] fn test_optmulti_long_multi() { - let args = ["--test=20", "--test=30"]; - let opts = [optmulti("test")]; + let args = ["--test=20", "--test=30"]/~; + let opts = [optmulti("test")]/~; let rs = getopts(args, opts); alt rs { ok(m) { @@ -735,8 +736,8 @@ mod tests { #[test] fn test_optmulti_short() { - let args = ["-t", "20"]; - let opts = [optmulti("t")]; + let args = ["-t", "20"]/~; + let opts = [optmulti("t")]/~; let rs = getopts(args, opts); alt rs { ok(m) { @@ -749,8 +750,8 @@ mod tests { #[test] fn test_optmulti_short_missing() { - let args = ["blah"]; - let opts = [optmulti("t")]; + let args = ["blah"]/~; + let opts = [optmulti("t")]/~; let rs = getopts(args, opts); alt rs { ok(m) { assert (!opt_present(m, "t")); } @@ -760,8 +761,8 @@ mod tests { #[test] fn test_optmulti_short_no_arg() { - let args = ["-t"]; - let opts = [optmulti("t")]; + let args = ["-t"]/~; + let opts = [optmulti("t")]/~; let rs = getopts(args, opts); alt rs { err(f) { check_fail_type(f, argument_missing_); } @@ -771,8 +772,8 @@ mod tests { #[test] fn test_optmulti_short_multi() { - let args = ["-t", "20", "-t", "30"]; - let opts = [optmulti("t")]; + let args = ["-t", "20", "-t", "30"]/~; + let opts = [optmulti("t")]/~; let rs = getopts(args, opts); alt rs { ok(m) { @@ -787,8 +788,8 @@ mod tests { #[test] fn test_unrecognized_option_long() { - let args = ["--untest"]; - let opts = [optmulti("t")]; + let args = ["--untest"]/~; + let opts = [optmulti("t")]/~; let rs = getopts(args, opts); alt rs { err(f) { check_fail_type(f, unrecognized_option_); } @@ -798,8 +799,8 @@ mod tests { #[test] fn test_unrecognized_option_short() { - let args = ["-t"]; - let opts = [optmulti("test")]; + let args = ["-t"]/~; + let opts = [optmulti("test")]/~; let rs = getopts(args, opts); alt rs { err(f) { check_fail_type(f, unrecognized_option_); } @@ -811,11 +812,11 @@ mod tests { fn test_combined() { let args = ["prog", "free1", "-s", "20", "free2", "--flag", "--long=30", - "-f", "-m", "40", "-m", "50", "-n", "-A B", "-n", "-60 70"]; + "-f", "-m", "40", "-m", "50", "-n", "-A B", "-n", "-60 70"]/~; let opts = [optopt("s"), optflag("flag"), reqopt("long"), optflag("f"), optmulti("m"), optmulti("n"), - optopt("notpresent")]; + optopt("notpresent")]/~; let rs = getopts(args, opts); alt rs { ok(m) { @@ -838,23 +839,23 @@ mod tests { #[test] fn test_multi() { - let args = ["-e", "foo", "--encrypt", "foo"]; - let opts = [optopt("e"), optopt("encrypt")]; + let args = ["-e", "foo", "--encrypt", "foo"]/~; + let opts = [optopt("e"), optopt("encrypt")]/~; let match = alt getopts(args, opts) { result::ok(m) { m } result::err(f) { fail; } }; - assert opts_present(match, ["e"]); - assert opts_present(match, ["encrypt"]); - assert opts_present(match, ["encrypt", "e"]); - assert opts_present(match, ["e", "encrypt"]); - assert !opts_present(match, ["thing"]); - assert !opts_present(match, []); - - assert opts_str(match, ["e"]) == "foo"; - assert opts_str(match, ["encrypt"]) == "foo"; - assert opts_str(match, ["e", "encrypt"]) == "foo"; - assert opts_str(match, ["encrypt", "e"]) == "foo"; + assert opts_present(match, ["e"]/~); + assert opts_present(match, ["encrypt"]/~); + assert opts_present(match, ["encrypt", "e"]/~); + assert opts_present(match, ["e", "encrypt"]/~); + assert !opts_present(match, ["thing"]/~); + assert !opts_present(match, []/~); + + assert opts_str(match, ["e"]/~) == "foo"; + assert opts_str(match, ["encrypt"]/~) == "foo"; + assert opts_str(match, ["e", "encrypt"]/~) == "foo"; + assert opts_str(match, ["encrypt", "e"]/~) == "foo"; } } diff --git a/src/libstd/json.rs b/src/libstd/json.rs index a5a5ac31035..947b037841e 100644 --- a/src/libstd/json.rs +++ b/src/libstd/json.rs @@ -30,7 +30,7 @@ enum json { num(float), string(@str), boolean(bool), - list(@[json]), + list(@[json]/~), dict(map::hashmap<str, json>), null, } @@ -383,7 +383,7 @@ impl parser for parser { self.bump(); self.parse_whitespace(); - let mut values = []; + let mut values = []/~; if self.ch == ']' { self.bump(); @@ -585,7 +585,7 @@ impl of to_json for @str { impl <A: to_json copy, B: to_json copy> of to_json for (A, B) { fn to_json() -> json { let (a, b) = self; - list(@[a.to_json(), b.to_json()]) + list(@[a.to_json(), b.to_json()]/~) } } @@ -593,11 +593,11 @@ impl <A: to_json copy, B: to_json copy, C: to_json copy> of to_json for (A, B, C) { fn to_json() -> json { let (a, b, c) = self; - list(@[a.to_json(), b.to_json(), c.to_json()]) + list(@[a.to_json(), b.to_json(), c.to_json()]/~) } } -impl <A: to_json> of to_json for [A] { +impl <A: to_json> of to_json for [A]/~ { fn to_json() -> json { list(@self.map { |elt| elt.to_json() }) } } @@ -632,7 +632,7 @@ impl of to_str::to_str for error { #[cfg(test)] mod tests { - fn mk_dict(items: [(str, json)]) -> json { + fn mk_dict(items: [(str, json)]/~) -> json { let d = map::str_hash(); vec::iter(items) { |item| @@ -670,26 +670,26 @@ mod tests { #[test] fn test_write_list() { - assert to_str(list(@[])) == "[]"; - assert to_str(list(@[boolean(true)])) == "[true]"; + assert to_str(list(@[]/~)) == "[]"; + assert to_str(list(@[boolean(true)]/~)) == "[true]"; assert to_str(list(@[ boolean(false), null, - list(@[string(@"foo\nbar"), num(3.5f)]) - ])) == "[false, null, [\"foo\\nbar\", 3.5]]"; + list(@[string(@"foo\nbar"), num(3.5f)]/~) + ]/~)) == "[false, null, [\"foo\\nbar\", 3.5]]"; } #[test] fn test_write_dict() { - assert to_str(mk_dict([])) == "{}"; - assert to_str(mk_dict([("a", boolean(true))])) == "{ \"a\": true }"; + assert to_str(mk_dict([]/~)) == "{}"; + assert to_str(mk_dict([("a", boolean(true))]/~)) == "{ \"a\": true }"; assert to_str(mk_dict([ ("a", boolean(true)), ("b", list(@[ - mk_dict([("c", string(@"\x0c\r"))]), - mk_dict([("d", string(@""))]) - ])) - ])) == + mk_dict([("c", string(@"\x0c\r"))]/~), + mk_dict([("d", string(@""))]/~) + ]/~)) + ]/~)) == "{ " + "\"a\": true, " + "\"b\": [" + @@ -709,7 +709,7 @@ mod tests { err({line: 1u, col: 6u, msg: @"trailing characters"}); assert from_str("1a") == err({line: 1u, col: 2u, msg: @"trailing characters"}); - assert from_str("[]a") == + assert from_str("[]/~a") == err({line: 1u, col: 3u, msg: @"trailing characters"}); assert from_str("{}a") == err({line: 1u, col: 3u, msg: @"trailing characters"}); @@ -798,15 +798,15 @@ mod tests { assert from_str("[6 7]") == err({line: 1u, col: 4u, msg: @"expecting ',' or ']'"}); - assert from_str("[]") == ok(list(@[])); - assert from_str("[ ]") == ok(list(@[])); - assert from_str("[true]") == ok(list(@[boolean(true)])); - assert from_str("[ false ]") == ok(list(@[boolean(false)])); - assert from_str("[null]") == ok(list(@[null])); - assert from_str("[3, 1]") == ok(list(@[num(3f), num(1f)])); - assert from_str("\n[3, 2]\n") == ok(list(@[num(3f), num(2f)])); + assert from_str("[]") == ok(list(@[]/~)); + assert from_str("[ ]") == ok(list(@[]/~)); + assert from_str("[true]") == ok(list(@[boolean(true)]/~)); + assert from_str("[ false ]") == ok(list(@[boolean(false)]/~)); + assert from_str("[null]") == ok(list(@[null]/~)); + assert from_str("[3, 1]") == ok(list(@[num(3f), num(1f)]/~)); + assert from_str("\n[3, 2]\n") == ok(list(@[num(3f), num(2f)]/~)); assert from_str("[2, [4, 1]]") == - ok(list(@[num(2f), list(@[num(4f), num(1f)])])); + ok(list(@[num(2f), list(@[num(4f), num(1f)]/~)]/~)); } #[test] @@ -835,23 +835,23 @@ mod tests { assert from_str("{\"a\":1,") == err({line: 1u, col: 8u, msg: @"EOF while parsing object"}); - assert eq(result::get(from_str("{}")), mk_dict([])); + assert eq(result::get(from_str("{}")), mk_dict([]/~)); assert eq(result::get(from_str("{\"a\": 3}")), - mk_dict([("a", num(3.0f))])); + mk_dict([("a", num(3.0f))]/~)); assert eq(result::get(from_str("{ \"a\": null, \"b\" : true }")), mk_dict([ ("a", null), - ("b", boolean(true))])); + ("b", boolean(true))]/~)); assert eq(result::get(from_str("\n{ \"a\": null, \"b\" : true }\n")), mk_dict([ ("a", null), - ("b", boolean(true))])); + ("b", boolean(true))]/~)); assert eq(result::get(from_str("{\"a\" : 1.0 ,\"b\": [ true ]}")), mk_dict([ ("a", num(1.0)), - ("b", list(@[boolean(true)])) - ])); + ("b", list(@[boolean(true)]/~)) + ]/~)); assert eq(result::get(from_str( "{" + "\"a\": 1.0, " + @@ -867,10 +867,10 @@ mod tests { boolean(true), string(@"foo\nbar"), mk_dict([ - ("c", mk_dict([("d", null)])) - ]) - ])) - ])); + ("c", mk_dict([("d", null)]/~)) + ]/~) + ]/~)) + ]/~)); } #[test] diff --git a/src/libstd/list.rs b/src/libstd/list.rs index 5a468df4c88..ad7828da8c6 100644 --- a/src/libstd/list.rs +++ b/src/libstd/list.rs @@ -10,7 +10,7 @@ enum list<T> { } #[doc = "Create a list from a vector"] -fn from_vec<T: copy>(v: [T]) -> @list<T> { +fn from_vec<T: copy>(v: [T]/~) -> @list<T> { vec::foldr(v, @nil::<T>, { |h, t| @cons(h, t) }) } @@ -135,9 +135,9 @@ mod tests { #[test] fn test_is_empty() { - let empty : @list::list<int> = from_vec([]); - let full1 = from_vec([1]); - let full2 = from_vec(['r', 'u']); + let empty : @list::list<int> = from_vec([]/~); + let full1 = from_vec([1]/~); + let full2 = from_vec(['r', 'u']/~); assert is_empty(empty); assert !is_empty(full1); @@ -150,7 +150,7 @@ mod tests { #[test] fn test_from_vec() { - let l = from_vec([0, 1, 2]); + let l = from_vec([0, 1, 2]/~); assert (head(l) == 0); @@ -163,14 +163,14 @@ mod tests { #[test] fn test_from_vec_empty() { - let empty : @list::list<int> = from_vec([]); + let empty : @list::list<int> = from_vec([]/~); assert (empty == @list::nil::<int>); } #[test] fn test_foldl() { fn add(&&a: uint, &&b: int) -> uint { ret a + (b as uint); } - let l = from_vec([0, 1, 2, 3, 4]); + let l = from_vec([0, 1, 2, 3, 4]/~); let empty = @list::nil::<int>; assert (list::foldl(0u, l, add) == 10u); assert (list::foldl(0u, empty, add) == 0u); @@ -181,21 +181,21 @@ mod tests { fn sub(&&a: int, &&b: int) -> int { a - b } - let l = from_vec([1, 2, 3, 4]); + let l = from_vec([1, 2, 3, 4]/~); assert (list::foldl(0, l, sub) == -10); } #[test] fn test_find_success() { fn match(&&i: int) -> bool { ret i == 2; } - let l = from_vec([0, 1, 2]); + let l = from_vec([0, 1, 2]/~); assert (list::find(l, match) == option::some(2)); } #[test] fn test_find_fail() { fn match(&&_i: int) -> bool { ret false; } - let l = from_vec([0, 1, 2]); + let l = from_vec([0, 1, 2]/~); let empty = @list::nil::<int>; assert (list::find(l, match) == option::none::<int>); assert (list::find(empty, match) == option::none::<int>); @@ -203,7 +203,7 @@ mod tests { #[test] fn test_has() { - let l = from_vec([5, 8, 6]); + let l = from_vec([5, 8, 6]/~); let empty = @list::nil::<int>; assert (list::has(l, 5)); assert (!list::has(l, 7)); @@ -213,7 +213,7 @@ mod tests { #[test] fn test_len() { - let l = from_vec([0, 1, 2]); + let l = from_vec([0, 1, 2]/~); let empty = @list::nil::<int>; assert (list::len(l) == 3u); assert (list::len(empty) == 0u); diff --git a/src/libstd/map.rs b/src/libstd/map.rs index c988b167fd0..7d1e7b599a0 100644 --- a/src/libstd/map.rs +++ b/src/libstd/map.rs @@ -86,7 +86,7 @@ mod chained { type t<K, V> = @{ mut count: uint, - mut chains: [mut chain<K,V>], + mut chains: [mut chain<K,V>]/~, hasher: hashfn<K>, eqer: eqfn<K> }; @@ -259,7 +259,7 @@ mod chained { fn each_value(blk: fn(V) -> bool) { self.each { |_k, v| blk(v)} } } - fn chains<K,V>(nchains: uint) -> [mut chain<K,V>] { + fn chains<K,V>(nchains: uint) -> [mut chain<K,V>]/~ { ret vec::to_mut(vec::from_elem(nchains, absent)); } @@ -299,7 +299,7 @@ fn box_str_hash<V: copy>() -> hashmap<@str, V> { } #[doc = "Construct a hashmap for byte string keys"] -fn bytes_hash<V: copy>() -> hashmap<[u8], V> { +fn bytes_hash<V: copy>() -> hashmap<[u8]/~, V> { ret hashmap(vec::u8::hash, vec::u8::eq); } @@ -323,10 +323,10 @@ fn set_add<K: const copy>(set: set<K>, key: K) -> bool { #[doc = " Convert a set into a vector. "] -fn vec_from_set<T: copy>(s: set<T>) -> [T] { - let mut v = []; +fn vec_from_set<T: copy>(s: set<T>) -> [T]/~ { + let mut v = []/~; s.each_key() {|k| - v += [k]; + v += [k]/~; true }; v @@ -334,7 +334,7 @@ fn vec_from_set<T: copy>(s: set<T>) -> [T] { #[doc = "Construct a hashmap from a vector"] fn hash_from_vec<K: const copy, V: copy>(hasher: hashfn<K>, eqer: eqfn<K>, - items: [(K, V)]) -> hashmap<K, V> { + items: [(K, V)]/~) -> hashmap<K, V> { let map = hashmap(hasher, eqer); vec::iter(items) { |item| let (key, value) = item; @@ -344,22 +344,22 @@ fn hash_from_vec<K: const copy, V: copy>(hasher: hashfn<K>, eqer: eqfn<K>, } #[doc = "Construct a hashmap from a vector with string keys"] -fn hash_from_strs<V: copy>(items: [(str, V)]) -> hashmap<str, V> { +fn hash_from_strs<V: copy>(items: [(str, V)]/~) -> hashmap<str, V> { hash_from_vec(str::hash, str::eq, items) } #[doc = "Construct a hashmap from a vector with byte keys"] -fn hash_from_bytes<V: copy>(items: [([u8], V)]) -> hashmap<[u8], V> { +fn hash_from_bytes<V: copy>(items: [([u8]/~, V)]/~) -> hashmap<[u8]/~, V> { hash_from_vec(vec::u8::hash, vec::u8::eq, items) } #[doc = "Construct a hashmap from a vector with int keys"] -fn hash_from_ints<V: copy>(items: [(int, V)]) -> hashmap<int, V> { +fn hash_from_ints<V: copy>(items: [(int, V)]/~) -> hashmap<int, V> { hash_from_vec(int::hash, int::eq, items) } #[doc = "Construct a hashmap from a vector with uint keys"] -fn hash_from_uints<V: copy>(items: [(uint, V)]) -> hashmap<uint, V> { +fn hash_from_uints<V: copy>(items: [(uint, V)]/~) -> hashmap<uint, V> { hash_from_vec(uint::hash, uint::eq, items) } @@ -612,7 +612,7 @@ mod tests { ("a", 1), ("b", 2), ("c", 3) - ]); + ]/~); assert map.size() == 3u; assert map.get("a") == 1; assert map.get("b") == 2; diff --git a/src/libstd/md4.rs b/src/libstd/md4.rs index 8f790c88ae9..08fa6f8597a 100644 --- a/src/libstd/md4.rs +++ b/src/libstd/md4.rs @@ -1,21 +1,21 @@ -fn md4(msg: [u8]) -> {a: u32, b: u32, c: u32, d: u32} { +fn md4(msg: [u8]/~) -> {a: u32, b: u32, c: u32, d: u32} { // subtle: if orig_len is merely uint, then the code below // which performs shifts by 32 bits or more has undefined // results. let orig_len: u64 = (vec::len(msg) * 8u) as u64; // pad message - let mut msg = msg + [0x80u8]; + let mut msg = msg + [0x80u8]/~; let mut bitlen = orig_len + 8u64; while (bitlen + 64u64) % 512u64 > 0u64 { - msg += [0u8]; + msg += [0u8]/~; bitlen += 8u64; } // append length let mut i = 0u64; while i < 8u64 { - msg += [(orig_len >> (i * 8u64)) as u8]; + msg += [(orig_len >> (i * 8u64)) as u8]/~; i += 1u64; } @@ -82,7 +82,7 @@ fn md4(msg: [u8]) -> {a: u32, b: u32, c: u32, d: u32} { ret {a: a, b: b, c: c, d: d}; } -fn md4_str(msg: [u8]) -> str { +fn md4_str(msg: [u8]/~) -> str { let {a, b, c, d} = md4(msg); fn app(a: u32, b: u32, c: u32, d: u32, f: fn(u32)) { f(a); f(b); f(c); f(d); diff --git a/src/libstd/net_tcp.rs b/src/libstd/net_tcp.rs index c828566841e..386e869d983 100644 --- a/src/libstd/net_tcp.rs +++ b/src/libstd/net_tcp.rs @@ -113,7 +113,7 @@ fn connect(input_ip: ip::ip_addr, port: uint, closed_signal_ch: comm::chan(closed_signal_po) }; let conn_data_ptr = ptr::addr_of(conn_data); - let reader_po = comm::port::<result::result<[u8], tcp_err_data>>(); + let reader_po = comm::port::<result::result<[u8]/~, tcp_err_data>>(); let stream_handle_ptr = malloc_uv_tcp_t(); *(stream_handle_ptr as *mut uv::ll::uv_tcp_t) = uv::ll::tcp_t(); let socket_data = @{ @@ -206,7 +206,7 @@ Write binary data to a tcp stream; Blocks until operation completes # Arguments * sock - a `tcp_socket` to write to -* raw_write_data - a vector of `[u8]` that will be written to the stream. +* raw_write_data - a vector of `[u8]/~` that will be written to the stream. This value must remain valid for the duration of the `write` call # Returns @@ -214,7 +214,7 @@ This value must remain valid for the duration of the `write` call A `result` object with a `nil` value as the `ok` variant, or a `tcp_err_data` value as the `err` variant "] -fn write(sock: tcp_socket, raw_write_data: [u8]) +fn write(sock: tcp_socket, raw_write_data: [u8]/~) -> result::result<(), tcp_err_data> unsafe { let socket_data_ptr = ptr::addr_of(*(sock.socket_data)); write_common_impl(socket_data_ptr, raw_write_data) @@ -238,7 +238,7 @@ Otherwise, use the blocking `tcp::write` function instead. # Arguments * sock - a `tcp_socket` to write to -* raw_write_data - a vector of `[u8]` that will be written to the stream. +* raw_write_data - a vector of `[u8]/~` that will be written to the stream. This value must remain valid for the duration of the `write` call # Returns @@ -247,7 +247,7 @@ A `future` value that, once the `write` operation completes, resolves to a `result` object with a `nil` value as the `ok` variant, or a `tcp_err_data` value as the `err` variant "] -fn write_future(sock: tcp_socket, raw_write_data: [u8]) +fn write_future(sock: tcp_socket, raw_write_data: [u8]/~) -> future::future<result::result<(), tcp_err_data>> unsafe { let socket_data_ptr = ptr::addr_of(*(sock.socket_data)); future::spawn {|| @@ -270,7 +270,7 @@ on) from until `read_stop` is called, or a `tcp_err_data` record "] fn read_start(sock: tcp_socket) -> result::result<comm::port< - result::result<[u8], tcp_err_data>>, tcp_err_data> unsafe { + result::result<[u8]/~, tcp_err_data>>, tcp_err_data> unsafe { let socket_data = ptr::addr_of(*(sock.socket_data)); read_start_common_impl(socket_data) } @@ -303,13 +303,13 @@ data received. read attempt. Pass `0u` to wait indefinitely "] fn read(sock: tcp_socket, timeout_msecs: uint) - -> result::result<[u8],tcp_err_data> { + -> result::result<[u8]/~,tcp_err_data> { let socket_data = ptr::addr_of(*(sock.socket_data)); read_common_impl(socket_data, timeout_msecs) } #[doc=" -Reads a single chunk of data; returns a `future::future<[u8]>` immediately +Reads a single chunk of data; returns a `future::future<[u8]/~>` immediately Does a non-blocking read operation for a single chunk of data from a `tcp_socket` and immediately returns a `future` value representing the @@ -337,7 +337,7 @@ Otherwise, use the blocking `tcp::read` function instead. read attempt. Pass `0u` to wait indefinitely "] fn read_future(sock: tcp_socket, timeout_msecs: uint) - -> future::future<result::result<[u8],tcp_err_data>> { + -> future::future<result::result<[u8]/~,tcp_err_data>> { let socket_data = ptr::addr_of(*(sock.socket_data)); future::spawn {|| read_common_impl(socket_data, timeout_msecs) @@ -590,7 +590,7 @@ fn accept(new_conn: tcp_new_connection) new_tcp_conn(server_handle_ptr) { let server_data_ptr = uv::ll::get_data_for_uv_handle( server_handle_ptr) as *tcp_listen_fc_data; - let reader_po = comm::port::<result::result<[u8], tcp_err_data>>(); + let reader_po = comm::port::<result::result<[u8]/~, tcp_err_data>>(); let iotask = (*server_data_ptr).iotask; let stream_handle_ptr = malloc_uv_tcp_t(); *(stream_handle_ptr as *mut uv::ll::uv_tcp_t) = uv::ll::tcp_t(); @@ -790,7 +790,7 @@ Convenience methods extending `net::tcp::tcp_socket` "] impl sock_methods for tcp_socket { fn read_start() -> result::result<comm::port< - result::result<[u8], tcp_err_data>>, tcp_err_data> { + result::result<[u8]/~, tcp_err_data>>, tcp_err_data> { read_start(self) } fn read_stop() -> @@ -798,18 +798,18 @@ impl sock_methods for tcp_socket { read_stop(self) } fn read(timeout_msecs: uint) -> - result::result<[u8], tcp_err_data> { + result::result<[u8]/~, tcp_err_data> { read(self, timeout_msecs) } fn read_future(timeout_msecs: uint) -> - future::future<result::result<[u8], tcp_err_data>> { + future::future<result::result<[u8]/~, tcp_err_data>> { read_future(self, timeout_msecs) } - fn write(raw_write_data: [u8]) + fn write(raw_write_data: [u8]/~) -> result::result<(), tcp_err_data> { write(self, raw_write_data) } - fn write_future(raw_write_data: [u8]) + fn write_future(raw_write_data: [u8]/~) -> future::future<result::result<(), tcp_err_data>> { write_future(self, raw_write_data) } @@ -818,7 +818,7 @@ impl sock_methods for tcp_socket { // shared implementation for tcp::read fn read_common_impl(socket_data: *tcp_socket_data, timeout_msecs: uint) - -> result::result<[u8],tcp_err_data> unsafe { + -> result::result<[u8]/~,tcp_err_data> unsafe { log(debug, "starting tcp::read"); let iotask = (*socket_data).iotask; let rs_result = read_start_common_impl(socket_data); @@ -887,7 +887,7 @@ fn read_stop_common_impl(socket_data: *tcp_socket_data) -> // shared impl for read_start fn read_start_common_impl(socket_data: *tcp_socket_data) -> result::result<comm::port< - result::result<[u8], tcp_err_data>>, tcp_err_data> unsafe { + result::result<[u8]/~, tcp_err_data>>, tcp_err_data> unsafe { let stream_handle_ptr = (*socket_data).stream_handle_ptr; let start_po = comm::port::<option<uv::ll::uv_err_data>>(); let start_ch = comm::chan(start_po); @@ -920,14 +920,14 @@ fn read_start_common_impl(socket_data: *tcp_socket_data) // shared implementation used by write and write_future fn write_common_impl(socket_data_ptr: *tcp_socket_data, - raw_write_data: [u8]) + raw_write_data: [u8]/~) -> result::result<(), tcp_err_data> unsafe { let write_req_ptr = ptr::addr_of((*socket_data_ptr).write_req); let stream_handle_ptr = (*socket_data_ptr).stream_handle_ptr; let write_buf_vec = [ uv::ll::buf_init( vec::unsafe::to_ptr(raw_write_data), - vec::len(raw_write_data)) ]; + vec::len(raw_write_data)) ]/~; let write_buf_vec_ptr = ptr::addr_of(write_buf_vec); let result_po = comm::port::<tcp_write_result>(); let write_data = { @@ -968,7 +968,7 @@ fn conn_port_new_tcp_socket( iotask: iotask) -> result::result<tcp_socket,tcp_err_data> unsafe { // tcp_nl_on_connection_cb - let reader_po = comm::port::<result::result<[u8], tcp_err_data>>(); + let reader_po = comm::port::<result::result<[u8]/~, tcp_err_data>>(); let client_socket_data = @{ reader_po : reader_po, reader_ch : comm::chan(reader_po), @@ -1120,7 +1120,7 @@ enum tcp_read_start_result { } enum tcp_read_result { - tcp_read_data([u8]), + tcp_read_data([u8]/~), tcp_read_done, tcp_read_err(tcp_err_data) } @@ -1264,8 +1264,8 @@ enum conn_attempt { } type tcp_socket_data = { - reader_po: comm::port<result::result<[u8], tcp_err_data>>, - reader_ch: comm::chan<result::result<[u8], tcp_err_data>>, + reader_po: comm::port<result::result<[u8]/~, tcp_err_data>>, + reader_ch: comm::chan<result::result<[u8]/~, tcp_err_data>>, stream_handle_ptr: *uv::ll::uv_tcp_t, connect_req: uv::ll::uv_connect_t, write_req: uv::ll::uv_write_t, @@ -1570,7 +1570,7 @@ mod test { } } - fn tcp_write_single(sock: tcp_socket, val: [u8]) { + fn tcp_write_single(sock: tcp_socket, val: [u8]/~) { let write_result_future = sock.write_future(val); let write_result = write_result_future.get(); if result::is_err(write_result) { diff --git a/src/libstd/par.rs b/src/libstd/par.rs index 17297d94bd9..156f21216e5 100644 --- a/src/libstd/par.rs +++ b/src/libstd/par.rs @@ -19,22 +19,22 @@ return the intermediate results. This is used to build most of the other parallel vector functions, like map or alli."] fn map_slices<A: copy send, B: copy send>( - xs: [A], + xs: [A]/~, f: fn() -> fn~(uint, [A]/&) -> B) - -> [B] { + -> [B]/~ { let len = xs.len(); if len < min_granularity { log(info, "small slice"); // This is a small vector, fall back on the normal map. - [f()(0u, xs)] + [f()(0u, xs)]/~ } else { let num_tasks = uint::min(max_tasks, len / min_granularity); let items_per_task = len / num_tasks; - let mut futures = []; + let mut futures = []/~; let mut base = 0u; log(info, "spawning tasks"); while base < len { @@ -74,18 +74,19 @@ fn map_slices<A: copy send, B: copy send>( } #[doc="A parallel version of map."] -fn map<A: copy send, B: copy send>(xs: [A], f: fn~(A) -> B) -> [B] { +fn map<A: copy send, B: copy send>(xs: [A]/~, f: fn~(A) -> B) -> [B]/~ { vec::concat(map_slices(xs) {|| - fn~(_base: uint, slice : [A]/&, copy f) -> [B] { + fn~(_base: uint, slice : [A]/&, copy f) -> [B]/~ { vec::map(slice, f) } }) } #[doc="A parallel version of mapi."] -fn mapi<A: copy send, B: copy send>(xs: [A], f: fn~(uint, A) -> B) -> [B] { +fn mapi<A: copy send, B: copy send>(xs: [A]/~, + f: fn~(uint, A) -> B) -> [B]/~ { let slices = map_slices(xs) {|| - fn~(base: uint, slice : [A]/&, copy f) -> [B] { + fn~(base: uint, slice : [A]/&, copy f) -> [B]/~ { vec::mapi(slice) {|i, x| f(i + base, x) } @@ -102,10 +103,10 @@ fn mapi<A: copy send, B: copy send>(xs: [A], f: fn~(uint, A) -> B) -> [B] { In this case, f is a function that creates functions to run over the inner elements. This is to skirt the need for copy constructors."] fn mapi_factory<A: copy send, B: copy send>( - xs: [A], f: fn() -> fn~(uint, A) -> B) -> [B] { + xs: [A]/~, f: fn() -> fn~(uint, A) -> B) -> [B]/~ { let slices = map_slices(xs) {|| let f = f(); - fn~(base: uint, slice : [A]/&, move f) -> [B] { + fn~(base: uint, slice : [A]/&, move f) -> [B]/~ { vec::mapi(slice) {|i, x| f(i + base, x) } @@ -118,7 +119,7 @@ fn mapi_factory<A: copy send, B: copy send>( } #[doc="Returns true if the function holds for all elements in the vector."] -fn alli<A: copy send>(xs: [A], f: fn~(uint, A) -> bool) -> bool { +fn alli<A: copy send>(xs: [A]/~, f: fn~(uint, A) -> bool) -> bool { vec::all(map_slices(xs) {|| fn~(base: uint, slice : [A]/&, copy f) -> bool { vec::alli(slice) {|i, x| @@ -129,7 +130,7 @@ fn alli<A: copy send>(xs: [A], f: fn~(uint, A) -> bool) -> bool { } #[doc="Returns true if the function holds for any elements in the vector."] -fn any<A: copy send>(xs: [A], f: fn~(A) -> bool) -> bool { +fn any<A: copy send>(xs: [A]/~, f: fn~(A) -> bool) -> bool { vec::any(map_slices(xs) {|| fn~(_base : uint, slice: [A]/&, copy f) -> bool { vec::any(slice, f) diff --git a/src/libstd/rope.rs b/src/libstd/rope.rs index a8cd3b65ef8..3799e7cdd28 100644 --- a/src/libstd/rope.rs +++ b/src/libstd/rope.rs @@ -97,7 +97,7 @@ Add one char to the end of the rope * this function executes in near-constant time "] fn append_char(rope: rope, char: char) -> rope { - ret append_str(rope, @str::from_chars([char])); + ret append_str(rope, @str::from_chars([char]/~)); } #[doc = " @@ -118,7 +118,7 @@ Add one char to the beginning of the rope * this function executes in near-constant time "] fn prepend_char(rope: rope, char: char) -> rope { - ret prepend_str(rope, @str::from_chars([char])); + ret prepend_str(rope, @str::from_chars([char]/~)); } #[doc = " @@ -153,7 +153,7 @@ If the ropes are balanced initially and have the same height, the resulting rope remains balanced. However, this function does not take any further measure to ensure that the result is balanced. "] -fn concat(v: [rope]) -> rope { +fn concat(v: [rope]/~) -> rope { //Copy `v` into a mut vector let mut len = vec::len(v); if len == 0u { ret node::empty; } @@ -752,7 +752,7 @@ mod node { * forest - The forest. This vector is progressively rewritten during execution and should be discarded as meaningless afterwards. "] - fn tree_from_forest_destructive(forest: [mut @node]) -> @node { + fn tree_from_forest_destructive(forest: [mut @node]/~) -> @node { let mut i; let mut len = vec::len(forest); while len > 1u { @@ -805,7 +805,7 @@ mod node { option::none { break; } option::some(x) { //TODO: Replace with memcpy or something similar - let mut local_buf: [u8] = + let mut local_buf: [u8]/~ = unsafe::reinterpret_cast(*x.content); let mut i = x.byte_offset; while i < x.byte_len { @@ -859,7 +859,7 @@ mod node { fn bal(node: @node) -> option<@node> { if height(node) < hint_max_node_height { ret option::none; } //1. Gather all leaves as a forest - let mut forest = [mut]; + let mut forest = [mut]/~; let it = leaf_iterator::start(node); loop { alt (leaf_iterator::next(it)) { @@ -1113,12 +1113,12 @@ mod node { mod leaf_iterator { type t = { - stack: [mut @node], + stack: [mut @node]/~, mut stackpos: int }; fn empty() -> t { - let stack : [mut @node] = [mut]; + let stack : [mut @node]/~ = [mut]/~; ret {stack: stack, mut stackpos: -1} } diff --git a/src/libstd/serialization.rs b/src/libstd/serialization.rs index 43059ca7828..5c1d7f00b62 100644 --- a/src/libstd/serialization.rs +++ b/src/libstd/serialization.rs @@ -83,7 +83,7 @@ iface deserializer { // // In some cases, these should eventually be coded as traits. -fn emit_from_vec<S: serializer, T>(s: S, v: [T], f: fn(T)) { +fn emit_from_vec<S: serializer, T>(s: S, v: [T]/~, f: fn(T)) { s.emit_vec(vec::len(v)) {|| vec::iteri(v) {|i,e| s.emit_vec_elt(i) {|| @@ -93,7 +93,7 @@ fn emit_from_vec<S: serializer, T>(s: S, v: [T], f: fn(T)) { } } -fn read_to_vec<D: deserializer, T: copy>(d: D, f: fn() -> T) -> [T] { +fn read_to_vec<D: deserializer, T: copy>(d: D, f: fn() -> T) -> [T]/~ { d.read_vec {|len| vec::from_fn(len) {|i| d.read_vec_elt(i) {|| f() } @@ -102,13 +102,13 @@ fn read_to_vec<D: deserializer, T: copy>(d: D, f: fn() -> T) -> [T] { } impl serializer_helpers<S: serializer> for S { - fn emit_from_vec<T>(v: [T], f: fn(T)) { + fn emit_from_vec<T>(v: [T]/~, f: fn(T)) { emit_from_vec(self, v, f) } } impl deserializer_helpers<D: deserializer> for D { - fn read_to_vec<T: copy>(f: fn() -> T) -> [T] { + fn read_to_vec<T: copy>(f: fn() -> T) -> [T]/~ { read_to_vec(self, f) } } diff --git a/src/libstd/sha1.rs b/src/libstd/sha1.rs index 2325a9cd3fb..a492facb1a3 100644 --- a/src/libstd/sha1.rs +++ b/src/libstd/sha1.rs @@ -22,14 +22,14 @@ export sha1; #[doc = "The SHA-1 interface"] iface sha1 { #[doc = "Provide message input as bytes"] - fn input([u8]); + fn input([u8]/~); #[doc = "Provide message input as string"] fn input_str(str); #[doc = " Read the digest as a vector of 20 bytes. After calling this no further input may be provided until reset is called. "] - fn result() -> [u8]; + fn result() -> [u8]/~; #[doc = " Read the digest as a hex string. After calling this no further input may be provided until reset is called. @@ -52,15 +52,15 @@ const k3: u32 = 0xCA62C1D6u32; #[doc = "Construct a `sha` object"] fn sha1() -> sha1 { type sha1state = - {h: [mut u32], + {h: [mut u32]/~, mut len_low: u32, mut len_high: u32, - msg_block: [mut u8], + msg_block: [mut u8]/~, mut msg_block_idx: uint, mut computed: bool, - work_buf: @[mut u32]}; + work_buf: @[mut u32]/~}; - fn add_input(st: sha1state, msg: [u8]) { + fn add_input(st: sha1state, msg: [u8]/~) { /* FIXME: Should be typestate precondition (#2345) */ assert (!st.computed); for vec::each(msg) {|element| @@ -157,15 +157,15 @@ fn sha1() -> sha1 { fn circular_shift(bits: u32, word: u32) -> u32 { ret word << bits | word >> 32u32 - bits; } - fn mk_result(st: sha1state) -> [u8] { + fn mk_result(st: sha1state) -> [u8]/~ { if !st.computed { pad_msg(st); st.computed = true; } - let mut rs: [u8] = []; + let mut rs: [u8]/~ = []/~; for vec::each(st.h) {|hpart| let a = (hpart >> 24u32 & 0xFFu32) as u8; let b = (hpart >> 16u32 & 0xFFu32) as u8; let c = (hpart >> 8u32 & 0xFFu32) as u8; let d = (hpart & 0xFFu32) as u8; - rs += [a, b, c, d]; + rs += [a, b, c, d]/~; } ret rs; } @@ -231,9 +231,9 @@ fn sha1() -> sha1 { self.h[4] = 0xC3D2E1F0u32; self.computed = false; } - fn input(msg: [u8]) { add_input(self, msg); } + fn input(msg: [u8]/~) { add_input(self, msg); } fn input_str(msg: str) { add_input(self, str::bytes(msg)); } - fn result() -> [u8] { ret mk_result(self); } + fn result() -> [u8]/~ { ret mk_result(self); } fn result_str() -> str { let r = mk_result(self); let mut s = ""; @@ -260,7 +260,7 @@ mod tests { #[test] fn test() unsafe { - type test = {input: str, output: [u8]}; + type test = {input: str, output: [u8]/~}; fn a_million_letter_a() -> str { let mut i = 0; @@ -270,14 +270,14 @@ mod tests { } // Test messages from FIPS 180-1 - let fips_180_1_tests: [test] = + let fips_180_1_tests: [test]/~ = [{input: "abc", output: [0xA9u8, 0x99u8, 0x3Eu8, 0x36u8, 0x47u8, 0x06u8, 0x81u8, 0x6Au8, 0xBAu8, 0x3Eu8, 0x25u8, 0x71u8, 0x78u8, 0x50u8, 0xC2u8, 0x6Cu8, - 0x9Cu8, 0xD0u8, 0xD8u8, 0x9Du8]}, + 0x9Cu8, 0xD0u8, 0xD8u8, 0x9Du8]/~}, {input: "abcdbcdecdefdefgefghfghighij" + "hijkijkljklmklmnlmnomnopnopq", @@ -286,33 +286,33 @@ mod tests { 0x1Cu8, 0x3Bu8, 0xD2u8, 0x6Eu8, 0xBAu8, 0xAEu8, 0x4Au8, 0xA1u8, 0xF9u8, 0x51u8, 0x29u8, 0xE5u8, - 0xE5u8, 0x46u8, 0x70u8, 0xF1u8]}, + 0xE5u8, 0x46u8, 0x70u8, 0xF1u8]/~}, {input: a_million_letter_a(), output: [0x34u8, 0xAAu8, 0x97u8, 0x3Cu8, 0xD4u8, 0xC4u8, 0xDAu8, 0xA4u8, 0xF6u8, 0x1Eu8, 0xEBu8, 0x2Bu8, 0xDBu8, 0xADu8, 0x27u8, 0x31u8, - 0x65u8, 0x34u8, 0x01u8, 0x6Fu8]}]; + 0x65u8, 0x34u8, 0x01u8, 0x6Fu8]/~}]/~; // Examples from wikipedia - let wikipedia_tests: [test] = + let wikipedia_tests: [test]/~ = [{input: "The quick brown fox jumps over the lazy dog", output: [0x2fu8, 0xd4u8, 0xe1u8, 0xc6u8, 0x7au8, 0x2du8, 0x28u8, 0xfcu8, 0xedu8, 0x84u8, 0x9eu8, 0xe1u8, 0xbbu8, 0x76u8, 0xe7u8, 0x39u8, - 0x1bu8, 0x93u8, 0xebu8, 0x12u8]}, + 0x1bu8, 0x93u8, 0xebu8, 0x12u8]/~}, {input: "The quick brown fox jumps over the lazy cog", output: [0xdeu8, 0x9fu8, 0x2cu8, 0x7fu8, 0xd2u8, 0x5eu8, 0x1bu8, 0x3au8, 0xfau8, 0xd3u8, 0xe8u8, 0x5au8, 0x0bu8, 0xd1u8, 0x7du8, 0x9bu8, - 0x10u8, 0x0du8, 0xb4u8, 0xb3u8]}]; + 0x10u8, 0x0du8, 0xb4u8, 0xb3u8]/~}]/~; let tests = fips_180_1_tests + wikipedia_tests; - fn check_vec_eq(v0: [u8], v1: [u8]) { + fn check_vec_eq(v0: [u8]/~, v1: [u8]/~) { assert (vec::len::<u8>(v0) == vec::len::<u8>(v1)); let len = vec::len::<u8>(v0); let mut i = 0u; diff --git a/src/libstd/sort.rs b/src/libstd/sort.rs index 5c5a6e09d2f..e3ab3b09707 100644 --- a/src/libstd/sort.rs +++ b/src/libstd/sort.rs @@ -1,5 +1,5 @@ #[doc = "Sorting methods"]; -import vec::len; +import vec::{len, push}; import int::{eq, ord}; export le; @@ -15,18 +15,19 @@ Merge sort. Returns a new vector containing the sorted list. Has worst case O(n log n) performance, best case O(n), but is not space efficient. This is a stable sort. "] -fn merge_sort<T: copy>(le: le<T>, v: [const T]) -> [T] { +fn merge_sort<T: copy>(le: le<T>, v: [const T]/~) -> [T]/~ { type slice = (uint, uint); ret merge_sort_(le, v, (0u, len(v))); - fn merge_sort_<T: copy>(le: le<T>, v: [const T], slice: slice) -> [T] { + fn merge_sort_<T: copy>(le: le<T>, v: [const T]/~, slice: slice) + -> [T]/~ { let begin = tuple::first(slice); let end = tuple::second(slice); let v_len = end - begin; - if v_len == 0u { ret []; } - if v_len == 1u { ret [v[begin]]; } + if v_len == 0u { ret []/~; } + if v_len == 1u { ret [v[begin]]/~; } let mid = v_len / 2u + begin; let a = (begin, mid); @@ -34,8 +35,8 @@ fn merge_sort<T: copy>(le: le<T>, v: [const T]) -> [T] { ret merge(le, merge_sort_(le, v, a), merge_sort_(le, v, b)); } - fn merge<T: copy>(le: le<T>, a: [T], b: [T]) -> [T] { - let mut rs = []; + fn merge<T: copy>(le: le<T>, a: [T]/~, b: [T]/~) -> [T]/~ { + let mut rs = []/~; vec::reserve(rs, len(a) + len(b)); let a_len = len(a); let mut a_ix = 0u; @@ -53,7 +54,7 @@ fn merge_sort<T: copy>(le: le<T>, v: [const T]) -> [T] { } } -fn part<T: copy>(compare_func: le<T>, arr: [mut T], left: uint, +fn part<T: copy>(compare_func: le<T>, arr: [mut T]/~, left: uint, right: uint, pivot: uint) -> uint { let pivot_value = arr[pivot]; arr[pivot] <-> arr[right]; @@ -70,7 +71,7 @@ fn part<T: copy>(compare_func: le<T>, arr: [mut T], left: uint, ret storage_index; } -fn qsort<T: copy>(compare_func: le<T>, arr: [mut T], left: uint, +fn qsort<T: copy>(compare_func: le<T>, arr: [mut T]/~, left: uint, right: uint) { if right > left { let pivot = (left + right) / 2u; @@ -89,13 +90,13 @@ Quicksort. Sorts a mut vector in place. Has worst case O(n^2) performance, average case O(n log n). This is an unstable sort. "] -fn quick_sort<T: copy>(compare_func: le<T>, arr: [mut T]) { +fn quick_sort<T: copy>(compare_func: le<T>, arr: [mut T]/~) { if len::<T>(arr) == 0u { ret; } qsort::<T>(compare_func, arr, 0u, len::<T>(arr) - 1u); } fn qsort3<T: copy>(compare_func_lt: le<T>, compare_func_eq: le<T>, - arr: [mut T], left: int, right: int) { + arr: [mut T]/~, left: int, right: int) { if right <= left { ret; } let v: T = arr[right]; let mut i: int = left - 1; @@ -145,14 +146,14 @@ fn qsort3<T: copy>(compare_func_lt: le<T>, compare_func_eq: le<T>, #[doc = " Fancy quicksort. Sorts a mut vector in place. -Based on algorithm presented by [Sedgewick and Bentley] +Based on algorithm presented by [Sedgewick and Bentley]/~ (http://www.cs.princeton.edu/~rs/talks/QuicksortIsOptimal.pdf). According to these slides this is the algorithm of choice for 'randomly ordered keys, abstract compare' & 'small number of key values'. This is an unstable sort. "] -fn quick_sort3<T: copy ord eq>(arr: [mut T]) { +fn quick_sort3<T: copy ord eq>(arr: [mut T]/~) { if len::<T>(arr) == 0u { ret; } qsort3::<T>({ |x, y| x.lt(y) }, { |x, y| x.eq(y) }, arr, 0, (len::<T>(arr) as int) - 1); @@ -160,7 +161,7 @@ fn quick_sort3<T: copy ord eq>(arr: [mut T]) { #[cfg(test)] mod test_qsort3 { - fn check_sort(v1: [mut int], v2: [mut int]) { + fn check_sort(v1: [mut int]/~, v2: [mut int]/~) { let len = vec::len::<int>(v1); quick_sort3::<int>(v1); let mut i = 0u; @@ -174,24 +175,24 @@ mod test_qsort3 { #[test] fn test() { { - let v1 = [mut 3, 7, 4, 5, 2, 9, 5, 8]; - let v2 = [mut 2, 3, 4, 5, 5, 7, 8, 9]; + let v1 = [mut 3, 7, 4, 5, 2, 9, 5, 8]/~; + let v2 = [mut 2, 3, 4, 5, 5, 7, 8, 9]/~; check_sort(v1, v2); } { - let v1 = [mut 1, 1, 1]; - let v2 = [mut 1, 1, 1]; + let v1 = [mut 1, 1, 1]/~; + let v2 = [mut 1, 1, 1]/~; check_sort(v1, v2); } { - let v1: [mut int] = [mut]; - let v2: [mut int] = [mut]; + let v1: [mut int]/~ = [mut]/~; + let v2: [mut int]/~ = [mut]/~; check_sort(v1, v2); } - { let v1 = [mut 9]; let v2 = [mut 9]; check_sort(v1, v2); } + { let v1 = [mut 9]/~; let v2 = [mut 9]/~; check_sort(v1, v2); } { - let v1 = [mut 9, 3, 3, 3, 9]; - let v2 = [mut 3, 3, 3, 9, 9]; + let v1 = [mut 9, 3, 3, 3, 9]/~; + let v2 = [mut 3, 3, 3, 9, 9]/~; check_sort(v1, v2); } } @@ -199,7 +200,7 @@ mod test_qsort3 { #[cfg(test)] mod test_qsort { - fn check_sort(v1: [mut int], v2: [mut int]) { + fn check_sort(v1: [mut int]/~, v2: [mut int]/~) { let len = vec::len::<int>(v1); fn leual(&&a: int, &&b: int) -> bool { ret a <= b; } let f = leual; @@ -215,24 +216,24 @@ mod test_qsort { #[test] fn test() { { - let v1 = [mut 3, 7, 4, 5, 2, 9, 5, 8]; - let v2 = [mut 2, 3, 4, 5, 5, 7, 8, 9]; + let v1 = [mut 3, 7, 4, 5, 2, 9, 5, 8]/~; + let v2 = [mut 2, 3, 4, 5, 5, 7, 8, 9]/~; check_sort(v1, v2); } { - let v1 = [mut 1, 1, 1]; - let v2 = [mut 1, 1, 1]; + let v1 = [mut 1, 1, 1]/~; + let v2 = [mut 1, 1, 1]/~; check_sort(v1, v2); } { - let v1: [mut int] = [mut]; - let v2: [mut int] = [mut]; + let v1: [mut int]/~ = [mut]/~; + let v2: [mut int]/~ = [mut]/~; check_sort(v1, v2); } - { let v1 = [mut 9]; let v2 = [mut 9]; check_sort(v1, v2); } + { let v1 = [mut 9]/~; let v2 = [mut 9]/~; check_sort(v1, v2); } { - let v1 = [mut 9, 3, 3, 3, 9]; - let v2 = [mut 3, 3, 3, 9, 9]; + let v1 = [mut 9, 3, 3, 3, 9]/~; + let v2 = [mut 3, 3, 3, 9, 9]/~; check_sort(v1, v2); } } @@ -240,9 +241,9 @@ mod test_qsort { // Regression test for #750 #[test] fn test_simple() { - let names = [mut 2, 1, 3]; + let names = [mut 2, 1, 3]/~; - let expected = [1, 2, 3]; + let expected = [1, 2, 3]/~; fn le(&&a: int, &&b: int) -> bool { int::le(a, b) } sort::quick_sort(le, names); @@ -261,7 +262,7 @@ mod test_qsort { #[cfg(test)] mod tests { - fn check_sort(v1: [int], v2: [int]) { + fn check_sort(v1: [int]/~, v2: [int]/~) { let len = vec::len::<int>(v1); fn le(&&a: int, &&b: int) -> bool { ret a <= b; } let f = le; @@ -277,16 +278,16 @@ mod tests { #[test] fn test() { { - let v1 = [3, 7, 4, 5, 2, 9, 5, 8]; - let v2 = [2, 3, 4, 5, 5, 7, 8, 9]; + let v1 = [3, 7, 4, 5, 2, 9, 5, 8]/~; + let v2 = [2, 3, 4, 5, 5, 7, 8, 9]/~; check_sort(v1, v2); } - { let v1 = [1, 1, 1]; let v2 = [1, 1, 1]; check_sort(v1, v2); } - { let v1: [int] = []; let v2: [int] = []; check_sort(v1, v2); } - { let v1 = [9]; let v2 = [9]; check_sort(v1, v2); } + { let v1 = [1, 1, 1]/~; let v2 = [1, 1, 1]/~; check_sort(v1, v2); } + { let v1:[int]/~ = []/~; let v2:[int]/~ = []/~; check_sort(v1, v2); } + { let v1 = [9]/~; let v2 = [9]/~; check_sort(v1, v2); } { - let v1 = [9, 3, 3, 3, 9]; - let v2 = [3, 3, 3, 9, 9]; + let v1 = [9, 3, 3, 3, 9]/~; + let v2 = [3, 3, 3, 9, 9]/~; check_sort(v1, v2); } } @@ -294,9 +295,9 @@ mod tests { #[test] fn test_merge_sort_mutable() { fn le(&&a: int, &&b: int) -> bool { ret a <= b; } - let v1 = [mut 3, 2, 1]; + let v1 = [mut 3, 2, 1]/~; let v2 = merge_sort(le, v1); - assert v2 == [1, 2, 3]; + assert v2 == [1, 2, 3]/~; } } diff --git a/src/libstd/term.rs b/src/libstd/term.rs index 3bbde56693a..fdbdc7205da 100644 --- a/src/libstd/term.rs +++ b/src/libstd/term.rs @@ -23,18 +23,18 @@ const color_bright_magenta: u8 = 13u8; const color_bright_cyan: u8 = 14u8; const color_bright_white: u8 = 15u8; -fn esc(writer: io::writer) { writer.write([0x1bu8, '[' as u8]); } +fn esc(writer: io::writer) { writer.write([0x1bu8, '[' as u8]/~); } #[doc = "Reset the foreground and background colors to default"] fn reset(writer: io::writer) { esc(writer); - writer.write(['0' as u8, 'm' as u8]); + writer.write(['0' as u8, 'm' as u8]/~); } #[doc = "Returns true if the terminal supports color"] fn color_supported() -> bool { let supported_terms = ["xterm-color", "xterm", - "screen-bce", "xterm-256color"]; + "screen-bce", "xterm-256color"]/~; ret alt os::getenv("TERM") { option::some(env) { for vec::each(supported_terms) {|term| @@ -50,8 +50,8 @@ fn set_color(writer: io::writer, first_char: u8, color: u8) { assert (color < 16u8); esc(writer); let mut color = color; - if color >= 8u8 { writer.write(['1' as u8, ';' as u8]); color -= 8u8; } - writer.write([first_char, ('0' as u8) + color, 'm' as u8]); + if color >= 8u8 { writer.write(['1' as u8, ';' as u8]/~); color -= 8u8; } + writer.write([first_char, ('0' as u8) + color, 'm' as u8]/~); } #[doc = "Set the foreground color"] diff --git a/src/libstd/test.rs b/src/libstd/test.rs index 01b413054fb..beefdd06385 100644 --- a/src/libstd/test.rs +++ b/src/libstd/test.rs @@ -49,7 +49,7 @@ type test_desc = { // The default console test runner. It accepts the command line // arguments and a vector of test_descs (generated at compile time). -fn test_main(args: [str], tests: [test_desc]) { +fn test_main(args: [str]/~, tests: [test_desc]/~) { let opts = alt parse_opts(args) { either::left(o) { o } @@ -64,9 +64,9 @@ type test_opts = {filter: option<str>, run_ignored: bool, type opt_res = either<test_opts, str>; // Parses command line arguments into test options -fn parse_opts(args: [str]) -> opt_res { +fn parse_opts(args: [str]/~) -> opt_res { let args_ = vec::tail(args); - let opts = [getopts::optflag("ignored"), getopts::optopt("logfile")]; + let opts = [getopts::optflag("ignored"), getopts::optopt("logfile")]/~; let match = alt getopts::getopts(args_, opts) { ok(m) { m } @@ -97,11 +97,11 @@ type console_test_state = mut passed: uint, mut failed: uint, mut ignored: uint, - mut failures: [test_desc]}; + mut failures: [test_desc]/~}; // A simple console test runner fn run_tests_console(opts: test_opts, - tests: [test_desc]) -> bool { + tests: [test_desc]/~) -> bool { fn callback(event: testevent, st: console_test_state) { alt event { @@ -128,7 +128,7 @@ fn run_tests_console(opts: test_opts, st.failed += 1u; write_failed(st.out, st.use_color); st.out.write_line(""); - st.failures += [copy test]; + st.failures += [copy test]/~; } tr_ignored { st.ignored += 1u; @@ -142,7 +142,7 @@ fn run_tests_console(opts: test_opts, let log_out = alt opts.logfile { some(path) { - alt io::file_writer(path, [io::create, io::truncate]) { + alt io::file_writer(path, [io::create, io::truncate]/~) { result::ok(w) { some(w) } result::err(s) { fail(#fmt("can't open output file: %s", s)) @@ -160,7 +160,7 @@ fn run_tests_console(opts: test_opts, mut passed: 0u, mut failed: 0u, mut ignored: 0u, - mut failures: []}; + mut failures: []/~}; run_tests(opts, tests, {|x|callback(x, st)}); @@ -250,7 +250,7 @@ fn should_sort_failures_before_printing_them() { mut passed: 0u, mut failed: 0u, mut ignored: 0u, - mut failures: [test_b, test_a]}; + mut failures: [test_b, test_a]/~}; print_failures(st); @@ -264,14 +264,14 @@ fn should_sort_failures_before_printing_them() { fn use_color() -> bool { ret get_concurrency() == 1u; } enum testevent { - te_filtered([test_desc]), + te_filtered([test_desc]/~), te_wait(test_desc), te_result(test_desc, test_result), } type monitor_msg = (test_desc, test_result); -fn run_tests(opts: test_opts, tests: [test_desc], +fn run_tests(opts: test_opts, tests: [test_desc]/~, callback: fn@(testevent)) { let mut filtered_tests = filter_tests(opts, tests); @@ -329,7 +329,7 @@ fn get_concurrency() -> uint { #[warn(no_non_implicitly_copyable_typarams)] fn filter_tests(opts: test_opts, - tests: [test_desc]) -> [test_desc] { + tests: [test_desc]/~) -> [test_desc]/~ { let mut filtered = copy tests; // Remove tests that don't match the test filter @@ -482,7 +482,7 @@ mod tests { #[test] fn first_free_arg_should_be_a_filter() { - let args = ["progname", "filter"]; + let args = ["progname", "filter"]/~; let opts = alt parse_opts(args) { either::left(o) { o } _ { fail "Malformed arg in first_free_arg_should_be_a_filter"; } }; assert (str::eq("filter", option::get(opts.filter))); @@ -490,7 +490,7 @@ mod tests { #[test] fn parse_ignored_flag() { - let args = ["progname", "filter", "--ignored"]; + let args = ["progname", "filter", "--ignored"]/~; let opts = alt parse_opts(args) { either::left(o) { o } _ { fail "Malformed arg in parse_ignored_flag"; } }; assert (opts.run_ignored); @@ -505,7 +505,7 @@ mod tests { logfile: option::none}; let tests = [{name: "1", fn: fn~() { }, ignore: true, should_fail: false}, - {name: "2", fn: fn~() { }, ignore: false, should_fail: false}]; + {name: "2", fn: fn~() { }, ignore: false, should_fail: false}]/~; let filtered = filter_tests(opts, tests); assert (vec::len(filtered) == 1u); @@ -524,15 +524,15 @@ mod tests { "test::ignored_tests_result_in_ignored", "test::first_free_arg_should_be_a_filter", "test::parse_ignored_flag", "test::filter_for_ignored_option", - "test::sort_tests"]; + "test::sort_tests"]/~; let tests = { let testfn = fn~() { }; - let mut tests = []; + let mut tests = []/~; for vec::each(names) {|name| let test = {name: name, fn: copy testfn, ignore: false, should_fail: false}; - tests += [test]; + tests += [test]/~; } tests }; @@ -543,7 +543,7 @@ mod tests { "test::do_not_run_ignored_tests", "test::filter_for_ignored_option", "test::first_free_arg_should_be_a_filter", "test::ignored_tests_result_in_ignored", "test::parse_ignored_flag", - "test::sort_tests"]; + "test::sort_tests"]/~; let pairs = vec::zip(expected, filtered); diff --git a/src/libstd/time.rs b/src/libstd/time.rs index d06749b5757..b2d5ea64a98 100644 --- a/src/libstd/time.rs +++ b/src/libstd/time.rs @@ -66,14 +66,14 @@ fn tzset() { } type tm = { - tm_sec: i32, // seconds after the minute [0-60] - tm_min: i32, // minutes after the hour [0-59] - tm_hour: i32, // hours after midnight [0-23] - tm_mday: i32, // days of the month [1-31] - tm_mon: i32, // months since January [0-11] + tm_sec: i32, // seconds after the minute [0-60]/~ + tm_min: i32, // minutes after the hour [0-59]/~ + tm_hour: i32, // hours after midnight [0-23]/~ + tm_mday: i32, // days of the month [1-31]/~ + tm_mon: i32, // months since January [0-11]/~ tm_year: i32, // years since 1900 - tm_wday: i32, // days since Sunday [0-6] - tm_yday: i32, // days since January 1 [0-365] + tm_wday: i32, // days since Sunday [0-6]/~ + tm_yday: i32, // days since January 1 [0-365]/~ tm_isdst: i32, // Daylight Savings Time flag tm_gmtoff: i32, // offset from UTC in seconds tm_zone: str, // timezone abbreviation @@ -151,7 +151,7 @@ fn strptime(s: str, format: str) -> result<tm, str> { ret true; } - fn match_strs(s: str, pos: uint, strs: [(str, i32)]) + fn match_strs(s: str, pos: uint, strs: [(str, i32)]/~) -> option<(i32, uint)> { let mut i = 0u; let len = vec::len(strs); @@ -214,7 +214,7 @@ fn strptime(s: str, format: str) -> result<tm, str> { ("Thursday", 4_i32), ("Friday", 5_i32), ("Saturday", 6_i32) - ]) { + ]/~) { some(item) { let (v, pos) = item; tm.tm_wday = v; ok(pos) } none { err("Invalid day") } } @@ -228,7 +228,7 @@ fn strptime(s: str, format: str) -> result<tm, str> { ("Thu", 4_i32), ("Fri", 5_i32), ("Sat", 6_i32) - ]) { + ]/~) { some(item) { let (v, pos) = item; tm.tm_wday = v; ok(pos) } none { err("Invalid day") } } @@ -247,7 +247,7 @@ fn strptime(s: str, format: str) -> result<tm, str> { ("October", 9_i32), ("November", 10_i32), ("December", 11_i32) - ]) { + ]/~) { some(item) { let (v, pos) = item; tm.tm_mon = v; ok(pos) } none { err("Invalid month") } } @@ -266,7 +266,7 @@ fn strptime(s: str, format: str) -> result<tm, str> { ("Oct", 9_i32), ("Nov", 10_i32), ("Dec", 11_i32) - ]) { + ]/~) { some(item) { let (v, pos) = item; tm.tm_mon = v; ok(pos) } none { err("Invalid month") } } @@ -385,13 +385,13 @@ fn strptime(s: str, format: str) -> result<tm, str> { } 'n' { parse_char(s, pos, '\n') } 'P' { - alt match_strs(s, pos, [("am", 0_i32), ("pm", 12_i32)]) { + alt match_strs(s, pos, [("am", 0_i32), ("pm", 12_i32)]/~) { some(item) { let (v, pos) = item; tm.tm_hour += v; ok(pos) } none { err("Invalid hour") } } } 'p' { - alt match_strs(s, pos, [("AM", 0_i32), ("PM", 12_i32)]) { + alt match_strs(s, pos, [("AM", 0_i32), ("PM", 12_i32)]/~) { some(item) { let (v, pos) = item; tm.tm_hour += v; ok(pos) } none { err("Invalid hour") } } @@ -1010,7 +1010,7 @@ mod tests { "Thursday", "Friday", "Saturday" - ].iter { |day| assert test(day, "%A"); } + ]/~.iter { |day| assert test(day, "%A"); } [ "Sun", @@ -1020,7 +1020,7 @@ mod tests { "Thu", "Fri", "Sat" - ].iter { |day| assert test(day, "%a"); } + ]/~.iter { |day| assert test(day, "%a"); } [ "January", @@ -1035,7 +1035,7 @@ mod tests { "October", "November", "December" - ].iter { |day| assert test(day, "%B"); } + ]/~.iter { |day| assert test(day, "%B"); } [ "Jan", @@ -1050,7 +1050,7 @@ mod tests { "Oct", "Nov", "Dec" - ].iter { |day| assert test(day, "%b"); } + ]/~.iter { |day| assert test(day, "%b"); } assert test("19", "%C"); assert test("Fri Feb 13 23:31:30 2009", "%c"); diff --git a/src/libstd/timer.rs b/src/libstd/timer.rs index 3ee92e5f074..f6981ce39e0 100644 --- a/src/libstd/timer.rs +++ b/src/libstd/timer.rs @@ -167,7 +167,7 @@ mod test { [(1u, 20u), (10u, 10u), - (20u, 2u)] + (20u, 2u)]/~ }; diff --git a/src/libstd/uv_ll.rs b/src/libstd/uv_ll.rs index b7e1ee7d82c..8011d816fea 100644 --- a/src/libstd/uv_ll.rs +++ b/src/libstd/uv_ll.rs @@ -24,7 +24,7 @@ import libc::size_t; // libuv struct mappings type uv_ip4_addr = { - ip: [u8], + ip: [u8]/~, port: int }; type uv_ip6_addr = uv_ip4_addr; @@ -616,7 +616,7 @@ unsafe fn accept(server: *libc::c_void, client: *libc::c_void) } unsafe fn write<T>(req: *uv_write_t, stream: *T, - buf_in: *[uv_buf_t], cb: *u8) -> libc::c_int { + buf_in: *[uv_buf_t]/~, cb: *u8) -> libc::c_int { let buf_ptr = vec::unsafe::to_ptr(*buf_in); let buf_cnt = vec::len(*buf_in) as i32; ret rustrt::rust_uv_write(req as *libc::c_void, @@ -678,7 +678,7 @@ unsafe fn buf_init(++input: *u8, len: uint) -> uv_buf_t { unsafe fn ip4_addr(ip: str, port: int) -> sockaddr_in { let mut addr_vec = str::bytes(ip); - addr_vec += [0u8]; // add null terminator + addr_vec += [0u8]/~; // add null terminator let addr_vec_ptr = vec::unsafe::to_ptr(addr_vec); let ip_back = str::from_bytes(addr_vec); log(debug, #fmt("vec val: '%s' length: %u", @@ -795,13 +795,13 @@ type uv_err_data = { mod test { enum tcp_read_data { tcp_read_eof, - tcp_read_more([u8]), + tcp_read_more([u8]/~), tcp_read_error } type request_wrapper = { write_req: *uv_write_t, - req_buf: *[uv_buf_t], + req_buf: *[uv_buf_t]/~, read_chan: *comm::chan<str> }; @@ -917,7 +917,7 @@ mod test { log(debug, #fmt("req_msg ptr: %u", req_msg_ptr as uint)); let req_msg = [ buf_init(req_msg_ptr, vec::len(req_str_bytes)) - ]; + ]/~; // this is the enclosing record, we'll pass a ptr to // this to C.. let write_handle = write_t(); @@ -1115,7 +1115,7 @@ mod test { client: *uv_tcp_t, server: *uv_tcp_t, server_kill_msg: str, - server_resp_buf: *[uv_buf_t], + server_resp_buf: *[uv_buf_t]/~, server_chan: *comm::chan<str>, server_write_req: *uv_write_t }; @@ -1164,7 +1164,7 @@ mod test { log(debug, #fmt("resp_msg ptr: %u", resp_msg_ptr as uint)); let resp_msg = [ buf_init(resp_msg_ptr, vec::len(resp_str_bytes)) - ]; + ]/~; let continue_async_handle = async_t(); let continue_async_handle_ptr = |
