From fc6b7c8b381bcb506eab0f50c69b6cc18aafacb2 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Mon, 12 Sep 2011 11:27:30 +0200 Subject: Reformat for new mode syntax, step 1 Long lines were fixed in a very crude way, as I'll be following up with another reformat in a bit. --- src/lib/aio.rs | 10 +++---- src/lib/bitv.rs | 35 ++++++++++------------ src/lib/box.rs | 2 +- src/lib/comm.rs | 6 ++-- src/lib/dbg.rs | 18 ++++++------ src/lib/deque.rs | 13 +++++---- src/lib/ebml.rs | 18 ++++++------ src/lib/either.rs | 10 +++---- src/lib/extfmt.rs | 41 +++++++++++++------------- src/lib/fs.rs | 14 ++++----- src/lib/fun_treemap.rs | 6 ++-- src/lib/generic_os.rs | 23 +++++++++------ src/lib/getopts.rs | 36 +++++++++++------------ src/lib/int.rs | 4 +-- src/lib/io.rs | 36 +++++++++++------------ src/lib/linux_os.rs | 2 +- src/lib/list.rs | 19 ++++++------ src/lib/macos_os.rs | 2 +- src/lib/map.rs | 52 ++++++++++++++++----------------- src/lib/net.rs | 4 +-- src/lib/option.rs | 14 ++++----- src/lib/posix_fs.rs | 6 ++-- src/lib/ptr.rs | 4 +-- src/lib/run_program.rs | 16 +++++----- src/lib/sha1.rs | 16 +++++----- src/lib/smallintmap.rs | 12 ++++---- src/lib/sort.rs | 24 +++++++-------- src/lib/str.rs | 78 ++++++++++++++++++++++++------------------------- src/lib/task.rs | 6 ++-- src/lib/test.rs | 35 +++++++++++----------- src/lib/treemap.rs | 7 +++-- src/lib/ufind.rs | 12 ++++---- src/lib/uint.rs | 4 +-- src/lib/unsafe.rs | 4 +-- src/lib/util.rs | 6 ++-- src/lib/vec.rs | 79 +++++++++++++++++++++++++------------------------- src/lib/win32_fs.rs | 6 ++-- src/lib/win32_os.rs | 2 +- 38 files changed, 341 insertions(+), 341 deletions(-) (limited to 'src/lib') diff --git a/src/lib/aio.rs b/src/lib/aio.rs index 8d8b036933d..0c4bcfd267d 100644 --- a/src/lib/aio.rs +++ b/src/lib/aio.rs @@ -14,11 +14,11 @@ native "rust" mod rustrt { fn aio_init(); fn aio_run(); fn aio_stop(); - fn aio_connect(host: *u8, port: int, connected: &chan); - fn aio_serve(host: *u8, port: int, acceptChan: &chan) -> server; - fn aio_writedata(s: socket, buf: *u8, size: uint, status: &chan); - fn aio_read(s: socket, reader: &chan<[u8]>); - fn aio_close_server(s: server, status: &chan); + fn aio_connect(host: *u8, port: int, connected: chan); + fn aio_serve(host: *u8, port: int, acceptChan: chan) -> server; + fn aio_writedata(s: socket, buf: *u8, size: uint, status: chan); + fn aio_read(s: socket, reader: chan<[u8]>); + fn aio_close_server(s: server, status: chan); fn aio_close_socket(s: socket); fn aio_is_null_client(s: socket) -> bool; } diff --git a/src/lib/bitv.rs b/src/lib/bitv.rs index 019aa32f36a..e47c72f1028 100644 --- a/src/lib/bitv.rs +++ b/src/lib/bitv.rs @@ -35,7 +35,7 @@ fn create(nbits: uint, init: bool) -> t { ret @{storage: storage, nbits: nbits}; } -fn process(op: &block(uint, uint) -> uint, v0: &t, v1: &t) -> bool { +fn process(op: block(uint, uint) -> uint, v0: t, v1: t) -> bool { let len = vec::len(v1.storage); assert (vec::len(v0.storage) == len); assert (v0.nbits == v1.nbits); @@ -51,21 +51,18 @@ fn process(op: &block(uint, uint) -> uint, v0: &t, v1: &t) -> bool { fn lor(w0: uint, w1: uint) -> uint { ret w0 | w1; } -fn union(v0: &t, v1: &t) -> bool { let sub = lor; ret process(sub, v0, v1); } +fn union(v0: t, v1: t) -> bool { let sub = lor; ret process(sub, v0, v1); } fn land(w0: uint, w1: uint) -> uint { ret w0 & w1; } -fn intersect(v0: &t, v1: &t) -> bool { +fn intersect(v0: t, v1: t) -> bool { let sub = land; ret process(sub, v0, v1); } fn right(_w0: uint, w1: uint) -> uint { ret w1; } -fn assign(v0: &t, v1: t) -> bool { - let sub = right; - ret process(sub, v0, v1); -} +fn assign(v0: t, v1: t) -> bool { let sub = right; ret process(sub, v0, v1); } fn clone(v: t) -> t { let storage = vec::init_elt_mut::(0u, v.nbits / uint_bits() + 1u); @@ -74,7 +71,7 @@ fn clone(v: t) -> t { ret @{storage: storage, nbits: v.nbits}; } -fn get(v: &t, i: uint) -> bool { +fn get(v: t, i: uint) -> bool { assert (i < v.nbits); let bits = uint_bits(); let w = i / bits; @@ -83,7 +80,7 @@ fn get(v: &t, i: uint) -> bool { ret x == 1u; } -fn equal(v0: &t, v1: &t) -> bool { +fn equal(v0: t, v1: t) -> bool { // FIXME: when we can break or return from inside an iterator loop, // we can eliminate this painful while-loop @@ -96,17 +93,17 @@ fn equal(v0: &t, v1: &t) -> bool { ret true; } -fn clear(v: &t) { +fn clear(v: t) { for each i: uint in uint::range(0u, vec::len(v.storage)) { v.storage[i] = 0u; } } -fn set_all(v: &t) { +fn set_all(v: t) { for each i: uint in uint::range(0u, v.nbits) { set(v, i, true); } } -fn invert(v: &t) { +fn invert(v: t) { for each i: uint in uint::range(0u, vec::len(v.storage)) { v.storage[i] = !v.storage[i]; } @@ -114,14 +111,14 @@ fn invert(v: &t) { /* v0 = v0 - v1 */ -fn difference(v0: &t, v1: &t) -> bool { +fn difference(v0: t, v1: t) -> bool { invert(v1); let b = intersect(v0, v1); invert(v1); ret b; } -fn set(v: &t, i: uint, x: bool) { +fn set(v: t, i: uint, x: bool) { assert (i < v.nbits); let bits = uint_bits(); let w = i / bits; @@ -132,32 +129,32 @@ fn set(v: &t, i: uint, x: bool) { /* true if all bits are 1 */ -fn is_true(v: &t) -> bool { +fn is_true(v: t) -> bool { for i: uint in to_vec(v) { if i != 1u { ret false; } } ret true; } /* true if all bits are non-1 */ -fn is_false(v: &t) -> bool { +fn is_false(v: t) -> bool { for i: uint in to_vec(v) { if i == 1u { ret false; } } ret true; } fn init_to_vec(v: t, i: uint) -> uint { ret if get(v, i) { 1u } else { 0u }; } -fn to_vec(v: &t) -> [uint] { +fn to_vec(v: t) -> [uint] { let sub = bind init_to_vec(v, _); ret vec::init_fn::(sub, v.nbits); } -fn to_str(v: &t) -> str { +fn to_str(v: t) -> str { let rs = ""; for i: uint in to_vec(v) { if i == 1u { rs += "1"; } else { rs += "0"; } } ret rs; } -fn eq_vec(v0: &t, v1: &[uint]) -> bool { +fn eq_vec(v0: t, v1: [uint]) -> bool { assert (v0.nbits == vec::len::(v1)); let len = v0.nbits; let i = 0u; diff --git a/src/lib/box.rs b/src/lib/box.rs index 94132a7f7f8..a4322c09be9 100644 --- a/src/lib/box.rs +++ b/src/lib/box.rs @@ -1,7 +1,7 @@ export ptr_eq; -fn ptr_eq(a: &@T, b: &@T) -> bool { +fn ptr_eq(a: @T, b: @T) -> bool { let a_ptr: uint = unsafe::reinterpret_cast(a); let b_ptr: uint = unsafe::reinterpret_cast(b); ret a_ptr == b_ptr; diff --git a/src/lib/comm.rs b/src/lib/comm.rs index f1ea9d485bc..7c3be729e83 100644 --- a/src/lib/comm.rs +++ b/src/lib/comm.rs @@ -38,7 +38,7 @@ resource port_ptr(po: *rustrt::rust_port) { tag port<~T> { port_t(@port_ptr); } -fn send<~T>(ch: &chan, data: -T) { +fn send<~T>(ch: chan, data: -T) { let chan_t(t, p) = ch; rustrt::chan_id_send(t, p, data); } @@ -47,8 +47,8 @@ fn port<~T>() -> port { port_t(@port_ptr(rustrt::new_port(sys::size_of::()))) } -fn recv<~T>(p: &port) -> T { ret rusti::recv(***p) } +fn recv<~T>(p: port) -> T { ret rusti::recv(***p) } -fn chan<~T>(p: &port) -> chan { +fn chan<~T>(p: port) -> chan { chan_t(task::get_task_id(), rustrt::get_port_id(***p)) } diff --git a/src/lib/dbg.rs b/src/lib/dbg.rs index 6858b30419a..6371eec349b 100644 --- a/src/lib/dbg.rs +++ b/src/lib/dbg.rs @@ -10,21 +10,21 @@ native "rust" mod rustrt { fn debug_tydesc(); - fn debug_opaque(x: &T); + fn debug_opaque(x: T); fn debug_box(x: @T); - fn debug_tag(x: &T); - fn debug_obj(x: &T, nmethods: uint, nbytes: uint); - fn debug_fn(x: &T); + fn debug_tag(x: T); + fn debug_obj(x: T, nmethods: uint, nbytes: uint); + fn debug_fn(x: T); fn debug_ptrcast(x: @T) -> @U; } fn debug_tydesc() { rustrt::debug_tydesc::(); } -fn debug_opaque(x: &T) { rustrt::debug_opaque::(x); } +fn debug_opaque(x: T) { rustrt::debug_opaque::(x); } fn debug_box(x: @T) { rustrt::debug_box::(x); } -fn debug_tag(x: &T) { rustrt::debug_tag::(x); } +fn debug_tag(x: T) { rustrt::debug_tag::(x); } /** @@ -36,15 +36,15 @@ fn debug_tag(x: &T) { rustrt::debug_tag::(x); } * this to at least be 4u, since an implicit captured tydesc pointer sits in * the front of any obj's data tuple.x */ -fn debug_obj(x: &T, nmethods: uint, nbytes: uint) { +fn debug_obj(x: T, nmethods: uint, nbytes: uint) { rustrt::debug_obj::(x, nmethods, nbytes); } -fn debug_fn(x: &T) { rustrt::debug_fn::(x); } +fn debug_fn(x: T) { rustrt::debug_fn::(x); } fn ptr_cast(x: @T) -> @U { ret rustrt::debug_ptrcast::(x); } -fn refcount(a: &@T) -> uint { +fn refcount(a: @T) -> uint { let p: *uint = unsafe::reinterpret_cast(a); ret *p; } diff --git a/src/lib/deque.rs b/src/lib/deque.rs index 3cc75e2f3b6..246806c8daa 100644 --- a/src/lib/deque.rs +++ b/src/lib/deque.rs @@ -7,8 +7,8 @@ type t = obj { fn size() -> uint; - fn add_front(&T); - fn add_back(&T); + fn add_front(T); + fn add_back(T); fn pop_front() -> T; fn pop_back() -> T; fn peek_front() -> T; @@ -28,7 +28,8 @@ fn create<@T>() -> t { - fn grow<@T>(nelts: uint, lo: uint, elts: &[mutable cell]) -> + + fn grow<@T>(nelts: uint, lo: uint, elts: [mutable cell]) -> [mutable cell] { assert (nelts == vec::len(elts)); let rv = [mutable]; @@ -44,7 +45,7 @@ fn create<@T>() -> t { ret rv; } - fn get<@T>(elts: &[mutable cell], i: uint) -> T { + fn get<@T>(elts: [mutable cell], i: uint) -> T { ret alt elts[i] { option::some(t) { t } _ { fail } }; } obj deque<@T>(mutable nelts: uint, @@ -52,7 +53,7 @@ fn create<@T>() -> t { mutable hi: uint, mutable elts: [mutable cell]) { fn size() -> uint { ret nelts; } - fn add_front(t: &T) { + fn add_front(t: T) { let oldlo: uint = lo; if lo == 0u { lo = vec::len::>(elts) - 1u; @@ -65,7 +66,7 @@ fn create<@T>() -> t { elts[lo] = option::some::(t); nelts += 1u; } - fn add_back(t: &T) { + fn add_back(t: T) { if lo == hi && nelts != 0u { elts = grow::(nelts, lo, elts); lo = 0u; diff --git a/src/lib/ebml.rs b/src/lib/ebml.rs index 09d0bee1a60..6b380850a61 100644 --- a/src/lib/ebml.rs +++ b/src/lib/ebml.rs @@ -17,7 +17,7 @@ type ebml_state = {ebml_tag: ebml_tag, tag_pos: uint, data_pos: uint}; // ebml reading type doc = {data: @[u8], start: uint, end: uint}; -fn vint_at(data: &[u8], start: uint) -> {val: uint, next: uint} { +fn vint_at(data: [u8], start: uint) -> {val: uint, next: uint} { let a = data[start]; if a & 0x80u8 != 0u8 { ret {val: a & 0x7fu8 as uint, next: start + 1u}; } if a & 0x40u8 != 0u8 { @@ -39,11 +39,11 @@ fn vint_at(data: &[u8], start: uint) -> {val: uint, next: uint} { } else { log_err "vint too big"; fail; } } -fn new_doc(data: &@[u8]) -> doc { +fn new_doc(data: @[u8]) -> doc { ret {data: data, start: 0u, end: vec::len::(*data)}; } -fn doc_at(data: &@[u8], start: uint) -> doc { +fn doc_at(data: @[u8], start: uint) -> doc { let elt_tag = vint_at(*data, start); let elt_size = vint_at(*data, elt_tag.next); let end = elt_size.next + elt_size.val; @@ -98,7 +98,7 @@ iter tagged_docs(d: doc, tg: uint) -> doc { fn doc_data(d: doc) -> [u8] { ret vec::slice::(*d.data, d.start, d.end); } -fn be_uint_from_bytes(data: &@[u8], start: uint, size: uint) -> uint { +fn be_uint_from_bytes(data: @[u8], start: uint, size: uint) -> uint { let sz = size; assert (sz <= 4u); let val = 0u; @@ -119,7 +119,7 @@ fn doc_as_uint(d: doc) -> uint { // ebml writing type writer = {writer: io::buf_writer, mutable size_positions: [uint]}; -fn write_sized_vint(w: &io::buf_writer, n: uint, size: uint) { +fn write_sized_vint(w: io::buf_writer, n: uint, size: uint) { let buf: [u8]; alt size { 1u { buf = [0x80u8 | (n as u8)]; } @@ -139,7 +139,7 @@ fn write_sized_vint(w: &io::buf_writer, n: uint, size: uint) { w.write(buf); } -fn write_vint(w: &io::buf_writer, n: uint) { +fn write_vint(w: io::buf_writer, n: uint) { if n < 0x7fu { write_sized_vint(w, n, 1u); ret; } if n < 0x4000u { write_sized_vint(w, n, 2u); ret; } if n < 0x200000u { write_sized_vint(w, n, 3u); ret; } @@ -148,14 +148,14 @@ fn write_vint(w: &io::buf_writer, n: uint) { fail; } -fn create_writer(w: &io::buf_writer) -> writer { +fn create_writer(w: io::buf_writer) -> writer { let size_positions: [uint] = []; ret {writer: w, mutable size_positions: size_positions}; } // TODO: Provide a function to write the standard ebml header. -fn start_tag(w: &writer, tag_id: uint) { +fn start_tag(w: writer, tag_id: uint) { // Write the tag ID: write_vint(w.writer, tag_id); @@ -166,7 +166,7 @@ fn start_tag(w: &writer, tag_id: uint) { w.writer.write(zeroes); } -fn end_tag(w: &writer) { +fn end_tag(w: writer) { let last_size_pos = vec::pop::(w.size_positions); let cur_pos = w.writer.tell(); w.writer.seek(last_size_pos as int, io::seek_set); diff --git a/src/lib/either.rs b/src/lib/either.rs index 6f2a27a958d..73efdbb70f1 100644 --- a/src/lib/either.rs +++ b/src/lib/either.rs @@ -6,12 +6,12 @@ import option::none; tag t { left(T); right(U); } fn either(f_left: &block(&T) -> V, f_right: &block(&U) -> V, - value: &t) -> V { + V>(f_left: block(T) -> V, f_right: block(U) -> V, value: t) -> + V { alt value { left(l) { f_left(l) } right(r) { f_right(r) } } } -fn lefts(eithers: &[t]) -> [T] { +fn lefts(eithers: [t]) -> [T] { let result: [T] = []; for elt: t in eithers { alt elt { left(l) { result += [l] } _ {/* fallthrough */ } } @@ -19,7 +19,7 @@ fn lefts(eithers: &[t]) -> [T] { ret result; } -fn rights(eithers: &[t]) -> [U] { +fn rights(eithers: [t]) -> [U] { let result: [U] = []; for elt: t in eithers { alt elt { right(r) { result += [r] } _ {/* fallthrough */ } } @@ -27,7 +27,7 @@ fn rights(eithers: &[t]) -> [U] { ret result; } -fn partition(eithers: &[t]) -> {lefts: [T], rights: [U]} { +fn partition(eithers: [t]) -> {lefts: [T], rights: [U]} { let lefts: [T] = []; let rights: [U] = []; for elt: t in eithers { diff --git a/src/lib/extfmt.rs b/src/lib/extfmt.rs index edd99120872..7a645201741 100644 --- a/src/lib/extfmt.rs +++ b/src/lib/extfmt.rs @@ -68,13 +68,13 @@ mod ct { // A fragment of the output sequence tag piece { piece_string(str); piece_conv(conv); } - type error_fn = fn(&str) -> ! ; + type error_fn = fn(str) -> ! ; - fn parse_fmt_string(s: &str, error: error_fn) -> [piece] { + fn parse_fmt_string(s: str, error: error_fn) -> [piece] { let pieces: [piece] = []; let lim = str::byte_len(s); let buf = ""; - fn flush_buf(buf: &str, pieces: &mutable [piece]) -> str { + fn flush_buf(buf: str, pieces: &mutable [piece]) -> str { if str::byte_len(buf) > 0u { let piece = piece_string(buf); pieces += [piece]; @@ -103,7 +103,7 @@ mod ct { buf = flush_buf(buf, pieces); ret pieces; } - fn peek_num(s: &str, i: uint, lim: uint) -> + fn peek_num(s: str, i: uint, lim: uint) -> option::t<{num: uint, next: uint}> { if i >= lim { ret none; } let c = s[i]; @@ -118,7 +118,7 @@ mod ct { } }; } - fn parse_conversion(s: &str, i: uint, lim: uint, error: error_fn) -> + fn parse_conversion(s: str, i: uint, lim: uint, error: error_fn) -> {piece: piece, next: uint} { let parm = parse_parameter(s, i, lim); let flags = parse_flags(s, parm.next, lim); @@ -133,7 +133,7 @@ mod ct { ty: ty.ty}), next: ty.next}; } - fn parse_parameter(s: &str, i: uint, lim: uint) -> + fn parse_parameter(s: str, i: uint, lim: uint) -> {param: option::t, next: uint} { if i >= lim { ret {param: none, next: i}; } let num = peek_num(s, i, lim); @@ -148,14 +148,14 @@ mod ct { } }; } - fn parse_flags(s: &str, i: uint, lim: uint) -> + fn parse_flags(s: str, i: uint, lim: uint) -> {flags: [flag], next: uint} { let noflags: [flag] = []; if i >= lim { ret {flags: noflags, next: i}; } // FIXME: This recursion generates illegal instructions if the return // value isn't boxed. Only started happening after the ivec conversion - fn more_(f: flag, s: &str, i: uint, lim: uint) -> + fn more_(f: flag, s: str, i: uint, lim: uint) -> @{flags: [flag], next: uint} { let next = parse_flags(s, i + 1u, lim); let rest = next.flags; @@ -177,8 +177,7 @@ mod ct { *more(flag_alternate) } else { {flags: noflags, next: i} }; } - fn parse_count(s: &str, i: uint, lim: uint) -> - {count: count, next: uint} { + fn parse_count(s: str, i: uint, lim: uint) -> {count: count, next: uint} { ret if i >= lim { {count: count_implied, next: i} } else if s[i] == '*' as u8 { @@ -198,7 +197,7 @@ mod ct { } }; } - fn parse_precision(s: &str, i: uint, lim: uint) -> + fn parse_precision(s: str, i: uint, lim: uint) -> {count: count, next: uint} { ret if i >= lim { {count: count_implied, next: i} @@ -214,7 +213,7 @@ mod ct { } } else { {count: count_implied, next: i} }; } - fn parse_type(s: &str, i: uint, lim: uint, error: error_fn) -> + fn parse_type(s: str, i: uint, lim: uint, error: error_fn) -> {ty: ty, next: uint} { if i >= lim { error("missing type in conversion"); } let tstr = str::substr(s, i, 1u); @@ -270,7 +269,7 @@ mod rt { // instead just use a bool per flag type conv = {flags: [flag], width: count, precision: count, ty: ty}; - fn conv_int(cv: &conv, i: int) -> str { + fn conv_int(cv: conv, i: int) -> str { let radix = 10u; let prec = get_int_precision(cv); let s = int_to_str_prec(i, radix, prec); @@ -283,7 +282,7 @@ mod rt { } ret pad(cv, s, pad_signed); } - fn conv_uint(cv: &conv, u: uint) -> str { + fn conv_uint(cv: conv, u: uint) -> str { let prec = get_int_precision(cv); let rs = alt cv.ty { @@ -295,17 +294,17 @@ mod rt { }; ret pad(cv, rs, pad_unsigned); } - fn conv_bool(cv: &conv, b: bool) -> str { + fn conv_bool(cv: conv, b: bool) -> str { let s = if b { "true" } else { "false" }; // run the boolean conversion through the string conversion logic, // giving it the same rules for precision, etc. ret conv_str(cv, s); } - fn conv_char(cv: &conv, c: char) -> str { + fn conv_char(cv: conv, c: char) -> str { ret pad(cv, str::from_char(c), pad_nozero); } - fn conv_str(cv: &conv, s: &str) -> str { + fn conv_str(cv: conv, s: str) -> str { // For strings, precision is the maximum characters // displayed @@ -346,7 +345,7 @@ mod rt { } else { s } }; } - fn get_int_precision(cv: &conv) -> uint { + fn get_int_precision(cv: conv) -> uint { ret alt cv.precision { count_is(c) { c as uint } count_implied. { 1u } @@ -360,7 +359,7 @@ mod rt { ret str::unsafe_from_bytes(svec); } tag pad_mode { pad_signed; pad_unsigned; pad_nozero; } - fn pad(cv: &conv, s: &str, mode: pad_mode) -> str { + fn pad(cv: conv, s: str, mode: pad_mode) -> str { let uwidth; alt cv.width { count_implied. { ret s; } @@ -388,7 +387,7 @@ mod rt { pad_signed. { might_zero_pad = true; signed = true; } pad_unsigned. { might_zero_pad = true; } } - fn have_precision(cv: &conv) -> bool { + fn have_precision(cv: conv) -> bool { ret alt cv.precision { count_implied. { false } _ { true } }; } let zero_padding = false; @@ -414,7 +413,7 @@ mod rt { } ret padstr + s; } - fn have_flag(flags: &[flag], f: flag) -> bool { + fn have_flag(flags: [flag], f: flag) -> bool { for candidate: flag in flags { if candidate == f { ret true; } } ret false; } diff --git a/src/lib/fs.rs b/src/lib/fs.rs index 3ab6d3f5786..d48c5487bd4 100644 --- a/src/lib/fs.rs +++ b/src/lib/fs.rs @@ -10,7 +10,7 @@ fn path_sep() -> str { ret str::from_char(os_fs::path_sep); } type path = str; -fn dirname(p: &path) -> path { +fn dirname(p: path) -> path { let i: int = str::rindex(p, os_fs::path_sep as u8); if i == -1 { i = str::rindex(p, os_fs::alt_path_sep as u8); @@ -19,7 +19,7 @@ fn dirname(p: &path) -> path { ret str::substr(p, 0u, i as uint); } -fn basename(p: &path) -> path { +fn basename(p: path) -> path { let i: int = str::rindex(p, os_fs::path_sep as u8); if i == -1 { i = str::rindex(p, os_fs::alt_path_sep as u8); @@ -32,7 +32,7 @@ fn basename(p: &path) -> path { // FIXME: Need some typestate to avoid bounds check when len(pre) == 0 -fn connect(pre: &path, post: &path) -> path { +fn connect(pre: path, post: path) -> path { let len = str::byte_len(pre); ret if pre[len - 1u] == os_fs::path_sep as u8 { @@ -41,11 +41,11 @@ fn connect(pre: &path, post: &path) -> path { } else { pre + path_sep() + post }; } -fn file_is_dir(p: &path) -> bool { +fn file_is_dir(p: path) -> bool { ret str::as_buf(p, {|buf| rustrt::rust_file_is_dir(buf) != 0 }); } -fn list_dir(p: &path) -> [str] { +fn list_dir(p: path) -> [str] { let p = p; let pl = str::byte_len(p); if pl == 0u || p[pl - 1u] as char != os_fs::path_sep { p += path_sep(); } @@ -58,11 +58,11 @@ fn list_dir(p: &path) -> [str] { ret full_paths; } -fn path_is_absolute(p: &path) -> bool { ret os_fs::path_is_absolute(p); } +fn path_is_absolute(p: path) -> bool { ret os_fs::path_is_absolute(p); } // FIXME: under Windows, we should prepend the current drive letter to paths // that start with a slash. -fn make_absolute(p: &path) -> path { +fn make_absolute(p: path) -> path { if path_is_absolute(p) { ret p; } else { ret connect(getcwd(), p); } } diff --git a/src/lib/fun_treemap.rs b/src/lib/fun_treemap.rs index 3d4894c4367..d8d6e217c95 100644 --- a/src/lib/fun_treemap.rs +++ b/src/lib/fun_treemap.rs @@ -29,7 +29,7 @@ type treemap<@K, @V> = @tree_node; fn init<@K, @V>() -> treemap { @empty } -fn insert<@K, @V>(m: &treemap, k: &K, v: &V) -> treemap { +fn insert<@K, @V>(m: treemap, k: K, v: V) -> treemap { @alt m { @empty. { node(@k, @v, @empty, @empty) } @node(@kk, vv, left, right) { @@ -42,7 +42,7 @@ fn insert<@K, @V>(m: &treemap, k: &K, v: &V) -> treemap { } } -fn find<@K, @V>(m: &treemap, k: &K) -> option { +fn find<@K, @V>(m: treemap, k: K) -> option { alt *m { empty. { none } node(@kk, @v, left, right) { @@ -55,7 +55,7 @@ fn find<@K, @V>(m: &treemap, k: &K) -> option { // Performs an in-order traversal -fn traverse<@K, @V>(m: &treemap, f: fn(&K, &V)) { +fn traverse<@K, @V>(m: treemap, f: fn(K, V)) { alt *m { empty. { } node(@k, @v, _, _) { diff --git a/src/lib/generic_os.rs b/src/lib/generic_os.rs index 8a34f76a387..9137df4acf5 100644 --- a/src/lib/generic_os.rs +++ b/src/lib/generic_os.rs @@ -3,7 +3,7 @@ import str::sbuf; #[cfg(target_os = "linux")] #[cfg(target_os = "macos")] -fn getenv(n: &str) -> option::t { +fn getenv(n: str) -> option::t { let s = str::as_buf(n, {|buf| os::libc::getenv(buf) }); ret if unsafe::reinterpret_cast(s) == 0 { option::none:: @@ -15,7 +15,7 @@ fn getenv(n: &str) -> option::t { #[cfg(target_os = "linux")] #[cfg(target_os = "macos")] -fn setenv(n: &str, v: &str) { +fn setenv(n: str, v: str) { // FIXME (868) let _: () = str::as_buf(n, @@ -30,7 +30,7 @@ fn setenv(n: &str, v: &str) { } #[cfg(target_os = "win32")] -fn getenv(n: &str) -> option::t { +fn getenv(n: str) -> option::t { let nsize = 256u; while true { let v: [u8] = []; @@ -53,13 +53,18 @@ fn getenv(n: &str) -> option::t { } #[cfg(target_os = "win32")] -fn setenv(n: &str, v: &str) { +fn setenv(n: str, v: str) { // FIXME (868) - let _: () = str::as_buf(n, {|nbuf| - let _: () = str::as_buf(v, {|vbuf| - os::kernel32::SetEnvironmentVariableA(nbuf, vbuf); - }); - }); + let _: () = + str::as_buf(n, + {|nbuf| + let _: () = + str::as_buf(v, + {|vbuf| + os::kernel32::SetEnvironmentVariableA(nbuf, + vbuf); + }); + }); } // Local Variables: diff --git a/src/lib/getopts.rs b/src/lib/getopts.rs index c36f766a5dc..de2573c13b3 100644 --- a/src/lib/getopts.rs +++ b/src/lib/getopts.rs @@ -37,29 +37,29 @@ tag occur { req; optional; multi; } type opt = {name: name, hasarg: hasarg, occur: occur}; -fn mkname(nm: &str) -> name { +fn mkname(nm: str) -> name { ret if str::char_len(nm) == 1u { short(str::char_at(nm, 0u)) } else { long(nm) }; } -fn reqopt(name: &str) -> opt { +fn reqopt(name: str) -> opt { ret {name: mkname(name), hasarg: yes, occur: req}; } -fn optopt(name: &str) -> opt { +fn optopt(name: str) -> opt { ret {name: mkname(name), hasarg: yes, occur: optional}; } -fn optflag(name: &str) -> opt { +fn optflag(name: str) -> opt { ret {name: mkname(name), hasarg: no, occur: optional}; } -fn optflagopt(name: &str) -> opt { +fn optflagopt(name: str) -> opt { ret {name: mkname(name), hasarg: maybe, occur: optional}; } -fn optmulti(name: &str) -> opt { +fn optmulti(name: str) -> opt { ret {name: mkname(name), hasarg: yes, occur: multi}; } @@ -67,15 +67,15 @@ tag optval { val(str); given; } type match = {opts: [opt], vals: [mutable [optval]], free: [str]}; -fn is_arg(arg: &str) -> bool { +fn is_arg(arg: str) -> bool { ret str::byte_len(arg) > 1u && arg[0] == '-' as u8; } -fn name_str(nm: &name) -> str { +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::t { +fn find_opt(opts: [opt], nm: name) -> option::t { let i = 0u; let l = vec::len::(opts); while i < l { if opts[i].name == nm { ret some::(i); } i += 1u; } @@ -90,7 +90,7 @@ tag fail_ { unexpected_argument(str); } -fn fail_str(f: &fail_) -> str { +fn fail_str(f: fail_) -> str { ret alt f { argument_missing(nm) { "Argument to option '" + nm + "' missing." } unrecognized_option(nm) { "Unrecognized option: '" + nm + "'." } @@ -106,7 +106,7 @@ fn fail_str(f: &fail_) -> str { tag result { success(match); failure(fail_); } -fn getopts(args: &[str], opts: &[opt]) -> result { +fn getopts(args: [str], opts: [opt]) -> result { let n_opts = vec::len::(opts); fn f(_x: uint) -> [optval] { ret []; } let vals = vec::init_fn_mut::<[optval]>(f, n_opts); @@ -200,24 +200,24 @@ fn getopts(args: &[str], opts: &[opt]) -> result { ret success({opts: opts, vals: 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. { log_err "No option '" + nm + "' defined."; fail } }; } -fn opt_val(m: &match, nm: &str) -> optval { ret opt_vals(m, nm)[0]; } +fn opt_val(m: match, nm: str) -> optval { ret opt_vals(m, nm)[0]; } -fn opt_present(m: &match, nm: &str) -> bool { +fn opt_present(m: match, nm: str) -> bool { ret vec::len::(opt_vals(m, nm)) > 0u; } -fn opt_str(m: &match, nm: &str) -> str { +fn opt_str(m: match, nm: str) -> str { ret alt opt_val(m, nm) { val(s) { s } _ { fail } }; } -fn opt_strs(m: &match, nm: &str) -> [str] { +fn opt_strs(m: match, nm: str) -> [str] { let acc: [str] = []; for v: optval in opt_vals(m, nm) { alt v { val(s) { acc += [s]; } _ { } } @@ -225,7 +225,7 @@ fn opt_strs(m: &match, nm: &str) -> [str] { ret acc; } -fn opt_maybe_str(m: &match, nm: &str) -> option::t { +fn opt_maybe_str(m: match, nm: str) -> option::t { let vals = opt_vals(m, nm); if vec::len::(vals) == 0u { ret none::; } ret alt vals[0] { val(s) { some::(s) } _ { none:: } }; @@ -235,7 +235,7 @@ fn opt_maybe_str(m: &match, nm: &str) -> option::t { /// Returns none if the option was not present, `def` if the option was /// present but no argument was provided, and the argument if the option was /// present and an argument was provided. -fn opt_default(m: &match, nm: &str, def: &str) -> option::t { +fn opt_default(m: match, nm: str, def: str) -> option::t { let vals = opt_vals(m, nm); if vec::len::(vals) == 0u { ret none::; } ret alt vals[0] { val(s) { some::(s) } _ { some::(def) } } diff --git a/src/lib/int.rs b/src/lib/int.rs index ef80852c8d3..98d8bb5e157 100644 --- a/src/lib/int.rs +++ b/src/lib/int.rs @@ -32,9 +32,9 @@ pure fn nonnegative(x: int) -> bool { ret x >= 0; } // FIXME: Make sure this works with negative integers. -fn hash(x: &int) -> uint { ret x as uint; } +fn hash(x: int) -> uint { ret x as uint; } -fn eq_alias(x: &int, y: &int) -> bool { ret x == y; } +fn eq_alias(x: int, y: int) -> bool { ret x == y; } iter range(lo: int, hi: int) -> int { let lo_: int = lo; diff --git a/src/lib/io.rs b/src/lib/io.rs index 0889d3ec454..73460e50588 100644 --- a/src/lib/io.rs +++ b/src/lib/io.rs @@ -174,7 +174,7 @@ fn stdin() -> reader { ret new_reader(FILE_buf_reader(rustrt::rust_get_stdin(), option::none)); } -fn file_reader(path: &str) -> reader { +fn file_reader(path: str) -> reader { let f = str::as_buf(path, {|pathbuf| @@ -218,11 +218,11 @@ obj byte_buf_reader(bbuf: byte_buf) { fn tell() -> uint { ret bbuf.pos; } } -fn new_byte_buf_reader(buf: &[u8]) -> buf_reader { +fn new_byte_buf_reader(buf: [u8]) -> buf_reader { ret byte_buf_reader(@{buf: buf, mutable pos: 0u}); } -fn string_reader(s: &str) -> reader { +fn string_reader(s: str) -> reader { ret new_reader(new_byte_buf_reader(str::bytes(s))); } @@ -236,13 +236,13 @@ type buf_writer = // FIXME: eventually u64 obj { - fn write(&[u8]); + fn write([u8]); fn seek(int, seek_style); fn tell() -> uint; }; obj FILE_writer(f: os::libc::FILE, res: option::t<@FILE_res>) { - fn write(v: &[u8]) { + fn write(v: [u8]) { let len = vec::len::(v); let vbuf = vec::unsafe::to_ptr::(v); let nout = os::libc::fwrite(vbuf, len, 1u, f); @@ -257,7 +257,7 @@ obj FILE_writer(f: os::libc::FILE, res: option::t<@FILE_res>) { resource fd_res(fd: int) { os::libc::close(fd); } obj fd_buf_writer(fd: int, res: option::t<@fd_res>) { - fn write(v: &[u8]) { + fn write(v: [u8]) { let len = vec::len::(v); let count = 0u; let vbuf; @@ -282,7 +282,7 @@ obj fd_buf_writer(fd: int, res: option::t<@fd_res>) { } } -fn file_buf_writer(path: &str, flags: &[fileflag]) -> buf_writer { +fn file_buf_writer(path: str, flags: [fileflag]) -> buf_writer { let fflags: int = os::libc_constants::O_WRONLY() | os::libc_constants::O_BINARY(); for f: fileflag in flags { @@ -313,12 +313,12 @@ type writer = // function will be provided for general encoded string output obj { fn get_buf_writer() -> buf_writer; - fn write_str(&str); - fn write_line(&str); + fn write_str(str); + fn write_line(str); fn write_char(char); fn write_int(int); fn write_uint(uint); - fn write_bytes(&[u8]); + fn write_bytes([u8]); fn write_le_uint(uint, uint); fn write_le_int(int, uint); fn write_be_uint(uint, uint); @@ -339,8 +339,8 @@ fn uint_to_be_bytes(n: uint, size: uint) -> [u8] { obj new_writer(out: buf_writer) { fn get_buf_writer() -> buf_writer { ret out; } - fn write_str(s: &str) { out.write(str::bytes(s)); } - fn write_line(s: &str) { + fn write_str(s: str) { out.write(str::bytes(s)); } + fn write_line(s: str) { out.write(str::bytes(s)); out.write(str::bytes("\n")); } @@ -351,7 +351,7 @@ obj new_writer(out: buf_writer) { } fn write_int(n: int) { out.write(str::bytes(int::to_str(n, 10u))); } fn write_uint(n: uint) { out.write(str::bytes(uint::to_str(n, 10u))); } - fn write_bytes(bytes: &[u8]) { out.write(bytes); } + fn write_bytes(bytes: [u8]) { out.write(bytes); } fn write_le_uint(n: uint, size: uint) { out.write(uint_to_le_bytes(n, size)); } @@ -363,13 +363,13 @@ obj new_writer(out: buf_writer) { } } -fn file_writer(path: &str, flags: &[fileflag]) -> writer { +fn file_writer(path: str, flags: [fileflag]) -> writer { ret new_writer(file_buf_writer(path, flags)); } // FIXME: fileflags -fn buffered_file_buf_writer(path: &str) -> buf_writer { +fn buffered_file_buf_writer(path: str) -> buf_writer { let f = str::as_buf(path, {|pathbuf| @@ -396,7 +396,7 @@ type str_writer = type mutable_byte_buf = @{mutable buf: [mutable u8], mutable pos: uint}; obj byte_buf_writer(buf: mutable_byte_buf) { - fn write(v: &[u8]) { + fn write(v: [u8]) { // Fast path. if buf.pos == vec::len(buf.buf) { @@ -453,11 +453,11 @@ fn seek_in_buf(offset: int, pos: uint, len: uint, whence: seek_style) -> ret bpos as uint; } -fn read_whole_file_str(file: &str) -> str { +fn read_whole_file_str(file: str) -> str { str::unsafe_from_bytes(read_whole_file(file)) } -fn read_whole_file(file: &str) -> [u8] { +fn read_whole_file(file: str) -> [u8] { // FIXME: There's a lot of copying here file_reader(file).read_whole_stream() diff --git a/src/lib/linux_os.rs b/src/lib/linux_os.rs index b393d9a1e08..5cd71d13b79 100644 --- a/src/lib/linux_os.rs +++ b/src/lib/linux_os.rs @@ -54,7 +54,7 @@ fn exec_suffix() -> str { ret ""; } fn target_os() -> str { ret "linux"; } -fn dylib_filename(base: &str) -> str { ret "lib" + base + ".so"; } +fn dylib_filename(base: str) -> str { ret "lib" + base + ".so"; } fn pipe() -> {in: int, out: int} { let fds = {mutable in: 0, mutable out: 0}; diff --git a/src/lib/list.rs b/src/lib/list.rs index 4f3cc5b2238..b3484281b1c 100644 --- a/src/lib/list.rs +++ b/src/lib/list.rs @@ -3,7 +3,7 @@ import option::none; tag list { cons(T, @list); nil; } -fn from_vec<@T>(v: &[T]) -> list { +fn from_vec<@T>(v: [T]) -> list { let l = nil::; // FIXME: This would be faster and more space efficient if it looped over // a reverse vector iterator. Unfortunately generic iterators seem not to @@ -13,7 +13,7 @@ fn from_vec<@T>(v: &[T]) -> list { ret l; } -fn foldl<@T, @U>(ls_: &list, u: &U, f: &block(&T, &U) -> U) -> U { +fn foldl<@T, @U>(ls_: list, u: U, f: block(T, U) -> U) -> U { let accum: U = u; let ls = ls_; while true { @@ -25,8 +25,7 @@ fn foldl<@T, @U>(ls_: &list, u: &U, f: &block(&T, &U) -> U) -> U { ret accum; } -fn find<@T, @U>(ls_: &list, f: &block(&T) -> option::t) -> - option::t { +fn find<@T, @U>(ls_: list, f: block(T) -> option::t) -> option::t { let ls = ls_; while true { alt ls { @@ -39,7 +38,7 @@ fn find<@T, @U>(ls_: &list, f: &block(&T) -> option::t) -> ret none; } -fn has<@T>(ls_: &list, elt: &T) -> bool { +fn has<@T>(ls_: list, elt: T) -> bool { let ls = ls_; while true { alt ls { @@ -50,20 +49,20 @@ fn has<@T>(ls_: &list, elt: &T) -> bool { ret false; } -fn length<@T>(ls: &list) -> uint { - fn count(_t: &T, u: &uint) -> uint { ret u + 1u; } +fn length<@T>(ls: list) -> uint { + fn count(_t: T, u: uint) -> uint { ret u + 1u; } ret foldl(ls, 0u, count); } -fn cdr<@T>(ls: &list) -> list { +fn cdr<@T>(ls: list) -> list { alt ls { cons(_, tl) { ret *tl; } nil. { fail "list empty" } } } -fn car<@T>(ls: &list) -> T { +fn car<@T>(ls: list) -> T { alt ls { cons(hd, _) { ret hd; } nil. { fail "list empty" } } } -fn append<@T>(l: &list, m: &list) -> list { +fn append<@T>(l: list, m: list) -> list { alt l { nil. { ret m; } cons(x, xs) { let rest = append(*xs, m); ret cons(x, @rest); } diff --git a/src/lib/macos_os.rs b/src/lib/macos_os.rs index e18fdd5b32f..3a63a9d2ffb 100644 --- a/src/lib/macos_os.rs +++ b/src/lib/macos_os.rs @@ -51,7 +51,7 @@ fn exec_suffix() -> str { ret ""; } fn target_os() -> str { ret "macos"; } -fn dylib_filename(base: &str) -> str { ret "lib" + base + ".dylib"; } +fn dylib_filename(base: str) -> str { ret "lib" + base + ".dylib"; } fn pipe() -> {in: int, out: int} { let fds = {mutable in: 0, mutable out: 0}; diff --git a/src/lib/map.rs b/src/lib/map.rs index d54eae03d10..81be20a6620 100644 --- a/src/lib/map.rs +++ b/src/lib/map.rs @@ -1,27 +1,27 @@ /** * Hashmap implementation. */ -type hashfn = fn(&K) -> uint; +type hashfn = fn(K) -> uint; -type eqfn = fn(&K, &K) -> bool; +type eqfn = fn(K, K) -> bool; type hashmap = obj { fn size() -> uint; - fn insert(&K, &V) -> bool; - fn contains_key(&K) -> bool; - fn get(&K) -> V; - fn find(&K) -> option::t; - fn remove(&K) -> option::t; + fn insert(K, V) -> bool; + fn contains_key(K) -> bool; + fn get(K) -> V; + fn find(K) -> option::t; + fn remove(K) -> option::t; fn rehash(); iter items() -> @{key: K, val: V}; iter keys() -> K; }; type hashset = hashmap; -fn set_add<@K>(set: hashset, key: &K) -> bool { ret set.insert(key, ()); } +fn set_add<@K>(set: hashset, key: K) -> bool { ret set.insert(key, ()); } -fn mk_hashmap<@K, @V>(hasher: &hashfn, eqer: &eqfn) -> hashmap { +fn mk_hashmap<@K, @V>(hasher: hashfn, eqer: eqfn) -> hashmap { let initial_capacity: uint = 32u; // 2^5 let load_factor: util::rational = {num: 3, den: 4}; @@ -54,9 +54,9 @@ fn mk_hashmap<@K, @V>(hasher: &hashfn, eqer: &eqfn) -> hashmap { */ fn insert_common<@K, - @V>(hasher: &hashfn, eqer: &eqfn, - bkts: &[mutable bucket], nbkts: uint, key: &K, - val: &V) -> bool { + @V>(hasher: hashfn, eqer: eqfn, + bkts: [mutable bucket], nbkts: uint, key: K, + val: V) -> bool { let i: uint = 0u; let h: uint = hasher(key); while i < nbkts { @@ -75,8 +75,8 @@ fn mk_hashmap<@K, @V>(hasher: &hashfn, eqer: &eqfn) -> hashmap { fail; // full table } fn find_common<@K, - @V>(hasher: &hashfn, eqer: &eqfn, - bkts: &[mutable bucket], nbkts: uint, key: &K) -> + @V>(hasher: hashfn, eqer: eqfn, + bkts: [mutable bucket], nbkts: uint, key: K) -> option::t { let i: uint = 0u; let h: uint = hasher(key); @@ -97,9 +97,9 @@ fn mk_hashmap<@K, @V>(hasher: &hashfn, eqer: &eqfn) -> hashmap { ret option::none; } fn rehash<@K, - @V>(hasher: &hashfn, eqer: &eqfn, - oldbkts: &[mutable bucket], _noldbkts: uint, - newbkts: &[mutable bucket], nnewbkts: uint) { + @V>(hasher: hashfn, eqer: eqfn, + oldbkts: [mutable bucket], _noldbkts: uint, + newbkts: [mutable bucket], nnewbkts: uint) { for b: bucket in oldbkts { alt b { some(k_, v_) { @@ -119,7 +119,7 @@ fn mk_hashmap<@K, @V>(hasher: &hashfn, eqer: &eqfn) -> hashmap { mutable nelts: uint, lf: util::rational) { fn size() -> uint { ret nelts; } - fn insert(key: &K, val: &V) -> bool { + fn insert(key: K, val: V) -> bool { let load: util::rational = {num: nelts + 1u as int, den: nbkts as int}; if !util::rational_leq(load, lf) { @@ -135,22 +135,22 @@ fn mk_hashmap<@K, @V>(hasher: &hashfn, eqer: &eqfn) -> hashmap { } ret false; } - fn contains_key(key: &K) -> bool { + fn contains_key(key: K) -> bool { ret alt find_common(hasher, eqer, bkts, nbkts, key) { option::some(_) { true } _ { false } }; } - fn get(key: &K) -> V { + fn get(key: K) -> V { ret alt find_common(hasher, eqer, bkts, nbkts, key) { option::some(val) { val } _ { fail } }; } - fn find(key: &K) -> option::t { + fn find(key: K) -> option::t { be find_common(hasher, eqer, bkts, nbkts, key); } - fn remove(key: &K) -> option::t { + fn remove(key: K) -> option::t { let i: uint = 0u; let h: uint = hasher(key); while i < nbkts { @@ -199,14 +199,14 @@ fn new_str_hash<@V>() -> hashmap { } fn new_int_hash<@V>() -> hashmap { - fn hash_int(x: &int) -> uint { ret x as uint; } - fn eq_int(a: &int, b: &int) -> bool { ret a == b; } + fn hash_int(x: int) -> uint { ret x as uint; } + fn eq_int(a: int, b: int) -> bool { ret a == b; } ret mk_hashmap(hash_int, eq_int); } fn new_uint_hash<@V>() -> hashmap { - fn hash_uint(x: &uint) -> uint { ret x; } - fn eq_uint(a: &uint, b: &uint) -> bool { ret a == b; } + fn hash_uint(x: uint) -> uint { ret x; } + fn eq_uint(a: uint, b: uint) -> bool { ret a == b; } ret mk_hashmap(hash_uint, eq_uint); } diff --git a/src/lib/net.rs b/src/lib/net.rs index be778d9858e..c7c042a54a9 100644 --- a/src/lib/net.rs +++ b/src/lib/net.rs @@ -12,8 +12,8 @@ fn format_addr(ip: ip_addr) -> str { } } -fn parse_addr(ip: &str) -> ip_addr { - let parts = vec::map({|&s| uint::from_str(s) }, str::split(ip, "."[0])); +fn parse_addr(ip: str) -> ip_addr { + let parts = vec::map({|s| uint::from_str(s) }, str::split(ip, "."[0])); if vec::len(parts) != 4u { fail "Too many dots in IP address"; } for i in parts { if i > 255u { fail "Invalid IP Address part."; } } ipv4(parts[0] as u8, parts[1] as u8, parts[2] as u8, parts[3] as u8) diff --git a/src/lib/option.rs b/src/lib/option.rs index ea14ef2b867..c10c22ae18d 100644 --- a/src/lib/option.rs +++ b/src/lib/option.rs @@ -2,30 +2,30 @@ tag t<@T> { none; some(T); } -fn get<@T>(opt: &t) -> T { +fn get<@T>(opt: t) -> T { alt opt { some(x) { x } none. { fail "option none" } } } -fn map<@T, @U>(f: &block(&T) -> U, opt: &t) -> t { +fn map<@T, @U>(f: block(T) -> U, opt: t) -> t { alt opt { some(x) { some(f(x)) } none. { none } } } -fn is_none<@T>(opt: &t) -> bool { +fn is_none<@T>(opt: t) -> bool { alt opt { none. { true } some(_) { false } } } -fn is_some<@T>(opt: &t) -> bool { !is_none(opt) } +fn is_some<@T>(opt: t) -> bool { !is_none(opt) } -fn from_maybe<@T>(def: &T, opt: &t) -> T { +fn from_maybe<@T>(def: T, opt: t) -> T { alt opt { some(x) { x } none. { def } } } -fn maybe<@T, @U>(def: &U, f: &block(&T) -> U, opt: &t) -> U { +fn maybe<@T, @U>(def: U, f: block(T) -> U, opt: t) -> U { alt opt { none. { def } some(t) { f(t) } } } // Can be defined in terms of the above when/if we have const bind. -fn may<@T>(f: &block(&T), opt: &t) { +fn may<@T>(f: block(T), opt: t) { alt opt { none. {/* nothing */ } some(t) { f(t); } } } diff --git a/src/lib/posix_fs.rs b/src/lib/posix_fs.rs index 8b4f06a6a9b..a20f9d7711f 100644 --- a/src/lib/posix_fs.rs +++ b/src/lib/posix_fs.rs @@ -1,9 +1,9 @@ native "rust" mod rustrt { - fn rust_list_files(path: &str) -> [str]; + fn rust_list_files(path: str) -> [str]; } -fn list_dir(path: &str) -> [str] { +fn list_dir(path: str) -> [str] { ret rustrt::rust_list_files(path); // FIXME: No idea why, but this appears to corrupt memory on OSX. I @@ -30,7 +30,7 @@ fn list_dir(path: &str) -> [str] { } -fn path_is_absolute(p: &str) -> bool { ret str::char_at(p, 0u) == '/'; } +fn path_is_absolute(p: str) -> bool { ret str::char_at(p, 0u) == '/'; } const path_sep: char = '/'; diff --git a/src/lib/ptr.rs b/src/lib/ptr.rs index 42815845e47..8d730732c3c 100644 --- a/src/lib/ptr.rs +++ b/src/lib/ptr.rs @@ -1,11 +1,11 @@ // Unsafe pointer utility functions. native "rust-intrinsic" mod rusti { - fn addr_of(val: &T) -> *mutable T; + fn addr_of(val: T) -> *mutable T; fn ptr_offset(ptr: *T, count: uint) -> *T; } -fn addr_of(val: &T) -> *mutable T { ret rusti::addr_of(val); } +fn addr_of(val: T) -> *mutable T { ret rusti::addr_of(val); } fn offset(ptr: *T, count: uint) -> *T { ret rusti::ptr_offset(ptr, count); } diff --git a/src/lib/run_program.rs b/src/lib/run_program.rs index a4adaace38a..43fe4bc3d95 100644 --- a/src/lib/run_program.rs +++ b/src/lib/run_program.rs @@ -12,19 +12,19 @@ native "rust" mod rustrt { int; } -fn arg_vec(prog: &str, args: &[@str]) -> [sbuf] { +fn arg_vec(prog: str, args: [@str]) -> [sbuf] { let argptrs = str::as_buf(prog, {|buf| [buf] }); for arg in args { argptrs += str::as_buf(*arg, {|buf| [buf] }); } argptrs += [unsafe::reinterpret_cast(0)]; ret argptrs; } -fn spawn_process(prog: &str, args: &[str], in_fd: int, out_fd: int, - err_fd: int) -> int { +fn spawn_process(prog: str, args: [str], in_fd: int, out_fd: int, err_fd: int) + -> int { // Note: we have to hold on to these vector references while we hold a // pointer to their buffers let prog = prog; - let args = vec::map({|&arg| @arg }, args); + let args = vec::map({|arg| @arg }, args); let argv = arg_vec(prog, args); let pid = rustrt::rust_run_program(vec::unsafe::to_ptr(argv), in_fd, out_fd, @@ -32,7 +32,7 @@ fn spawn_process(prog: &str, args: &[str], in_fd: int, out_fd: int, ret pid; } -fn run_program(prog: &str, args: &[str]) -> int { +fn run_program(prog: str, args: [str]) -> int { ret os::waitpid(spawn_process(prog, args, 0, 0, 0)); } @@ -49,7 +49,7 @@ type program = resource program_res(p: program) { p.destroy(); } -fn start_program(prog: &str, args: &[str]) -> @program_res { +fn start_program(prog: str, args: [str]) -> @program_res { let pipe_input = os::pipe(); let pipe_output = os::pipe(); let pipe_err = os::pipe(); @@ -100,7 +100,7 @@ fn start_program(prog: &str, args: &[str]) -> @program_res { os::fd_FILE(pipe_err.in), false)); } -fn read_all(rd: &io::reader) -> str { +fn read_all(rd: io::reader) -> str { let buf = ""; while !rd.eof() { let bytes = rd.read_bytes(4096u); @@ -109,7 +109,7 @@ fn read_all(rd: &io::reader) -> str { ret buf; } -fn program_output(prog: &str, args: &[str]) -> +fn program_output(prog: str, args: [str]) -> {status: int, out: str, err: str} { let pr = start_program(prog, args); pr.close_input(); diff --git a/src/lib/sha1.rs b/src/lib/sha1.rs index 25003a4b128..313ec407e26 100644 --- a/src/lib/sha1.rs +++ b/src/lib/sha1.rs @@ -15,8 +15,8 @@ type sha1 = // Reset the sha1 state for reuse. This is called // automatically during construction obj { - fn input(&[u8]); - fn input_str(&str); + fn input([u8]); + fn input_str(str); fn result() -> [u8]; fn result_str() -> str; fn reset(); @@ -44,7 +44,7 @@ fn mk_sha1() -> sha1 { mutable computed: bool, work_buf: [mutable u32]}; - fn add_input(st: &sha1state, msg: &[u8]) { + fn add_input(st: sha1state, msg: [u8]) { // FIXME: Should be typestate precondition assert (!st.computed); for element: u8 in msg { @@ -62,7 +62,7 @@ fn mk_sha1() -> sha1 { if st.msg_block_idx == msg_block_len { process_msg_block(st); } } } - fn process_msg_block(st: &sha1state) { + fn process_msg_block(st: sha1state) { // FIXME: Make precondition assert (vec::len(st.h) == digest_buf_len); assert (vec::len(st.work_buf) == work_buf_len); @@ -142,7 +142,7 @@ fn mk_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 rs: [u8] = []; for hpart: u32 in st.h { @@ -164,7 +164,7 @@ fn mk_sha1() -> sha1 { * call process_msg_block() appropriately. When it returns, it * can be assumed that the message digest has been computed. */ - fn pad_msg(st: &sha1state) { + fn pad_msg(st: sha1state) { // FIXME: Should be a precondition assert (vec::len(st.msg_block) == msg_block_len); @@ -215,8 +215,8 @@ fn mk_sha1() -> sha1 { st.h[4] = 0xC3D2E1F0u32; st.computed = false; } - fn input(msg: &[u8]) { add_input(st, msg); } - fn input_str(msg: &str) { add_input(st, str::bytes(msg)); } + fn input(msg: [u8]) { add_input(st, msg); } + fn input_str(msg: str) { add_input(st, str::bytes(msg)); } fn result() -> [u8] { ret mk_result(st); } fn result_str() -> str { let r = mk_result(st); diff --git a/src/lib/smallintmap.rs b/src/lib/smallintmap.rs index d5dcd6bcc78..5d706ea4b4f 100644 --- a/src/lib/smallintmap.rs +++ b/src/lib/smallintmap.rs @@ -14,31 +14,31 @@ fn mk<@T>() -> smallintmap { ret @{mutable v: v}; } -fn insert<@T>(m: &smallintmap, key: uint, val: &T) { +fn insert<@T>(m: smallintmap, key: uint, val: T) { vec::grow_set::>(m.v, key, none::, some::(val)); } -fn find<@T>(m: &smallintmap, key: uint) -> option::t { +fn find<@T>(m: smallintmap, key: uint) -> option::t { if key < vec::len::>(m.v) { ret m.v[key]; } ret none::; } -fn get<@T>(m: &smallintmap, key: uint) -> T { +fn get<@T>(m: smallintmap, key: uint) -> T { alt find::(m, key) { none::. { log_err "smallintmap::get(): key not present"; fail; } some::(v) { ret v; } } } -fn contains_key<@T>(m: &smallintmap, key: uint) -> bool { +fn contains_key<@T>(m: smallintmap, key: uint) -> bool { ret !option::is_none(find::(m, key)); } -fn truncate<@T>(m: &smallintmap, len: uint) { +fn truncate<@T>(m: smallintmap, len: uint) { m.v = vec::slice_mut::>(m.v, 0u, len); } -fn max_key(m: &smallintmap) -> uint { +fn max_key(m: smallintmap) -> uint { ret vec::len::>(m.v); } diff --git a/src/lib/sort.rs b/src/lib/sort.rs index 2a43bde42be..17e7c90ae38 100644 --- a/src/lib/sort.rs +++ b/src/lib/sort.rs @@ -6,10 +6,10 @@ export merge_sort; export quick_sort; export quick_sort3; -type lteq = block(&T, &T) -> bool; +type lteq = block(T, T) -> bool; -fn merge_sort<@T>(le: <eq, v: &[T]) -> [T] { - fn merge<@T>(le: <eq, a: &[T], b: &[T]) -> [T] { +fn merge_sort<@T>(le: lteq, v: [T]) -> [T] { + fn merge<@T>(le: lteq, a: [T], b: [T]) -> [T] { let rs: [T] = []; let a_len: uint = len::(a); let a_ix: uint = 0u; @@ -33,14 +33,14 @@ fn merge_sort<@T>(le: <eq, v: &[T]) -> [T] { ret merge::(le, merge_sort::(le, a), merge_sort::(le, b)); } -fn swap<@T>(arr: &[mutable T], x: uint, y: uint) { +fn swap<@T>(arr: [mutable T], x: uint, y: uint) { let a = arr[x]; arr[x] = arr[y]; arr[y] = a; } -fn part<@T>(compare_func: <eq, arr: &[mutable T], left: uint, - right: uint, pivot: uint) -> uint { +fn part<@T>(compare_func: lteq, arr: [mutable T], left: uint, right: uint, + pivot: uint) -> uint { let pivot_value = arr[pivot]; swap::(arr, pivot, right); let storage_index: uint = left; @@ -56,7 +56,7 @@ fn part<@T>(compare_func: <eq, arr: &[mutable T], left: uint, ret storage_index; } -fn qsort<@T>(compare_func: <eq, arr: &[mutable T], left: uint, +fn qsort<@T>(compare_func: lteq, arr: [mutable T], left: uint, right: uint) { if right > left { let pivot = (left + right) / 2u; @@ -69,7 +69,7 @@ fn qsort<@T>(compare_func: <eq, arr: &[mutable T], left: uint, } } -fn quick_sort<@T>(compare_func: <eq, arr: &[mutable T]) { +fn quick_sort<@T>(compare_func: lteq, arr: [mutable T]) { if len::(arr) == 0u { ret; } qsort::(compare_func, arr, 0u, len::(arr) - 1u); } @@ -79,8 +79,8 @@ fn quick_sort<@T>(compare_func: <eq, arr: &[mutable T]) { // 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' -fn qsort3<@T>(compare_func_lt: <eq, compare_func_eq: <eq, - arr: &[mutable T], left: int, right: int) { +fn qsort3<@T>(compare_func_lt: lteq, compare_func_eq: lteq, + arr: [mutable T], left: int, right: int) { if right <= left { ret; } let v: T = arr[right]; let i: int = left - 1; @@ -127,8 +127,8 @@ fn qsort3<@T>(compare_func_lt: <eq, compare_func_eq: <eq, qsort3::(compare_func_lt, compare_func_eq, arr, i, right); } -fn quick_sort3<@T>(compare_func_lt: <eq, compare_func_eq: <eq, - arr: &[mutable T]) { +fn quick_sort3<@T>(compare_func_lt: lteq, compare_func_eq: lteq, + arr: [mutable T]) { if len::(arr) == 0u { ret; } qsort3::(compare_func_lt, compare_func_eq, arr, 0, (len::(arr) as int) - 1); diff --git a/src/lib/str.rs b/src/lib/str.rs index 1d03f768101..c6edc5cb574 100644 --- a/src/lib/str.rs +++ b/src/lib/str.rs @@ -10,11 +10,11 @@ native "rust" mod rustrt { fn rust_str_push(s: &mutable str, ch: u8); } -fn eq(a: &str, b: &str) -> bool { a == b } +fn eq(a: str, b: str) -> bool { a == b } -fn lteq(a: &str, b: &str) -> bool { a <= b } +fn lteq(a: str, b: str) -> bool { a <= b } -fn hash(s: &str) -> uint { +fn hash(s: str) -> uint { // djb hash. // FIXME: replace with murmur. @@ -37,7 +37,7 @@ const tag_five_b: uint = 248u; const max_five_b: uint = 67108864u; const tag_six_b: uint = 252u; -fn is_utf8(v: &[u8]) -> bool { +fn is_utf8(v: [u8]) -> bool { let i = 0u; let total = vec::len::(v); while i < total { @@ -54,19 +54,19 @@ fn is_utf8(v: &[u8]) -> bool { ret true; } -fn is_ascii(s: &str) -> bool { +fn is_ascii(s: str) -> bool { let i: uint = byte_len(s); while i > 0u { i -= 1u; if s[i] & 128u8 != 0u8 { ret false; } } ret true; } /// Returns true if the string has length 0 -pure fn is_empty(s: &str) -> bool { for c: u8 in s { ret false; } ret true; } +pure fn is_empty(s: str) -> bool { for c: u8 in s { ret false; } ret true; } /// Returns true if the string has length greater than 0 -pure fn is_not_empty(s: &str) -> bool { !is_empty(s) } +pure fn is_not_empty(s: str) -> bool { !is_empty(s) } -fn is_whitespace(s: &str) -> bool { +fn is_whitespace(s: str) -> bool { let i = 0u; let len = char_len(s); while i < len { @@ -76,7 +76,7 @@ fn is_whitespace(s: &str) -> bool { ret true; } -fn byte_len(s: &str) -> uint { +fn byte_len(s: str) -> uint { let v: [u8] = unsafe::reinterpret_cast(s); let vlen = vec::len(v); unsafe::leak(v); @@ -85,14 +85,14 @@ fn byte_len(s: &str) -> uint { ret vlen - 1u; } -fn bytes(s: &str) -> [u8] { +fn bytes(s: str) -> [u8] { let v = unsafe::reinterpret_cast(s); let vcopy = vec::slice(v, 0u, vec::len(v) - 1u); unsafe::leak(v); ret vcopy; } -fn unsafe_from_bytes(v: &[mutable? u8]) -> str { +fn unsafe_from_bytes(v: [mutable? u8]) -> str { let vcopy: [u8] = v + [0u8]; let scopy: str = unsafe::reinterpret_cast(vcopy); unsafe::leak(vcopy); @@ -136,7 +136,7 @@ fn from_char(ch: char) -> str { ret buf; } -fn from_chars(chs: &[char]) -> str { +fn from_chars(chs: [char]) -> str { let buf = ""; for ch: char in chs { push_utf8_bytes(buf, ch); } ret buf; @@ -156,7 +156,7 @@ fn utf8_char_width(b: u8) -> uint { ret 6u; } -fn char_range_at(s: &str, i: uint) -> {ch: char, next: uint} { +fn char_range_at(s: str, i: uint) -> {ch: char, next: uint} { let b0 = s[i]; let w = utf8_char_width(b0); assert (w != 0u); @@ -178,9 +178,9 @@ fn char_range_at(s: &str, i: uint) -> {ch: char, next: uint} { ret {ch: val as char, next: i}; } -fn char_at(s: &str, i: uint) -> char { ret char_range_at(s, i).ch; } +fn char_at(s: str, i: uint) -> char { ret char_range_at(s, i).ch; } -fn char_len(s: &str) -> uint { +fn char_len(s: str) -> uint { let i = 0u; let len = 0u; let total = byte_len(s); @@ -194,7 +194,7 @@ fn char_len(s: &str) -> uint { ret len; } -fn to_chars(s: &str) -> [char] { +fn to_chars(s: str) -> [char] { let buf: [char] = []; let i = 0u; let len = byte_len(s); @@ -225,23 +225,23 @@ fn shift_char(s: &mutable str) -> char { fn unshift_char(s: &mutable str, ch: char) { s = from_char(ch) + s; } -fn index(s: &str, c: u8) -> int { +fn index(s: str, c: u8) -> int { let i: int = 0; for k: u8 in s { if k == c { ret i; } i += 1; } ret -1; } -fn rindex(s: &str, c: u8) -> int { +fn rindex(s: str, c: u8) -> int { let n: int = byte_len(s) as int; while n >= 0 { if s[n] == c { ret n; } n -= 1; } ret n; } -fn find(haystack: &str, needle: &str) -> int { +fn find(haystack: str, needle: str) -> int { let haystack_len: int = byte_len(haystack) as int; let needle_len: int = byte_len(needle) as int; if needle_len == 0 { ret 0; } - fn match_at(haystack: &str, needle: &str, i: int) -> bool { + fn match_at(haystack: str, needle: str, i: int) -> bool { let j: int = i; for c: u8 in needle { if haystack[j] != c { ret false; } j += 1; } ret true; @@ -254,7 +254,7 @@ fn find(haystack: &str, needle: &str) -> int { ret -1; } -fn starts_with(haystack: &str, needle: &str) -> bool { +fn starts_with(haystack: str, needle: str) -> bool { let haystack_len: uint = byte_len(haystack); let needle_len: uint = byte_len(needle); if needle_len == 0u { ret true; } @@ -262,7 +262,7 @@ fn starts_with(haystack: &str, needle: &str) -> bool { ret eq(substr(haystack, 0u, needle_len), needle); } -fn ends_with(haystack: &str, needle: &str) -> bool { +fn ends_with(haystack: str, needle: str) -> bool { let haystack_len: uint = byte_len(haystack); let needle_len: uint = byte_len(needle); ret if needle_len == 0u { @@ -275,11 +275,11 @@ fn ends_with(haystack: &str, needle: &str) -> bool { }; } -fn substr(s: &str, begin: uint, len: uint) -> str { +fn substr(s: str, begin: uint, len: uint) -> str { ret slice(s, begin, begin + len); } -fn slice(s: &str, begin: uint, end: uint) -> str { +fn slice(s: str, begin: uint, end: uint) -> str { // FIXME: Typestate precondition assert (begin <= end); assert (end <= byte_len(s)); @@ -293,7 +293,7 @@ fn slice(s: &str, begin: uint, end: uint) -> str { ret s2; } -fn safe_slice(s: &str, begin: uint, end: uint) : uint::le(begin, end) -> str { +fn safe_slice(s: str, begin: uint, end: uint) : uint::le(begin, end) -> str { // would need some magic to make this a precondition assert (end <= byte_len(s)); ret slice(s, begin, end); @@ -317,11 +317,11 @@ fn pop_byte(s: &mutable str) -> u8 { fn push_byte(s: &mutable str, b: u8) { rustrt::rust_str_push(s, b); } -fn push_bytes(s: &mutable str, bytes: &[u8]) { +fn push_bytes(s: &mutable str, bytes: [u8]) { for byte in bytes { rustrt::rust_str_push(s, byte); } } -fn split(s: &str, sep: u8) -> [str] { +fn split(s: str, sep: u8) -> [str] { let v: [str] = []; let accum: str = ""; let ends_with_sep: bool = false; @@ -336,13 +336,13 @@ fn split(s: &str, sep: u8) -> [str] { ret v; } -fn concat(v: &[str]) -> str { +fn concat(v: [str]) -> str { let s: str = ""; for ss: str in v { s += ss; } ret s; } -fn connect(v: &[str], sep: &str) -> str { +fn connect(v: [str], sep: str) -> str { let s: str = ""; let first: bool = true; for ss: str in v { @@ -353,7 +353,7 @@ fn connect(v: &[str], sep: &str) -> str { } // FIXME: This only handles ASCII -fn to_upper(s: &str) -> str { +fn to_upper(s: str) -> str { let outstr = ""; let ascii_a = 'a' as u8; let ascii_z = 'z' as u8; @@ -369,7 +369,7 @@ fn to_upper(s: &str) -> str { } // FIXME: This is super-inefficient -fn replace(s: &str, from: &str, to: &str) : is_not_empty(from) -> str { +fn replace(s: str, from: str, to: str) : is_not_empty(from) -> str { // FIXME (694): Shouldn't have to check this check (is_not_empty(from)); if byte_len(s) == 0u { @@ -383,12 +383,12 @@ fn replace(s: &str, from: &str, to: &str) : is_not_empty(from) -> str { } // FIXME: Also not efficient -fn char_slice(s: &str, begin: uint, end: uint) -> str { +fn char_slice(s: str, begin: uint, end: uint) -> str { from_chars(vec::slice(to_chars(s), begin, end)) } -fn trim_left(s: &str) -> str { - fn count_whities(s: &[char]) -> uint { +fn trim_left(s: str) -> str { + fn count_whities(s: [char]) -> uint { let i = 0u; while i < vec::len(s) { if !char::is_whitespace(s[i]) { break; } @@ -401,8 +401,8 @@ fn trim_left(s: &str) -> str { ret from_chars(vec::slice(chars, whities, vec::len(chars))); } -fn trim_right(s: &str) -> str { - fn count_whities(s: &[char]) -> uint { +fn trim_right(s: str) -> str { + fn count_whities(s: [char]) -> uint { let i = vec::len(s); while 0u < i { if !char::is_whitespace(s[i - 1u]) { break; } @@ -415,18 +415,18 @@ fn trim_right(s: &str) -> str { ret from_chars(vec::slice(chars, 0u, whities)); } -fn trim(s: &str) -> str { trim_left(trim_right(s)) } +fn trim(s: str) -> str { trim_left(trim_right(s)) } type sbuf = *u8; -fn buf(s: &str) -> sbuf { +fn buf(s: str) -> sbuf { let saddr = ptr::addr_of(s); let vaddr: *[u8] = unsafe::reinterpret_cast(saddr); let buf = vec::to_ptr(*vaddr); ret buf; } -fn as_buf(s: &str, f: &block(sbuf) -> T) -> T { let buf = buf(s); f(buf) } +fn as_buf(s: str, f: block(sbuf) -> T) -> T { let buf = buf(s); f(buf) } fn str_from_cstr(cstr: sbuf) -> str { let res = ""; diff --git a/src/lib/task.rs b/src/lib/task.rs index b00e6c19991..24a9582ba4c 100644 --- a/src/lib/task.rs +++ b/src/lib/task.rs @@ -124,8 +124,8 @@ fn spawn_inner(thunk: -fn(), notify: option>) -> let ptrsize = sys::size_of::<*u8>(); let thunkfn: *mutable uint = cast(sp - ptrsize * 2u); let thunkenv: *mutable uint = cast(sp - ptrsize); - *thunkfn = cast(raw_thunk.code); - *thunkenv = cast(raw_thunk.env); + *thunkfn = cast(raw_thunk.code);; + *thunkenv = cast(raw_thunk.env);; // align the stack to 16 bytes (**task_ptr).stack_ptr = cast(sp - ptrsize * 4u); @@ -136,7 +136,7 @@ fn spawn_inner(thunk: -fn(), notify: option>) -> (**task_ptr).notify_chan = c; } none { } - }; + } // give the thunk environment's allocation to the new task rustrt::migrate_alloc(cast(raw_thunk.env), id); diff --git a/src/lib/test.rs b/src/lib/test.rs index 37fec12e9ce..1ad70db6f17 100644 --- a/src/lib/test.rs +++ b/src/lib/test.rs @@ -49,7 +49,7 @@ type test_desc = {name: test_name, fn: test_fn, ignore: bool}; // 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]) { check (vec::is_not_empty(args)); let opts = alt parse_opts(args) { @@ -64,7 +64,7 @@ type test_opts = {filter: option::t, run_ignored: bool}; type opt_res = either::t; // Parses command line arguments into test options -fn parse_opts(args: &[str]) : vec::is_not_empty(args) -> opt_res { +fn parse_opts(args: [str]) : vec::is_not_empty(args) -> opt_res { let args_ = vec::tail(args); let opts = [getopts::optflag("ignored")]; @@ -94,15 +94,15 @@ type joinable = (task, comm::port); // In cases where test functions and closures it is not ok to just dump them // into a task and run them, so this transformation gives the caller a chance // to create the test task. -type test_to_task = fn(&fn()) -> joinable; +type test_to_task = fn(fn()) -> joinable; // A simple console test runner -fn run_tests_console(opts: &test_opts, tests: &[test_desc]) -> bool { +fn run_tests_console(opts: test_opts, tests: [test_desc]) -> bool { run_tests_console_(opts, tests, default_test_to_task) } -fn run_tests_console_(opts: &test_opts, tests: &[test_desc], - to_task: &test_to_task) -> bool { +fn run_tests_console_(opts: test_opts, tests: [test_desc], + to_task: test_to_task) -> bool { type test_state = @{out: io::writer, @@ -175,20 +175,19 @@ fn run_tests_console_(opts: &test_opts, tests: &[test_desc], ret success; - fn write_ok(out: &io::writer, use_color: bool) { + fn write_ok(out: io::writer, use_color: bool) { write_pretty(out, "ok", term::color_green, use_color); } - fn write_failed(out: &io::writer, use_color: bool) { + fn write_failed(out: io::writer, use_color: bool) { write_pretty(out, "FAILED", term::color_red, use_color); } - fn write_ignored(out: &io::writer, use_color: bool) { + fn write_ignored(out: io::writer, use_color: bool) { write_pretty(out, "ignored", term::color_yellow, use_color); } - fn write_pretty(out: &io::writer, word: &str, color: u8, - use_color: bool) { + fn write_pretty(out: io::writer, word: str, color: u8, use_color: bool) { if use_color && term::color_supported() { term::fg(out.get_buf_writer(), color); } @@ -207,7 +206,7 @@ tag testevent { te_result(test_desc, test_result); } -fn run_tests(opts: &test_opts, tests: &[test_desc], to_task: &test_to_task, +fn run_tests(opts: test_opts, tests: [test_desc], to_task: test_to_task, callback: fn(testevent)) { let filtered_tests = filter_tests(opts, tests); @@ -241,7 +240,7 @@ fn run_tests(opts: &test_opts, tests: &[test_desc], to_task: &test_to_task, fn get_concurrency() -> uint { rustrt::sched_threads() } -fn filter_tests(opts: &test_opts, tests: &[test_desc]) -> [test_desc] { +fn filter_tests(opts: test_opts, tests: [test_desc]) -> [test_desc] { let filtered = tests; // Remove tests that don't match the test filter @@ -256,7 +255,7 @@ fn filter_tests(opts: &test_opts, tests: &[test_desc]) -> [test_desc] { }; let filter = - bind fn (test: &test_desc, filter_str: &str) -> + bind fn (test: test_desc, filter_str: str) -> option::t { if str::find(test.name, filter_str) >= 0 { ret option::some(test); @@ -273,7 +272,7 @@ fn filter_tests(opts: &test_opts, tests: &[test_desc]) -> [test_desc] { filtered } else { let filter = - fn (test: &test_desc) -> option::t { + fn (test: test_desc) -> option::t { if test.ignore { ret option::some({name: test.name, fn: test.fn, @@ -288,7 +287,7 @@ fn filter_tests(opts: &test_opts, tests: &[test_desc]) -> [test_desc] { // Sort the tests alphabetically filtered = { - fn lteq(t1: &test_desc, t2: &test_desc) -> bool { + fn lteq(t1: test_desc, t2: test_desc) -> bool { str::lteq(t1.name, t2.name) } sort::merge_sort(lteq, filtered) @@ -299,7 +298,7 @@ fn filter_tests(opts: &test_opts, tests: &[test_desc]) -> [test_desc] { type test_future = {test: test_desc, wait: fn() -> test_result}; -fn run_test(test: &test_desc, to_task: &test_to_task) -> test_future { +fn run_test(test: test_desc, to_task: test_to_task) -> test_future { if !test.ignore { let test_task = to_task(test.fn); ret {test: test, @@ -315,7 +314,7 @@ fn run_test(test: &test_desc, to_task: &test_to_task) -> test_future { // We need to run our tests in another task in order to trap test failures. // This function only works with functions that don't contain closures. -fn default_test_to_task(f: &fn()) -> joinable { +fn default_test_to_task(f: fn()) -> joinable { fn run_task(f: fn()) { configure_test_task(); f(); } ret task::spawn_joinable(bind run_task(f)); } diff --git a/src/lib/treemap.rs b/src/lib/treemap.rs index cdf9a67042b..bd65a58a8b3 100644 --- a/src/lib/treemap.rs +++ b/src/lib/treemap.rs @@ -23,7 +23,7 @@ type treemap<@K, @V> = @mutable tree_node; fn init<@K, @V>() -> treemap { @mutable empty } -fn insert<@K, @V>(m: &treemap, k: &K, v: &V) { +fn insert<@K, @V>(m: treemap, k: K, v: V) { alt m { @empty. { *m = node(@k, @v, @mutable empty, @mutable empty); } @node(@kk, _, _, _) { @@ -37,13 +37,14 @@ fn insert<@K, @V>(m: &treemap, k: &K, v: &V) { } } -fn find<@K, @V>(m: &treemap, k: &K) -> option { +fn find<@K, @V>(m: treemap, k: K) -> option { alt *m { empty. { none } node(@kk, @v, _, _) { if k == kk { some(v) } else if k < kk { + // Again, ugliness to unpack left and right individually. alt *m { node(_, _, left, _) { find(left, k) } } } else { alt *m { node(_, _, _, right) { find(right, k) } } } @@ -52,7 +53,7 @@ fn find<@K, @V>(m: &treemap, k: &K) -> option { } // Performs an in-order traversal -fn traverse<@K, @V>(m: &treemap, f: fn(&K, &V)) { +fn traverse<@K, @V>(m: treemap, f: fn(K, V)) { alt *m { empty. { } node(k, v, _, _) { diff --git a/src/lib/ufind.rs b/src/lib/ufind.rs index f225a2a7ca3..1a8aacae1da 100644 --- a/src/lib/ufind.rs +++ b/src/lib/ufind.rs @@ -12,7 +12,7 @@ type ufind = {mutable nodes: [mutable node]}; fn make() -> ufind { ret {mutable nodes: [mutable]}; } -fn make_set(ufnd: &ufind) -> uint { +fn make_set(ufnd: ufind) -> uint { let idx = vec::len(ufnd.nodes); ufnd.nodes += [mutable none::]; ret idx; @@ -21,18 +21,18 @@ fn make_set(ufnd: &ufind) -> uint { /// Creates sets as necessary to ensure that least `n` sets are present in the /// data structure. -fn grow(ufnd: &ufind, n: uint) { +fn grow(ufnd: ufind, n: uint) { while set_count(ufnd) < n { make_set(ufnd); } } -fn find(ufnd: &ufind, n: uint) -> uint { +fn find(ufnd: ufind, n: uint) -> uint { alt ufnd.nodes[n] { none. { ret n; } some(m) { let m_ = m; be find(ufnd, m_); } } } -fn union(ufnd: &ufind, m: uint, n: uint) { +fn union(ufnd: ufind, m: uint, n: uint) { let m_root = find(ufnd, m); let n_root = find(ufnd, n); if m_root < n_root { @@ -40,11 +40,11 @@ fn union(ufnd: &ufind, m: uint, n: uint) { } else if m_root > n_root { ufnd.nodes[m_root] = some::(n_root); } } -fn set_count(ufnd: &ufind) -> uint { ret vec::len::(ufnd.nodes); } +fn set_count(ufnd: ufind) -> uint { ret vec::len::(ufnd.nodes); } // Removes all sets with IDs greater than or equal to the given value. -fn prune(ufnd: &ufind, n: uint) { +fn prune(ufnd: ufind, n: uint) { // TODO: Use "slice" once we get rid of "mutable?" let len = vec::len::(ufnd.nodes); diff --git a/src/lib/uint.rs b/src/lib/uint.rs index 3553dc7e2cf..d992ade5a72 100644 --- a/src/lib/uint.rs +++ b/src/lib/uint.rs @@ -39,7 +39,7 @@ fn next_power_of_two(n: uint) -> uint { ret tmp + 1u; } -fn parse_buf(buf: &[u8], radix: uint) -> uint { +fn parse_buf(buf: [u8], radix: uint) -> uint { if vec::len::(buf) == 0u { log_err "parse_buf(): buf is empty"; fail; @@ -56,7 +56,7 @@ fn parse_buf(buf: &[u8], radix: uint) -> uint { fail; } -fn from_str(s: &str) -> uint { parse_buf(str::bytes(s), 10u) } +fn from_str(s: str) -> uint { parse_buf(str::bytes(s), 10u) } fn to_str(num: uint, radix: uint) -> str { let n = num; diff --git a/src/lib/unsafe.rs b/src/lib/unsafe.rs index 79e409d27fc..d5f2a363409 100644 --- a/src/lib/unsafe.rs +++ b/src/lib/unsafe.rs @@ -1,7 +1,7 @@ // Unsafe operations. native "rust-intrinsic" mod rusti { - fn cast(src: &T) -> U; + fn cast(src: T) -> U; } native "rust" mod rustrt { @@ -9,6 +9,6 @@ native "rust" mod rustrt { } // Casts the value at `src` to U. The two types must have the same length. -fn reinterpret_cast(src: &T) -> U { ret rusti::cast(src); } +fn reinterpret_cast(src: T) -> U { ret rusti::cast(src); } fn leak<@T>(thing: -T) { rustrt::leak(thing); } diff --git a/src/lib/util.rs b/src/lib/util.rs index 6041da4d0d0..69418267e9e 100644 --- a/src/lib/util.rs +++ b/src/lib/util.rs @@ -1,6 +1,6 @@ -fn id<@T>(x: &T) -> T { ret x; } +fn id<@T>(x: T) -> T { ret x; } /* FIXME (issue #141): See test/run-pass/constrained-type.rs. Uncomment @@ -9,13 +9,13 @@ type rational = {num: int, den: int}; // : int::positive(*.den); -fn rational_leq(x: &rational, y: &rational) -> bool { +fn rational_leq(x: rational, y: rational) -> bool { // NB: Uses the fact that rationals have positive denominators WLOG: ret x.num * y.den <= y.num * x.den; } -fn orb(a: &bool, b: &bool) -> bool { ret a || b; } +fn orb(a: bool, b: bool) -> bool { ret a || b; } // Local Variables: // mode: rust; // fill-column: 78; diff --git a/src/lib/vec.rs b/src/lib/vec.rs index 1ec736c6e87..c9970ccb5fc 100644 --- a/src/lib/vec.rs +++ b/src/lib/vec.rs @@ -6,7 +6,7 @@ import uint::next_power_of_two; import ptr::addr_of; native "rust-intrinsic" mod rusti { - fn vec_len(v: &[T]) -> uint; + fn vec_len(v: [T]) -> uint; } native "rust" mod rustrt { @@ -19,11 +19,11 @@ fn reserve<@T>(v: &mutable [mutable? T], n: uint) { rustrt::vec_reserve_shared(v, n); } -fn len(v: &[mutable? T]) -> uint { ret rusti::vec_len(v); } +fn len(v: [mutable? T]) -> uint { ret rusti::vec_len(v); } type init_op = fn(uint) -> T; -fn init_fn<@T>(op: &init_op, n_elts: uint) -> [T] { +fn init_fn<@T>(op: init_op, n_elts: uint) -> [T] { let v = []; reserve(v, n_elts); let i: uint = 0u; @@ -32,7 +32,7 @@ fn init_fn<@T>(op: &init_op, n_elts: uint) -> [T] { } // TODO: Remove me once we have slots. -fn init_fn_mut<@T>(op: &init_op, n_elts: uint) -> [mutable T] { +fn init_fn_mut<@T>(op: init_op, n_elts: uint) -> [mutable T] { let v = [mutable]; reserve(v, n_elts); let i: uint = 0u; @@ -40,7 +40,7 @@ fn init_fn_mut<@T>(op: &init_op, n_elts: uint) -> [mutable T] { ret v; } -fn init_elt<@T>(t: &T, n_elts: uint) -> [T] { +fn init_elt<@T>(t: T, n_elts: uint) -> [T] { let v = []; reserve(v, n_elts); let i: uint = 0u; @@ -49,7 +49,7 @@ fn init_elt<@T>(t: &T, n_elts: uint) -> [T] { } // TODO: Remove me once we have slots. -fn init_elt_mut<@T>(t: &T, n_elts: uint) -> [mutable T] { +fn init_elt_mut<@T>(t: T, n_elts: uint) -> [mutable T] { let v = [mutable]; reserve(v, n_elts); let i: uint = 0u; @@ -59,51 +59,51 @@ fn init_elt_mut<@T>(t: &T, n_elts: uint) -> [mutable T] { // FIXME: Possible typestate postcondition: // len(result) == len(v) (needs issue #586) -fn to_mut<@T>(v: &[T]) -> [mutable T] { +fn to_mut<@T>(v: [T]) -> [mutable T] { let vres = [mutable]; for t: T in v { vres += [mutable t]; } ret vres; } // Same comment as from_mut -fn from_mut<@T>(v: &[mutable T]) -> [T] { +fn from_mut<@T>(v: [mutable T]) -> [T] { let vres = []; for t: T in v { vres += [t]; } ret vres; } // Predicates -pure fn is_empty(v: &[mutable? T]) -> bool { +pure fn is_empty(v: [mutable? T]) -> bool { // FIXME: This would be easier if we could just call len for t: T in v { ret false; } ret true; } -pure fn is_not_empty(v: &[mutable? T]) -> bool { ret !is_empty(v); } +pure fn is_not_empty(v: [mutable? T]) -> bool { ret !is_empty(v); } // Accessors /// Returns the first element of a vector -fn head<@T>(v: &[mutable? T]) : is_not_empty(v) -> T { ret v[0]; } +fn head<@T>(v: [mutable? T]) : is_not_empty(v) -> T { ret v[0]; } /// Returns all but the first element of a vector -fn tail<@T>(v: &[mutable? T]) : is_not_empty(v) -> [mutable? T] { +fn tail<@T>(v: [mutable? T]) : is_not_empty(v) -> [mutable? T] { ret slice(v, 1u, len(v)); } /// Returns the last element of `v`. -fn last<@T>(v: &[mutable? T]) -> option::t { +fn last<@T>(v: [mutable? T]) -> option::t { if len(v) == 0u { ret none; } ret some(v[len(v) - 1u]); } /// Returns the last element of a non-empty vector `v`. -fn last_total<@T>(v: &[mutable? T]) : is_not_empty(v) -> T { +fn last_total<@T>(v: [mutable? T]) : is_not_empty(v) -> T { ret v[len(v) - 1u]; } /// Returns a copy of the elements from [`start`..`end`) from `v`. -fn slice<@T>(v: &[mutable? T], start: uint, end: uint) -> [T] { +fn slice<@T>(v: [mutable? T], start: uint, end: uint) -> [T] { assert (start <= end); assert (end <= len(v)); let result = []; @@ -114,7 +114,7 @@ fn slice<@T>(v: &[mutable? T], start: uint, end: uint) -> [T] { } // TODO: Remove me once we have slots. -fn slice_mut<@T>(v: &[mutable? T], start: uint, end: uint) -> [mutable T] { +fn slice_mut<@T>(v: [mutable? T], start: uint, end: uint) -> [mutable T] { assert (start <= end); assert (end <= len(v)); let result = [mutable]; @@ -151,14 +151,14 @@ fn pop<@T>(v: &mutable [mutable? T]) -> T { // Appending /// Expands the given vector in-place by appending `n` copies of `initval`. -fn grow<@T>(v: &mutable [T], n: uint, initval: &T) { +fn grow<@T>(v: &mutable [T], n: uint, initval: T) { reserve(v, next_power_of_two(len(v) + n)); let i: uint = 0u; while i < n { v += [initval]; i += 1u; } } // TODO: Remove me once we have slots. -fn grow_mut<@T>(v: &mutable [mutable T], n: uint, initval: &T) { +fn grow_mut<@T>(v: &mutable [mutable T], n: uint, initval: T) { reserve(v, next_power_of_two(len(v) + n)); let i: uint = 0u; while i < n { v += [mutable initval]; i += 1u; } @@ -175,7 +175,7 @@ fn grow_fn<@T>(v: &mutable [T], n: uint, init_fn: fn(uint) -> T) { /// Sets the element at position `index` to `val`. If `index` is past the end /// of the vector, expands the vector by replicating `initval` to fill the /// intervening space. -fn grow_set<@T>(v: &mutable [mutable T], index: uint, initval: &T, val: &T) { +fn grow_set<@T>(v: &mutable [mutable T], index: uint, initval: T, val: T) { if index >= len(v) { grow_mut(v, index - len(v) + 1u, initval); } v[index] = val; } @@ -183,7 +183,7 @@ fn grow_set<@T>(v: &mutable [mutable T], index: uint, initval: &T, val: &T) { // Functional utilities -fn map<@T, @U>(f: &block(&T) -> U, v: &[mutable? T]) -> [U] { +fn map<@T, @U>(f: block(T) -> U, v: [mutable? T]) -> [U] { let result = []; reserve(result, len(v)); for elem: T in v { @@ -193,7 +193,7 @@ fn map<@T, @U>(f: &block(&T) -> U, v: &[mutable? T]) -> [U] { ret result; } -fn map2<@T, @U, @V>(f: &block(&T, &U) -> V, v0: &[T], v1: &[U]) -> [V] { +fn map2<@T, @U, @V>(f: block(T, U) -> V, v0: [T], v1: [U]) -> [V] { let v0_len = len::(v0); if v0_len != len::(v1) { fail; } let u: [V] = []; @@ -202,8 +202,7 @@ fn map2<@T, @U, @V>(f: &block(&T, &U) -> V, v0: &[T], v1: &[U]) -> [V] { ret u; } -fn filter_map<@T, @U>(f: &block(&T) -> option::t, v: &[mutable? T]) -> - [U] { +fn filter_map<@T, @U>(f: block(T) -> option::t, v: [mutable? T]) -> [U] { let result = []; for elem: T in v { let elem2 = elem; // satisfies alias checker @@ -215,7 +214,7 @@ fn filter_map<@T, @U>(f: &block(&T) -> option::t, v: &[mutable? T]) -> ret result; } -fn foldl<@T, @U>(p: &block(&U, &T) -> U, z: &U, v: &[mutable? T]) -> U { +fn foldl<@T, @U>(p: block(U, T) -> U, z: U, v: [mutable? T]) -> U { let sz = len(v); if sz == 0u { ret z; } let first = v[0]; @@ -223,45 +222,45 @@ fn foldl<@T, @U>(p: &block(&U, &T) -> U, z: &U, v: &[mutable? T]) -> U { ret p(foldl(p, z, rest), first); } -fn any(f: &block(&T) -> bool, v: &[T]) -> bool { +fn any(f: block(T) -> bool, v: [T]) -> bool { for elem: T in v { if f(elem) { ret true; } } ret false; } -fn all(f: &block(&T) -> bool, v: &[T]) -> bool { +fn all(f: block(T) -> bool, v: [T]) -> bool { for elem: T in v { if !f(elem) { ret false; } } ret true; } -fn member(x: &T, v: &[T]) -> bool { +fn member(x: T, v: [T]) -> bool { for elt: T in v { if x == elt { ret true; } } ret false; } -fn count(x: &T, v: &[mutable? T]) -> uint { +fn count(x: T, v: [mutable? T]) -> uint { let cnt = 0u; for elt: T in v { if x == elt { cnt += 1u; } } ret cnt; } -fn find<@T>(f: &block(&T) -> bool, v: &[T]) -> option::t { +fn find<@T>(f: block(T) -> bool, v: [T]) -> option::t { for elt: T in v { if f(elt) { ret some(elt); } } ret none; } -fn position<@T>(x: &T, v: &[T]) -> option::t { +fn position<@T>(x: T, v: [T]) -> option::t { let i: uint = 0u; while i < len(v) { if x == v[i] { ret some::(i); } i += 1u; } ret none; } -fn position_pred(f: fn(&T) -> bool, v: &[T]) -> option::t { +fn position_pred(f: fn(T) -> bool, v: [T]) -> option::t { let i: uint = 0u; while i < len(v) { if f(v[i]) { ret some::(i); } i += 1u; } ret none; } -pure fn same_length(xs: &[T], ys: &[U]) -> bool { +pure fn same_length(xs: [T], ys: [U]) -> bool { let xlen = unchecked{ vec::len(xs) }; let ylen = unchecked{ vec::len(ys) }; xlen == ylen @@ -271,13 +270,13 @@ pure fn same_length(xs: &[T], ys: &[U]) -> bool { // saying the two result lists have the same length -- or, could // return a nominal record with a constraint saying that, instead of // returning a tuple (contingent on issue #869) -fn unzip<@T, @U>(v: &[(T, U)]) -> ([T], [U]) { +fn unzip<@T, @U>(v: [(T, U)]) -> ([T], [U]) { let as = [], bs = []; for (a, b) in v { as += [a]; bs += [b]; } ret (as, bs); } -fn zip<@T, @U>(v: &[T], u: &[U]) : same_length(v, u) -> [(T, U)] { +fn zip<@T, @U>(v: [T], u: [U]) : same_length(v, u) -> [(T, U)] { let zipped = []; let sz = len(v), i = 0u; assert (sz == len(u)); @@ -286,14 +285,14 @@ fn zip<@T, @U>(v: &[T], u: &[U]) : same_length(v, u) -> [(T, U)] { } // Swaps two elements in a vector -fn swap<@T>(v: &[mutable T], a: uint, b: uint) { +fn swap<@T>(v: [mutable T], a: uint, b: uint) { let t: T = v[a]; v[a] = v[b]; v[b] = t; } // In place vector reversal -fn reverse<@T>(v: &[mutable T]) { +fn reverse<@T>(v: [mutable T]) { let i: uint = 0u; let ln = len::(v); while i < ln / 2u { swap(v, i, ln - i - 1u); i += 1u; } @@ -301,7 +300,7 @@ fn reverse<@T>(v: &[mutable T]) { // Functional vector reversal. Returns a reversed copy of v. -fn reversed<@T>(v: &[T]) -> [T] { +fn reversed<@T>(v: [T]) -> [T] { let rs: [T] = []; let i = len::(v); if i == 0u { ret rs; } else { i -= 1u; } @@ -326,7 +325,7 @@ fn enum_uints(start: uint, end: uint) : uint::le(start, end) -> [uint] { } // Iterate over a list with with the indexes -iter iter2<@T>(v: &[T]) -> (uint, T) { +iter iter2<@T>(v: [T]) -> (uint, T) { let i = 0u; for x in v { put (i, x); i += 1u; } } @@ -343,13 +342,13 @@ mod unsafe { (**repr).fill = new_len * sys::size_of::(); } - fn to_ptr(v: &[T]) -> *T { + fn to_ptr(v: [T]) -> *T { let repr: **vec_repr = ::unsafe::reinterpret_cast(addr_of(v)); ret ::unsafe::reinterpret_cast(addr_of((**repr).data)); } } -fn to_ptr(v: &[T]) -> *T { ret unsafe::to_ptr(v); } +fn to_ptr(v: [T]) -> *T { ret unsafe::to_ptr(v); } // Local Variables: // mode: rust; diff --git a/src/lib/win32_fs.rs b/src/lib/win32_fs.rs index 8052d0280fe..06701249150 100644 --- a/src/lib/win32_fs.rs +++ b/src/lib/win32_fs.rs @@ -1,16 +1,16 @@ native "rust" mod rustrt { - fn rust_list_files(path: &str) -> [str]; + fn rust_list_files(path: str) -> [str]; fn rust_file_is_dir(path: str) -> int; } -fn list_dir(path: &str) -> [str] { +fn list_dir(path: str) -> [str] { let path = path + "*"; ret rustrt::rust_list_files(path); } -fn path_is_absolute(p: &str) -> bool { +fn path_is_absolute(p: str) -> bool { ret str::char_at(p, 0u) == '/' || str::char_at(p, 1u) == ':' && str::char_at(p, 2u) == '\\'; } diff --git a/src/lib/win32_os.rs b/src/lib/win32_os.rs index bf94439099f..7cd3f58cdca 100644 --- a/src/lib/win32_os.rs +++ b/src/lib/win32_os.rs @@ -49,7 +49,7 @@ fn exec_suffix() -> str { ret ".exe"; } fn target_os() -> str { ret "win32"; } -fn dylib_filename(base: &str) -> str { ret base + ".dll"; } +fn dylib_filename(base: str) -> str { ret base + ".dll"; } fn pipe() -> {in: int, out: int} { // Windows pipes work subtly differently than unix pipes, and their -- cgit 1.4.1-3-g733a5