diff options
| author | Brian Anderson <banderson@mozilla.com> | 2012-08-01 17:30:05 -0700 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2012-08-01 19:16:06 -0700 |
| commit | b355936b4da0831f47afe8f251daee503c8caa32 (patch) | |
| tree | 9f870e26f773af714cbcf7f315de5ff3722300c3 /src/libstd | |
| parent | dc499f193e473abc78c557feaa86969bbe7aa159 (diff) | |
| download | rust-b355936b4da0831f47afe8f251daee503c8caa32.tar.gz rust-b355936b4da0831f47afe8f251daee503c8caa32.zip | |
Convert ret to return
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/arena.rs | 8 | ||||
| -rw-r--r-- | src/libstd/base64.rs | 4 | ||||
| -rw-r--r-- | src/libstd/bitv.rs | 22 | ||||
| -rw-r--r-- | src/libstd/c_vec.rs | 12 | ||||
| -rw-r--r-- | src/libstd/cmp.rs | 6 | ||||
| -rw-r--r-- | src/libstd/deque.rs | 46 | ||||
| -rw-r--r-- | src/libstd/ebml.rs | 54 | ||||
| -rw-r--r-- | src/libstd/getopts.rs | 60 | ||||
| -rw-r--r-- | src/libstd/json.rs | 52 | ||||
| -rw-r--r-- | src/libstd/list.rs | 24 | ||||
| -rw-r--r-- | src/libstd/map.rs | 42 | ||||
| -rw-r--r-- | src/libstd/md4.rs | 2 | ||||
| -rw-r--r-- | src/libstd/net_ip.rs | 6 | ||||
| -rw-r--r-- | src/libstd/net_tcp.rs | 4 | ||||
| -rw-r--r-- | src/libstd/net_url.rs | 26 | ||||
| -rw-r--r-- | src/libstd/rope.rs | 178 | ||||
| -rw-r--r-- | src/libstd/sha1.rs | 12 | ||||
| -rw-r--r-- | src/libstd/smallintmap.rs | 16 | ||||
| -rw-r--r-- | src/libstd/sort.rs | 24 | ||||
| -rw-r--r-- | src/libstd/tempfile.rs | 4 | ||||
| -rw-r--r-- | src/libstd/term.rs | 8 | ||||
| -rw-r--r-- | src/libstd/test.rs | 20 | ||||
| -rw-r--r-- | src/libstd/time.rs | 12 | ||||
| -rw-r--r-- | src/libstd/treemap.rs | 2 | ||||
| -rw-r--r-- | src/libstd/unicode.rs | 12 | ||||
| -rw-r--r-- | src/libstd/uv_global_loop.rs | 2 | ||||
| -rw-r--r-- | src/libstd/uv_iotask.rs | 2 | ||||
| -rw-r--r-- | src/libstd/uv_ll.rs | 116 |
28 files changed, 393 insertions, 383 deletions
diff --git a/src/libstd/arena.rs b/src/libstd/arena.rs index 2df720e6fe1..b9bc977db31 100644 --- a/src/libstd/arena.rs +++ b/src/libstd/arena.rs @@ -20,7 +20,7 @@ fn chunk(size: uint) -> @chunk { } fn arena_with_size(initial_size: uint) -> arena { - ret arena_({mut chunks: @cons(chunk(initial_size), @nil)}); + return arena_({mut chunks: @cons(chunk(initial_size), @nil)}); } fn arena() -> arena { @@ -36,7 +36,7 @@ impl arena for arena { head = chunk(uint::next_power_of_two(new_min_chunk_size + 1u)); self.chunks = @cons(head, self.chunks); - ret self.alloc_inner(n_bytes, align); + return self.alloc_inner(n_bytes, align); } #[inline(always)] @@ -48,13 +48,13 @@ impl arena for arena { start = (start + alignm1) & !alignm1; let end = start + n_bytes; if end > vec::capacity(head.data) { - ret self.alloc_grow(n_bytes, align); + return self.alloc_grow(n_bytes, align); } unsafe { let p = ptr::offset(vec::unsafe::to_ptr(head.data), start); head.fill = end; - ret unsafe::reinterpret_cast(p); + return unsafe::reinterpret_cast(p); } } diff --git a/src/libstd/base64.rs b/src/libstd/base64.rs index 7a8946d02a6..8ee0253ba40 100644 --- a/src/libstd/base64.rs +++ b/src/libstd/base64.rs @@ -100,11 +100,11 @@ impl of from_base64 for ~[u8] { 1u { vec::push(r, ((n >> 16u) & 0xFFu) as u8); vec::push(r, ((n >> 8u ) & 0xFFu) as u8); - ret copy r; + return copy r; } 2u { vec::push(r, ((n >> 10u) & 0xFFu) as u8); - ret copy r; + return copy r; } _ { fail ~"invalid base64 padding"; diff --git a/src/libstd/bitv.rs b/src/libstd/bitv.rs index a9b3910ec19..f27e6c3e266 100644 --- a/src/libstd/bitv.rs +++ b/src/libstd/bitv.rs @@ -143,7 +143,7 @@ class big_bitv { fn equals(b: &big_bitv) -> bool { let len = b.storage.len(); for uint::iterate(0, len) |i| { - if self.storage[i] != b.storage[i] { ret false; } + if self.storage[i] != b.storage[i] { return false; } } } } @@ -287,7 +287,7 @@ class bitv { */ #[inline(always)] fn equal(v1: bitv) -> bool { - if self.nbits != v1.nbits { ret false; } + if self.nbits != v1.nbits { return false; } alt self.rep { small(b) { alt v1.rep { @@ -300,7 +300,7 @@ class bitv { big(s1) { s.equals(s1) } - small(_) { ret false; } + small(_) { return false; } } } } @@ -354,7 +354,7 @@ class bitv { alt self.rep { small(b) { b.is_true() } _ { - for self.each() |i| { if !i { ret false; } } + for self.each() |i| { if !i { return false; } } true } } @@ -375,14 +375,14 @@ class bitv { alt self.rep { small(b) { b.is_false() } big(_) { - for self.each() |i| { if i { ret false; } } + for self.each() |i| { if i { return false; } } true } } } fn init_to_vec(i: uint) -> uint { - ret if self.get(i) { 1 } else { 0 }; + return if self.get(i) { 1 } else { 0 }; } /** @@ -392,7 +392,7 @@ class bitv { */ fn to_vec() -> ~[uint] { let sub = |x| self.init_to_vec(x); - ret vec::from_fn::<uint>(self.nbits, sub); + return vec::from_fn::<uint>(self.nbits, sub); } /** @@ -420,7 +420,7 @@ class bitv { while i < self.nbits { let w0 = self.get(i); let w1 = v[i]; - if !w0 && w1 != 0u || w0 && w1 == 0u { ret false; } + if !w0 && w1 != 0u || w0 && w1 == 0u { return false; } i = i + 1; } true @@ -438,11 +438,11 @@ class bitv { const uint_bits: uint = 32u + (1u << 32u >> 27u); -pure fn lor(w0: uint, w1: uint) -> uint { ret w0 | w1; } +pure fn lor(w0: uint, w1: uint) -> uint { return w0 | w1; } -pure fn land(w0: uint, w1: uint) -> uint { ret w0 & w1; } +pure fn land(w0: uint, w1: uint) -> uint { return w0 & w1; } -pure fn right(_w0: uint, w1: uint) -> uint { ret w1; } +pure fn right(_w0: uint, w1: uint) -> uint { return w1; } impl extensions of ops::index<uint,bool> for bitv { pure fn index(&&i: uint) -> bool { diff --git a/src/libstd/c_vec.rs b/src/libstd/c_vec.rs index 7f71b999d6f..b80ec82bcf3 100644 --- a/src/libstd/c_vec.rs +++ b/src/libstd/c_vec.rs @@ -66,7 +66,7 @@ class dtor_res { * * len - The number of elements in the buffer */ unsafe fn c_vec<T>(base: *mut T, len: uint) -> c_vec<T> { - ret c_vec_({ + return c_vec_({ base: base, len: len, rsrc: @dtor_res(option::none) @@ -86,7 +86,7 @@ unsafe fn c_vec<T>(base: *mut T, len: uint) -> c_vec<T> { */ unsafe fn c_vec_with_dtor<T>(base: *mut T, len: uint, dtor: fn@()) -> c_vec<T> { - ret c_vec_({ + return c_vec_({ base: base, len: len, rsrc: @dtor_res(option::some(dtor)) @@ -104,7 +104,7 @@ unsafe fn c_vec_with_dtor<T>(base: *mut T, len: uint, dtor: fn@()) */ fn get<T: copy>(t: c_vec<T>, ofs: uint) -> T { assert ofs < len(t); - ret unsafe { *ptr::mut_offset((*t).base, ofs) }; + return unsafe { *ptr::mut_offset((*t).base, ofs) }; } /** @@ -123,12 +123,12 @@ fn set<T: copy>(t: c_vec<T>, ofs: uint, v: T) { /// Returns the length of the vector fn len<T>(t: c_vec<T>) -> uint { - ret (*t).len; + return (*t).len; } /// Returns a pointer to the first element of the vector unsafe fn ptr<T>(t: c_vec<T>) -> *mut T { - ret (*t).base; + return (*t).base; } #[cfg(test)] @@ -140,7 +140,7 @@ mod tests { assert mem as int != 0; - ret unsafe { c_vec_with_dtor(mem as *mut u8, n as uint, + return unsafe { c_vec_with_dtor(mem as *mut u8, n as uint, ||free(mem)) }; } diff --git a/src/libstd/cmp.rs b/src/libstd/cmp.rs index f74cbba23ce..cc2c9dae3d6 100644 --- a/src/libstd/cmp.rs +++ b/src/libstd/cmp.rs @@ -8,19 +8,19 @@ trait fuzzy_eq { impl fuzzy_eq of fuzzy_eq for float { pure fn fuzzy_eq(&&other: float) -> bool { - ret float::abs(self - other) < fuzzy_epsilon; + return float::abs(self - other) < fuzzy_epsilon; } } impl fuzzy_eq of fuzzy_eq for f32 { pure fn fuzzy_eq(&&other: f32) -> bool { - ret f32::abs(self - other) < (fuzzy_epsilon as f32); + return f32::abs(self - other) < (fuzzy_epsilon as f32); } } impl fuzzy_eq of fuzzy_eq for f64 { pure fn fuzzy_eq(&&other: f64) -> bool { - ret f64::abs(self - other) < (fuzzy_epsilon as f64); + return f64::abs(self - other) < (fuzzy_epsilon as f64); } } diff --git a/src/libstd/deque.rs b/src/libstd/deque.rs index 408a8ca20c2..f3feb26ebb6 100644 --- a/src/libstd/deque.rs +++ b/src/libstd/deque.rs @@ -38,7 +38,7 @@ fn create<T: copy>() -> t<T> { i += 1u; } - ret rv; + return rv; } fn get<T: copy>(elts: dvec<cell<T>>, i: uint) -> T { alt elts.get_elt(i) { some(t) { t } _ { fail } } @@ -50,7 +50,7 @@ fn create<T: copy>() -> t<T> { elts: dvec<cell<T>>}; impl <T: copy> of t<T> for repr<T> { - fn size() -> uint { ret self.nelts; } + fn size() -> uint { return self.nelts; } fn add_front(t: T) { let oldlo: uint = self.lo; if self.lo == 0u { @@ -83,7 +83,7 @@ fn create<T: copy>() -> t<T> { self.elts.set_elt(self.lo, none); self.lo = (self.lo + 1u) % self.elts.len(); self.nelts -= 1u; - ret t; + return t; } fn pop_back() -> T { if self.hi == 0u { @@ -92,13 +92,13 @@ fn create<T: copy>() -> t<T> { let t: T = get(self.elts, self.hi); self.elts.set_elt(self.hi, none); self.nelts -= 1u; - ret t; + return t; } - fn peek_front() -> T { ret get(self.elts, self.lo); } - fn peek_back() -> T { ret get(self.elts, self.hi - 1u); } + fn peek_front() -> T { return get(self.elts, self.lo); } + fn peek_back() -> T { return get(self.elts, self.hi - 1u); } fn get(i: int) -> T { let idx = (self.lo + (i as uint)) % self.elts.len(); - ret get(self.elts, idx); + return get(self.elts, idx); } } @@ -235,21 +235,25 @@ mod tests { #[test] fn test() { - fn inteq(&&a: int, &&b: int) -> bool { ret a == b; } - fn intboxeq(&&a: @int, &&b: @int) -> bool { ret a == b; } + fn inteq(&&a: int, &&b: int) -> bool { return a == b; } + fn intboxeq(&&a: @int, &&b: @int) -> bool { return a == b; } fn taggyeq(a: taggy, b: taggy) -> bool { alt a { - one(a1) { alt b { one(b1) { ret a1 == b1; } _ { ret false; } } } + one(a1) { + alt b { one(b1) {return a1 == b1; } _ { return false; } } + } two(a1, a2) { alt b { - two(b1, b2) { ret a1 == b1 && a2 == b2; } - _ { ret false; } + two(b1, b2) { return a1 == b1 && a2 == b2; } + _ { return false; } } } three(a1, a2, a3) { alt b { - three(b1, b2, b3) { ret a1 == b1 && a2 == b2 && a3 == b3; } - _ { ret false; } + three(b1, b2, b3) { + return a1 == b1 && a2 == b2 && a3 == b3; + } + _ { return false; } } } } @@ -257,26 +261,28 @@ mod tests { fn taggypareq<T>(a: taggypar<T>, b: taggypar<T>) -> bool { alt a { onepar::<T>(a1) { - alt b { onepar::<T>(b1) { ret a1 == b1; } _ { ret false; } } + alt b { + onepar::<T>(b1) { return a1 == b1; } _ { return false; } + } } twopar::<T>(a1, a2) { alt b { - twopar::<T>(b1, b2) { ret a1 == b1 && a2 == b2; } - _ { ret false; } + twopar::<T>(b1, b2) { return a1 == b1 && a2 == b2; } + _ { return false; } } } threepar::<T>(a1, a2, a3) { alt b { threepar::<T>(b1, b2, b3) { - ret a1 == b1 && a2 == b2 && a3 == b3; + return a1 == b1 && a2 == b2 && a3 == b3; } - _ { ret false; } + _ { return false; } } } } } fn reccyeq(a: reccy, b: reccy) -> bool { - ret a.x == b.x && a.y == b.y && taggyeq(a.t, b.t); + return a.x == b.x && a.y == b.y && taggyeq(a.t, b.t); } debug!{"*** test boxes"}; test_boxes(@5, @72, @64, @175); diff --git a/src/libstd/ebml.rs b/src/libstd/ebml.rs index d5d1e70bc7b..46ccaa2d096 100644 --- a/src/libstd/ebml.rs +++ b/src/libstd/ebml.rs @@ -63,19 +63,19 @@ impl extensions of ops::index<uint,doc> for doc { fn vuint_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}; + return {val: (a & 0x7fu8) as uint, next: start + 1u}; } if a & 0x40u8 != 0u8 { - ret {val: ((a & 0x3fu8) as uint) << 8u | + return {val: ((a & 0x3fu8) as uint) << 8u | (data[start + 1u] as uint), next: start + 2u}; } else if a & 0x20u8 != 0u8 { - ret {val: ((a & 0x1fu8) as uint) << 16u | + return {val: ((a & 0x1fu8) as uint) << 16u | (data[start + 1u] as uint) << 8u | (data[start + 2u] as uint), next: start + 3u}; } else if a & 0x10u8 != 0u8 { - ret {val: ((a & 0x0fu8) as uint) << 24u | + return {val: ((a & 0x0fu8) as uint) << 24u | (data[start + 1u] as uint) << 16u | (data[start + 2u] as uint) << 8u | (data[start + 3u] as uint), @@ -84,14 +84,14 @@ fn vuint_at(data: &[u8], start: uint) -> {val: uint, next: uint} { } fn doc(data: @~[u8]) -> doc { - ret {data: data, start: 0u, end: vec::len::<u8>(*data)}; + return {data: data, start: 0u, end: vec::len::<u8>(*data)}; } 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; - ret {tag: elt_tag.val, + return {tag: elt_tag.val, doc: {data: data, start: elt_size.next, end: end}}; } @@ -102,15 +102,19 @@ fn maybe_get_doc(d: doc, tg: uint) -> option<doc> { let elt_size = vuint_at(*d.data, elt_tag.next); pos = elt_size.next + elt_size.val; if elt_tag.val == tg { - ret some::<doc>({data: d.data, start: elt_size.next, end: pos}); + return some::<doc>({ + data: d.data, + start: elt_size.next, + end: pos + }); } } - ret none::<doc>; + return none::<doc>; } fn get_doc(d: doc, tg: uint) -> doc { alt maybe_get_doc(d, tg) { - some(d) { ret d; } + some(d) { return d; } none { error!{"failed to find block with tag %u", tg}; fail; @@ -147,29 +151,29 @@ fn tagged_docs(d: doc, tg: uint, it: fn(doc) -> bool) { fn doc_data(d: doc) -> ~[u8] { vec::slice::<u8>(*d.data, d.start, d.end) } fn with_doc_data<T>(d: doc, f: fn(x: &[u8]) -> T) -> T { - ret f(vec::view(*d.data, d.start, d.end)); + return f(vec::view(*d.data, d.start, d.end)); } -fn doc_as_str(d: doc) -> ~str { ret str::from_bytes(doc_data(d)); } +fn doc_as_str(d: doc) -> ~str { return str::from_bytes(doc_data(d)); } fn doc_as_u8(d: doc) -> u8 { assert d.end == d.start + 1u; - ret (*d.data)[d.start]; + return (*d.data)[d.start]; } fn doc_as_u16(d: doc) -> u16 { assert d.end == d.start + 2u; - ret io::u64_from_be_bytes(*d.data, d.start, 2u) as u16; + return io::u64_from_be_bytes(*d.data, d.start, 2u) as u16; } fn doc_as_u32(d: doc) -> u32 { assert d.end == d.start + 4u; - ret io::u64_from_be_bytes(*d.data, d.start, 4u) as u32; + return io::u64_from_be_bytes(*d.data, d.start, 4u) as u32; } fn doc_as_u64(d: doc) -> u64 { assert d.end == d.start + 8u; - ret io::u64_from_be_bytes(*d.data, d.start, 8u); + return io::u64_from_be_bytes(*d.data, d.start, 8u); } fn doc_as_i8(d: doc) -> i8 { doc_as_u8(d) as i8 } @@ -205,16 +209,16 @@ fn write_sized_vuint(w: io::writer, n: uint, size: uint) { } fn write_vuint(w: io::writer, n: uint) { - if n < 0x7f_u { write_sized_vuint(w, n, 1u); ret; } - if n < 0x4000_u { write_sized_vuint(w, n, 2u); ret; } - if n < 0x200000_u { write_sized_vuint(w, n, 3u); ret; } - if n < 0x10000000_u { write_sized_vuint(w, n, 4u); ret; } + if n < 0x7f_u { write_sized_vuint(w, n, 1u); return; } + if n < 0x4000_u { write_sized_vuint(w, n, 2u); return; } + if n < 0x200000_u { write_sized_vuint(w, n, 3u); return; } + if n < 0x10000000_u { write_sized_vuint(w, n, 4u); return; } fail fmt!{"vint to write too big: %?", n}; } fn writer(w: io::writer) -> writer { let size_positions: ~[uint] = ~[]; - ret writer_({writer: w, mut size_positions: size_positions}); + return writer_({writer: w, mut size_positions: size_positions}); } // FIXME (#2741): Provide a function to write the standard ebml header. @@ -462,7 +466,7 @@ impl deserializer_priv for ebml_deserializer { r_doc.end, self.parent.end}; } self.pos = r_doc.end; - ret r_doc; + return r_doc; } fn push_doc<T: copy>(d: ebml::doc, f: fn() -> T) -> T{ @@ -473,13 +477,13 @@ impl deserializer_priv for ebml_deserializer { let r = f(); self.parent = old_parent; self.pos = old_pos; - ret r; + return r; } fn _next_uint(exp_tag: ebml_serializer_tag) -> uint { let r = ebml::doc_as_u32(self.next_doc(exp_tag)); debug!{"_next_uint exp_tag=%? result=%?", exp_tag, r}; - ret r as uint; + return r as uint; } } @@ -495,7 +499,7 @@ impl deserializer of serialization::deserializer for ebml_deserializer { if v > (core::uint::max_value as u64) { fail fmt!{"uint %? too large for this architecture", v}; } - ret v as uint; + return v as uint; } fn read_i64() -> i64 { ebml::doc_as_u64(self.next_doc(es_i64)) as i64 } @@ -507,7 +511,7 @@ impl deserializer of serialization::deserializer for ebml_deserializer { if v > (int::max_value as i64) || v < (int::min_value as i64) { fail fmt!{"int %? out of range for this architecture", v}; } - ret v as int; + return v as int; } fn read_bool() -> bool { ebml::doc_as_u8(self.next_doc(es_bool)) as bool } diff --git a/src/libstd/getopts.rs b/src/libstd/getopts.rs index 86a75e653d8..ed7d4206436 100644 --- a/src/libstd/getopts.rs +++ b/src/libstd/getopts.rs @@ -49,14 +49,14 @@ * }; * if opt_present(matches, "h") || opt_present(matches, "help") { * print_usage(program); - * ret; + * return; * } * let output = opt_maybe_str(matches, "o"); * let input = if vec::is_not_empty(matches.free) { * matches.free[0] * } else { * print_usage(program); - * ret; + * return; * }; * do_work(input, output); * } @@ -94,29 +94,29 @@ enum occur { req, optional, multi, } type opt = {name: name, hasarg: hasarg, occur: occur}; fn mkname(nm: ~str) -> name { - ret if str::len(nm) == 1u { + return if str::len(nm) == 1u { short(str::char_at(nm, 0u)) } else { long(nm) }; } /// Create an option that is required and takes an argument fn reqopt(name: ~str) -> opt { - ret {name: mkname(name), hasarg: yes, occur: req}; + return {name: mkname(name), hasarg: yes, occur: req}; } /// Create an option that is optional and takes an argument fn optopt(name: ~str) -> opt { - ret {name: mkname(name), hasarg: yes, occur: optional}; + return {name: mkname(name), hasarg: yes, occur: optional}; } /// Create an option that is optional and does not take an argument fn optflag(name: ~str) -> opt { - ret {name: mkname(name), hasarg: no, occur: optional}; + return {name: mkname(name), hasarg: no, occur: optional}; } /// Create an option that is optional and takes an optional argument fn optflagopt(name: ~str) -> opt { - ret {name: mkname(name), hasarg: maybe, occur: optional}; + return {name: mkname(name), hasarg: maybe, occur: optional}; } /** @@ -124,7 +124,7 @@ fn optflagopt(name: ~str) -> opt { * multiple times */ fn optmulti(name: ~str) -> opt { - ret {name: mkname(name), hasarg: yes, occur: multi}; + return {name: mkname(name), hasarg: yes, occur: multi}; } enum optval { val(~str), given, } @@ -136,11 +136,11 @@ enum optval { val(~str), given, } type matches = {opts: ~[opt], vals: ~[~[optval]], free: ~[~str]}; fn is_arg(arg: ~str) -> bool { - ret str::len(arg) > 1u && arg[0] == '-' as u8; + return str::len(arg) > 1u && arg[0] == '-' as u8; } fn name_str(nm: name) -> ~str { - ret alt nm { short(ch) { str::from_char(ch) } long(s) { s } }; + return alt nm { short(ch) { str::from_char(ch) } long(s) { s } }; } fn find_opt(opts: ~[opt], nm: name) -> option<uint> { @@ -161,7 +161,7 @@ enum fail_ { /// Convert a `fail_` enum into an error string fn fail_str(f: fail_) -> ~str { - ret alt f { + return alt f { argument_missing(nm) { ~"Argument to option '" + nm + ~"' missing." } @@ -191,7 +191,7 @@ type result = result::result<matches, fail_>; */ 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] { return ~[]; } let vals = vec::to_mut(vec::from_fn(n_opts, f)); let mut free: ~[~str] = ~[]; let l = vec::len(args); @@ -262,12 +262,12 @@ fn getopts(args: ~[~str], opts: ~[opt]) -> result unsafe { name_pos += 1u; let optid = alt find_opt(opts, nm) { some(id) { id } - none { ret err(unrecognized_option(name_str(nm))); } + none { return err(unrecognized_option(name_str(nm))); } }; alt opts[optid].hasarg { no { if !option::is_none::<~str>(i_arg) { - ret err(unexpected_argument(name_str(nm))); + return err(unexpected_argument(name_str(nm))); } vec::push(vals[optid], given); } @@ -284,7 +284,7 @@ fn getopts(args: ~[~str], opts: ~[opt]) -> result unsafe { vec::push(vals[optid], val(option::get::<~str>(i_arg))); } else if i + 1u == l { - ret err(argument_missing(name_str(nm))); + return err(argument_missing(name_str(nm))); } else { i += 1u; vec::push(vals[optid], val(args[i])); } } } @@ -298,42 +298,42 @@ fn getopts(args: ~[~str], opts: ~[opt]) -> result unsafe { let occ = opts[i].occur; if occ == req { if n == 0u { - ret err(option_missing(name_str(opts[i].name))); + return err(option_missing(name_str(opts[i].name))); } } if occ != multi { if n > 1u { - ret err(option_duplicated(name_str(opts[i].name))); + return err(option_duplicated(name_str(opts[i].name))); } } i += 1u; } - ret ok({opts: opts, vals: vec::from_mut(vals), free: free}); + return ok({opts: opts, vals: vec::from_mut(vals), free: free}); } fn opt_vals(m: matches, nm: ~str) -> ~[optval] { - ret alt find_opt(m.opts, mkname(nm)) { + return alt find_opt(m.opts, mkname(nm)) { some(id) { m.vals[id] } none { error!{"No option '%s' defined", nm}; fail } }; } -fn opt_val(m: matches, nm: ~str) -> optval { ret opt_vals(m, nm)[0]; } +fn opt_val(m: matches, nm: ~str) -> optval { return opt_vals(m, nm)[0]; } /// Returns true if an option was matched fn opt_present(m: matches, nm: ~str) -> bool { - ret vec::len::<optval>(opt_vals(m, nm)) > 0u; + return vec::len::<optval>(opt_vals(m, nm)) > 0u; } /// Returns true if any of several options were matched fn opts_present(m: matches, names: ~[~str]) -> bool { for vec::each(names) |nm| { alt find_opt(m.opts, mkname(nm)) { - some(_) { ret true; } + some(_) { return true; } _ { } } } - ret false; + return false; } @@ -344,7 +344,7 @@ fn opts_present(m: matches, names: ~[~str]) -> bool { * argument */ fn opt_str(m: matches, nm: ~str) -> ~str { - ret alt opt_val(m, nm) { val(s) { s } _ { fail } }; + return alt opt_val(m, nm) { val(s) { s } _ { fail } }; } /** @@ -356,7 +356,7 @@ fn opt_str(m: matches, nm: ~str) -> ~str { fn opts_str(m: matches, names: ~[~str]) -> ~str { for vec::each(names) |nm| { alt opt_val(m, nm) { - val(s) { ret s } + val(s) { return s } _ { } } } @@ -375,14 +375,14 @@ fn opt_strs(m: matches, nm: ~str) -> ~[~str] { for vec::each(opt_vals(m, nm)) |v| { alt v { val(s) { vec::push(acc, s); } _ { } } } - ret acc; + return acc; } /// Returns the string argument supplied to a matching option or none fn opt_maybe_str(m: matches, nm: ~str) -> option<~str> { let vals = opt_vals(m, nm); - if vec::len::<optval>(vals) == 0u { ret none::<~str>; } - ret alt vals[0] { val(s) { some::<~str>(s) } _ { none::<~str> } }; + if vec::len::<optval>(vals) == 0u { return none::<~str>; } + return alt vals[0] { val(s) { some::<~str>(s) } _ { none::<~str> } }; } @@ -395,8 +395,8 @@ fn opt_maybe_str(m: matches, nm: ~str) -> option<~str> { */ fn opt_default(m: matches, nm: ~str, def: ~str) -> option<~str> { let vals = opt_vals(m, nm); - if vec::len::<optval>(vals) == 0u { ret none::<~str>; } - ret alt vals[0] { val(s) { some::<~str>(s) } _ { some::<~str>(def) } } + if vec::len::<optval>(vals) == 0u { return none::<~str>; } + return alt vals[0] { val(s) { some::<~str>(s) } _ { some::<~str>(def) } } } #[cfg(test)] diff --git a/src/libstd/json.rs b/src/libstd/json.rs index 6a08bb5d9e1..f2c2a616ede 100644 --- a/src/libstd/json.rs +++ b/src/libstd/json.rs @@ -68,7 +68,7 @@ fn to_writer(wr: io::writer, j: json) { dict(d) { if d.size() == 0u { wr.write_str(~"{}"); - ret; + return; } wr.write_str(~"{ "); @@ -168,7 +168,7 @@ impl parser for parser { fn parse_value() -> result<json, error> { self.parse_whitespace(); - if self.eof() { ret self.error(~"EOF while parsing value"); } + if self.eof() { return self.error(~"EOF while parsing value"); } alt self.ch { 'n' { self.parse_ident(~"ull", null) } @@ -210,20 +210,20 @@ impl parser for parser { let mut res = alt self.parse_integer() { ok(res) { res } - err(e) { ret err(e); } + err(e) { return err(e); } }; if self.ch == '.' { alt self.parse_decimal(res) { ok(r) { res = r; } - err(e) { ret err(e); } + err(e) { return err(e); } } } if self.ch == 'e' || self.ch == 'E' { alt self.parse_exponent(res) { ok(r) { res = r; } - err(e) { ret err(e); } + err(e) { return err(e); } } } @@ -239,7 +239,7 @@ impl parser for parser { // There can be only one leading '0'. alt self.ch { - '0' to '9' { ret self.error(~"invalid number"); } + '0' to '9' { return self.error(~"invalid number"); } _ {} } } @@ -256,7 +256,7 @@ impl parser for parser { } } } - _ { ret self.error(~"invalid number"); } + _ { return self.error(~"invalid number"); } } ok(res) @@ -268,7 +268,7 @@ impl parser for parser { // Make sure a digit follows the decimal place. alt self.ch { '0' to '9' {} - _ { ret self.error(~"invalid number"); } + _ { return self.error(~"invalid number"); } } let mut res = res; @@ -304,7 +304,7 @@ impl parser for parser { // Make sure a digit follows the exponent place. alt self.ch { '0' to '9' {} - _ { ret self.error(~"invalid number"); } + _ { return self.error(~"invalid number"); } } while !self.eof() { @@ -356,19 +356,19 @@ impl parser for parser { n = n * 10u + (self.ch as uint) - ('0' as uint); } - _ { ret self.error(~"invalid \\u escape"); } + _ { return self.error(~"invalid \\u escape"); } } i += 1u; } // Error out if we didn't parse 4 digits. if i != 4u { - ret self.error(~"invalid \\u escape"); + return self.error(~"invalid \\u escape"); } str::push_char(res, n as char); } - _ { ret self.error(~"invalid escape"); } + _ { return self.error(~"invalid escape"); } } escape = false; } else if self.ch == '\\' { @@ -376,7 +376,7 @@ impl parser for parser { } else { if self.ch == '"' { self.bump(); - ret ok(@res); + return ok(@res); } str::push_char(res, self.ch); } @@ -393,24 +393,24 @@ impl parser for parser { if self.ch == ']' { self.bump(); - ret ok(list(@values)); + return ok(list(@values)); } loop { alt self.parse_value() { ok(v) { vec::push(values, v); } - e { ret e; } + e { return e; } } self.parse_whitespace(); if self.eof() { - ret self.error(~"EOF while parsing list"); + return self.error(~"EOF while parsing list"); } alt self.ch { ',' { self.bump(); } - ']' { self.bump(); ret ok(list(@values)); } - _ { ret self.error(~"expected `,` or `]`"); } + ']' { self.bump(); return ok(list(@values)); } + _ { return self.error(~"expected `,` or `]`"); } } }; } @@ -423,46 +423,46 @@ impl parser for parser { if self.ch == '}' { self.bump(); - ret ok(dict(values)); + return ok(dict(values)); } while !self.eof() { self.parse_whitespace(); if self.ch != '"' { - ret self.error(~"key must be a string"); + return self.error(~"key must be a string"); } let key = alt self.parse_str() { ok(key) { key } - err(e) { ret err(e); } + err(e) { return err(e); } }; self.parse_whitespace(); if self.ch != ':' { if self.eof() { break; } - ret self.error(~"expected `:`"); + return self.error(~"expected `:`"); } self.bump(); alt self.parse_value() { ok(value) { values.insert(copy *key, value); } - e { ret e; } + e { return e; } } self.parse_whitespace(); alt self.ch { ',' { self.bump(); } - '}' { self.bump(); ret ok(dict(values)); } + '}' { self.bump(); return ok(dict(values)); } _ { if self.eof() { break; } - ret self.error(~"expected `,` or `}`"); + return self.error(~"expected `,` or `}`"); } } } - ret self.error(~"EOF while parsing object"); + return self.error(~"EOF while parsing object"); } } diff --git a/src/libstd/list.rs b/src/libstd/list.rs index b8da3dcc38f..019c9cce632 100644 --- a/src/libstd/list.rs +++ b/src/libstd/list.rs @@ -45,10 +45,10 @@ fn find<T: copy>(ls: @list<T>, f: fn(T) -> bool) -> option<T> { loop { ls = alt *ls { cons(hd, tl) { - if f(hd) { ret some(hd); } + if f(hd) { return some(hd); } tl } - nil { ret none; } + nil { return none; } } }; } @@ -56,9 +56,9 @@ fn find<T: copy>(ls: @list<T>, f: fn(T) -> bool) -> option<T> { /// Returns true if a list contains an element with the given value fn has<T: copy>(ls: @list<T>, elt: T) -> bool { for each(ls) |e| { - if e == elt { ret true; } + if e == elt { return true; } } - ret false; + return false; } /// Returns true if the list is empty @@ -71,7 +71,7 @@ pure fn is_empty<T: copy>(ls: @list<T>) -> bool { /// Returns true if the list is not empty pure fn is_not_empty<T: copy>(ls: @list<T>) -> bool { - ret !is_empty(ls); + return !is_empty(ls); } /// Returns the length of a list @@ -84,7 +84,7 @@ fn len<T>(ls: @list<T>) -> uint { /// Returns all but the first element of a list pure fn tail<T: copy>(ls: @list<T>) -> @list<T> { alt *ls { - cons(_, tl) { ret tl; } + cons(_, tl) { return tl; } nil { fail ~"list empty" } } } @@ -97,8 +97,8 @@ pure fn head<T: copy>(ls: @list<T>) -> T { /// Appends one list to another pure fn append<T: copy>(l: @list<T>, m: @list<T>) -> @list<T> { alt *l { - nil { ret m; } - cons(x, xs) { let rest = append(xs, m); ret @cons(x, rest); } + nil { return m; } + cons(x, xs) { let rest = append(xs, m); return @cons(x, rest); } } } @@ -127,7 +127,7 @@ fn each<T>(l: @list<T>, f: fn(T) -> bool) { loop { cur = alt *cur { cons(hd, tl) { - if !f(hd) { ret; } + if !f(hd) { return; } tl } nil { break; } @@ -174,7 +174,7 @@ mod tests { #[test] fn test_foldl() { - fn add(&&a: uint, &&b: int) -> uint { ret a + (b as uint); } + fn add(&&a: uint, &&b: int) -> uint { return a + (b as uint); } let l = from_vec(~[0, 1, 2, 3, 4]); let empty = @list::nil::<int>; assert (list::foldl(0u, l, add) == 10u); @@ -192,14 +192,14 @@ mod tests { #[test] fn test_find_success() { - fn match_(&&i: int) -> bool { ret i == 2; } + fn match_(&&i: int) -> bool { return i == 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; } + fn match_(&&_i: int) -> bool { return false; } let l = from_vec(~[0, 1, 2]); let empty = @list::nil::<int>; assert (list::find(l, match_) == option::none::<int>); diff --git a/src/libstd/map.rs b/src/libstd/map.rs index 846a2bfc700..eb5c8cc95ab 100644 --- a/src/libstd/map.rs +++ b/src/libstd/map.rs @@ -124,7 +124,7 @@ mod chained { absent { debug!{"search_tbl: absent, comp %u, hash %u, idx %u", comp, h, idx}; - ret not_found; + return not_found; } present(e1) { comp += 1u; @@ -132,7 +132,7 @@ mod chained { debug!{"search_tbl: present, comp %u, \ hash %u, idx %u", comp, h, idx}; - ret found_after(e0, e1); + return found_after(e0, e1); } else { e0 = e1; } @@ -147,15 +147,15 @@ mod chained { absent { debug!{"search_tbl: absent, comp %u, hash %u, idx %u", 0u, h, idx}; - ret not_found; + return not_found; } present(e) { if e.hash == h && self.eqer(e.key, k) { debug!{"search_tbl: present, comp %u, hash %u, idx %u", 1u, h, idx}; - ret found_first(idx, e); + return found_first(idx, e); } else { - ret self.search_rem(k, h, idx, e); + return self.search_rem(k, h, idx, e); } } } @@ -182,7 +182,7 @@ mod chained { absent { break; } present(entry) { let next = entry.next; - if !blk(entry) { ret; } + if !blk(entry) { return; } next } } @@ -224,15 +224,15 @@ mod chained { self.rehash(); } - ret true; + return true; } found_first(_, entry) { entry.value = v; - ret false; + return false; } found_after(_, entry) { entry.value = v; - ret false + return false } } } @@ -292,7 +292,7 @@ mod chained { fn to_writer(wr: io::writer) { if self.count == 0u { wr.write_str("{}"); - ret; + return; } wr.write_str("{ "); @@ -324,7 +324,7 @@ mod chained { fn chains<K,V>(nchains: uint) -> ~[mut chain<K,V>] { - ret vec::to_mut(vec::from_elem(nchains, absent)); + return vec::to_mut(vec::from_elem(nchains, absent)); } fn mk<K, V: copy>(hasher: hashfn<K>, eqer: eqfn<K>) -> t<K,V> { @@ -353,32 +353,32 @@ fn hashmap<K: const, V: copy>(hasher: hashfn<K>, eqer: eqfn<K>) /// Construct a hashmap for string keys fn str_hash<V: copy>() -> hashmap<~str, V> { - ret hashmap(str::hash, str::eq); + return hashmap(str::hash, str::eq); } /// Construct a hashmap for boxed string keys fn box_str_hash<V: copy>() -> hashmap<@~str, V> { - ret hashmap(|x: @~str| str::hash(*x), |x,y| str::eq(*x,*y)); + return hashmap(|x: @~str| str::hash(*x), |x,y| str::eq(*x,*y)); } /// Construct a hashmap for byte string keys fn bytes_hash<V: copy>() -> hashmap<~[u8], V> { - ret hashmap(vec::u8::hash, vec::u8::eq); + return hashmap(vec::u8::hash, vec::u8::eq); } /// Construct a hashmap for int keys fn int_hash<V: copy>() -> hashmap<int, V> { - ret hashmap(int::hash, int::eq); + return hashmap(int::hash, int::eq); } /// Construct a hashmap for uint keys fn uint_hash<V: copy>() -> hashmap<uint, V> { - ret hashmap(uint::hash, uint::eq); + return hashmap(uint::hash, uint::eq); } /// Convenience function for adding keys to a hashmap with nil type keys fn set_add<K: const copy>(set: set<K>, key: K) -> bool { - ret set.insert(key, ()); + return set.insert(key, ()); } /// Convert a set into a vector. @@ -428,7 +428,7 @@ mod tests { #[test] fn test_simple() { debug!{"*** starting test_simple"}; - fn eq_uint(&&x: uint, &&y: uint) -> bool { ret x == y; } + fn eq_uint(&&x: uint, &&y: uint) -> bool { return x == y; } fn uint_id(&&x: uint) -> uint { x } let hasher_uint: map::hashfn<uint> = uint_id; let eqer_uint: map::eqfn<uint> = eq_uint; @@ -501,7 +501,7 @@ mod tests { fn test_growth() { debug!{"*** starting test_growth"}; let num_to_insert: uint = 64u; - fn eq_uint(&&x: uint, &&y: uint) -> bool { ret x == y; } + fn eq_uint(&&x: uint, &&y: uint) -> bool { return x == y; } fn uint_id(&&x: uint) -> uint { x } debug!{"uint -> uint"}; let hasher_uint: map::hashfn<uint> = uint_id; @@ -574,12 +574,12 @@ mod tests { fn test_removal() { debug!{"*** starting test_removal"}; let num_to_insert: uint = 64u; - fn eq(&&x: uint, &&y: uint) -> bool { ret x == y; } + fn eq(&&x: uint, &&y: uint) -> bool { return x == y; } fn hash(&&u: uint) -> uint { // This hash function intentionally causes collisions between // consecutive integer pairs. - ret u / 2u * 2u; + return u / 2u * 2u; } assert (hash(0u) == hash(1u)); assert (hash(2u) == hash(3u)); diff --git a/src/libstd/md4.rs b/src/libstd/md4.rs index 134091dfd1d..2c22d18440a 100644 --- a/src/libstd/md4.rs +++ b/src/libstd/md4.rs @@ -79,7 +79,7 @@ fn md4(msg: ~[u8]) -> {a: u32, b: u32, c: u32, d: u32} { a += aa; b += bb; c += cc; d += dd; i += 64u; } - ret {a: a, b: b, c: c, d: d}; + return {a: a, b: b, c: c, d: d}; } fn md4_str(msg: ~[u8]) -> ~str { diff --git a/src/libstd/net_ip.rs b/src/libstd/net_ip.rs index 38b6d6194eb..cb77f72038a 100644 --- a/src/libstd/net_ip.rs +++ b/src/libstd/net_ip.rs @@ -183,7 +183,7 @@ mod v4 { let ip_rep_result = parse_to_ipv4_rep(ip); if result::is_err(ip_rep_result) { let err_str = result::get_err(ip_rep_result); - ret result::err({err_msg: err_str}) + return result::err({err_msg: err_str}) } // ipv4_rep.as_u32 is unsafe :/ let input_is_inaddr_none = @@ -196,11 +196,11 @@ mod v4 { let ref_ip_rep_result = parse_to_ipv4_rep(reformatted_name); if result::is_err(ref_ip_rep_result) { let err_str = result::get_err(ref_ip_rep_result); - ret result::err({err_msg: err_str}) + return result::err({err_msg: err_str}) } if result::get(ref_ip_rep_result).as_u32() == INADDR_NONE && !input_is_inaddr_none { - ret result::err( + return result::err( {err_msg: ~"uv_ip4_name produced invalid result."}) } else { diff --git a/src/libstd/net_tcp.rs b/src/libstd/net_tcp.rs index 8bf35c8ee16..2cacd9de475 100644 --- a/src/libstd/net_tcp.rs +++ b/src/libstd/net_tcp.rs @@ -779,7 +779,7 @@ impl tcp_socket_buf of io::reader for @tcp_socket_buf { debug!{"ERROR sock_buf as io::reader.read err %? %?", err_data.err_name, err_data.err_msg}; - ret 0; + return 0; } } else { @@ -1581,7 +1581,7 @@ mod test { } } let ret_val = server_ch.recv(); - log(debug, fmt!{"SERVER: exited and got ret val: '%s'", ret_val}); + log(debug, fmt!{"SERVER: exited and got return val: '%s'", ret_val}); ret_val } diff --git a/src/libstd/net_url.rs b/src/libstd/net_url.rs index 928f8bc9399..5f77e7d414f 100644 --- a/src/libstd/net_url.rs +++ b/src/libstd/net_url.rs @@ -31,9 +31,9 @@ fn userinfo(-user: ~str, -pass: option<~str>) -> userinfo { fn split_char_first(s: ~str, c: char) -> (~str, ~str) { let mut v = str::splitn_char(s, c, 1); if v.len() == 1 { - ret (s, ~""); + return (s, ~""); } else { - ret (vec::shift(v), vec::pop(v)); + return (vec::shift(v), vec::pop(v)); } } @@ -44,16 +44,16 @@ fn userinfo_from_str(uinfo: ~str) -> userinfo { } else { option::some(p) }; - ret userinfo(user, pass); + return userinfo(user, pass); } fn userinfo_to_str(-userinfo: userinfo) -> ~str { if option::is_some(userinfo.pass) { - ret str::concat(~[copy userinfo.user, ~":", + return str::concat(~[copy userinfo.user, ~":", option::unwrap(copy userinfo.pass), ~"@"]); } else { - ret str::concat(~[copy userinfo.user, ~"@"]); + return str::concat(~[copy userinfo.user, ~"@"]); } } @@ -65,7 +65,7 @@ fn query_from_str(rawquery: ~str) -> query { vec::push(query, (k, v)); }; } - ret query; + return query; } fn query_to_str(query: query) -> ~str { @@ -74,7 +74,7 @@ fn query_to_str(query: query) -> ~str { let (k, v) = kv; strvec += ~[fmt!{"%s=%s", k, v}]; }; - ret str::connect(strvec, ~"&"); + return str::connect(strvec, ~"&"); } fn get_scheme(rawurl: ~str) -> option::option<(~str, ~str)> { @@ -82,13 +82,13 @@ fn get_scheme(rawurl: ~str) -> option::option<(~str, ~str)> { if char::is_alphabetic(c) { again; } else if c == ':' && i != 0 { - ret option::some((rawurl.slice(0,i), + return option::some((rawurl.slice(0,i), rawurl.slice(i+3,str::len(rawurl)))); } else { - ret option::none; + return option::none; } }; - ret option::none; + return option::none; } /** @@ -107,7 +107,7 @@ fn get_scheme(rawurl: ~str) -> option::option<(~str, ~str)> { fn from_str(rawurl: ~str) -> result::result<url, ~str> { let mut schm = get_scheme(rawurl); if option::is_none(schm) { - ret result::err(~"invalid scheme"); + return result::err(~"invalid scheme"); } let (scheme, rest) = option::unwrap(schm); let (u, rest) = split_char_first(rest, '@'); @@ -135,7 +135,7 @@ fn from_str(rawurl: ~str) -> result::result<url, ~str> { str::unshift_char(path, '/'); } - ret result::ok(url(scheme, user, host, path, query, fragment)); + return result::ok(url(scheme, user, host, path, query, fragment)); } /** @@ -170,7 +170,7 @@ fn to_str(url: url) -> ~str { ~"" }; - ret str::concat(~[copy url.scheme, + return str::concat(~[copy url.scheme, ~"://", user, copy url.host, diff --git a/src/libstd/rope.rs b/src/libstd/rope.rs index e9568a13df0..8debc45a0e9 100644 --- a/src/libstd/rope.rs +++ b/src/libstd/rope.rs @@ -33,7 +33,7 @@ type rope = node::root; /// Create an empty rope fn empty() -> rope { - ret node::empty; + return node::empty; } /** @@ -54,7 +54,7 @@ fn empty() -> rope { * * the function runs in linear time. */ fn of_str(str: @~str) -> rope { - ret of_substr(str, 0u, str::len(*str)); + return of_substr(str, 0u, str::len(*str)); } /** @@ -80,9 +80,9 @@ fn of_str(str: @~str) -> rope { * * this function fails if `byte_offset` or `byte_len` do not match `str`. */ fn of_substr(str: @~str, byte_offset: uint, byte_len: uint) -> rope { - if byte_len == 0u { ret node::empty; } + if byte_len == 0u { return node::empty; } if byte_offset + byte_len > str::len(*str) { fail; } - ret node::content(node::of_substr(str, byte_offset, byte_len)); + return node::content(node::of_substr(str, byte_offset, byte_len)); } /* @@ -97,7 +97,7 @@ Section: Adding things to a rope * * this function executes in near-constant time */ fn append_char(rope: rope, char: char) -> rope { - ret append_str(rope, @str::from_chars(~[char])); + return append_str(rope, @str::from_chars(~[char])); } /** @@ -108,7 +108,7 @@ fn append_char(rope: rope, char: char) -> rope { * * this function executes in near-linear time */ fn append_str(rope: rope, str: @~str) -> rope { - ret append_rope(rope, of_str(str)) + return append_rope(rope, of_str(str)) } /** @@ -118,7 +118,7 @@ fn append_str(rope: rope, str: @~str) -> rope { * * this function executes in near-constant time */ fn prepend_char(rope: rope, char: char) -> rope { - ret prepend_str(rope, @str::from_chars(~[char])); + return prepend_str(rope, @str::from_chars(~[char])); } /** @@ -128,18 +128,18 @@ fn prepend_char(rope: rope, char: char) -> rope { * * this function executes in near-linear time */ fn prepend_str(rope: rope, str: @~str) -> rope { - ret append_rope(of_str(str), rope) + return append_rope(of_str(str), rope) } /// Concatenate two ropes fn append_rope(left: rope, right: rope) -> rope { alt(left) { - node::empty { ret right; } + node::empty { return right; } node::content(left_content) { alt(right) { - node::empty { ret left; } + node::empty { return left; } node::content(right_content) { - ret node::content(node::concat2(left_content, right_content)); + return node::content(node::concat2(left_content, right_content)); } } } @@ -156,7 +156,7 @@ fn append_rope(left: rope, right: 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; } + if len == 0u { return node::empty; } let ropes = vec::to_mut(vec::from_elem(len, v[0])); for uint::range(1u, len) |i| { ropes[i] = v[i]; @@ -176,7 +176,7 @@ fn concat(v: ~[rope]) -> rope { } //Return final rope - ret ropes[0]; + return ropes[0]; } @@ -198,7 +198,7 @@ Section: Keeping ropes healthy */ fn bal(rope:rope) -> rope { alt(rope) { - node::empty { ret rope } + node::empty { return rope } node::content(x) { alt(node::bal(x)) { option::none { rope } @@ -227,13 +227,13 @@ Section: Transforming ropes * valid positions in rope */ fn sub_chars(rope: rope, char_offset: uint, char_len: uint) -> rope { - if char_len == 0u { ret node::empty; } + if char_len == 0u { return node::empty; } alt(rope) { node::empty { fail } node::content(node) { if char_len > node::char_len(node) { fail } else { - ret node::content(node::sub_chars(node, char_offset, char_len)) + return node::content(node::sub_chars(node, char_offset, char_len)) } } } @@ -253,13 +253,13 @@ fn sub_chars(rope: rope, char_offset: uint, char_len: uint) -> rope { * valid positions in rope */ fn sub_bytes(rope: rope, byte_offset: uint, byte_len: uint) -> rope { - if byte_len == 0u { ret node::empty; } + if byte_len == 0u { return node::empty; } alt(rope) { node::empty { fail } node::content(node) { if byte_len > node::byte_len(node) { fail } else { - ret node::content(node::sub_bytes(node, byte_offset, byte_len)) + return node::content(node::sub_bytes(node, byte_offset, byte_len)) } } } @@ -281,11 +281,11 @@ Section: Comparing ropes */ fn cmp(left: rope, right: rope) -> int { alt((left, right)) { - (node::empty, node::empty) { ret 0; } - (node::empty, _) { ret -1;} - (_, node::empty) { ret 1;} + (node::empty, node::empty) { return 0; } + (node::empty, _) { return -1;} + (_, node::empty) { return 1;} (node::content(a), node::content(b)) { - ret node::cmp(a, b); + return node::cmp(a, b); } } } @@ -295,7 +295,7 @@ fn cmp(left: rope, right: rope) -> int { * their structure), `false` otherwise */ fn eq(left: rope, right: rope) -> bool { - ret cmp(left, right) == 0; + return cmp(left, right) == 0; } /** @@ -310,7 +310,7 @@ fn eq(left: rope, right: rope) -> bool { * structure), `false` otherwise */ fn le(left: rope, right: rope) -> bool { - ret cmp(left, right) <= 0; + return cmp(left, right) <= 0; } /** @@ -325,7 +325,7 @@ fn le(left: rope, right: rope) -> bool { * structure), `false` otherwise */ fn lt(left: rope, right: rope) -> bool { - ret cmp(left, right) < 0; + return cmp(left, right) < 0; } /** @@ -340,7 +340,7 @@ fn lt(left: rope, right: rope) -> bool { * structure), `false` otherwise */ fn ge(left: rope, right: rope) -> bool { - ret cmp(left, right) >= 0; + return cmp(left, right) >= 0; } /** @@ -355,7 +355,7 @@ fn ge(left: rope, right: rope) -> bool { * structure), `false` otherwise */ fn gt(left: rope, right: rope) -> bool { - ret cmp(left, right) > 0; + return cmp(left, right) > 0; } /* @@ -384,8 +384,8 @@ Section: Iterating */ fn loop_chars(rope: rope, it: fn(char) -> bool) -> bool { alt(rope) { - node::empty { ret true } - node::content(x) { ret node::loop_chars(x, it) } + node::empty { return true } + node::content(x) { return node::loop_chars(x, it) } } } @@ -427,8 +427,8 @@ fn iter_chars(rope: rope, it: fn(char)) { */ fn loop_leaves(rope: rope, it: fn(node::leaf) -> bool) -> bool{ alt(rope) { - node::empty { ret true } - node::content(x) {ret node::loop_leaves(x, it)} + node::empty { return true } + node::content(x) {return node::loop_leaves(x, it)} } } @@ -436,23 +436,23 @@ mod iterator { mod leaf { fn start(rope: rope) -> node::leaf_iterator::t { alt(rope) { - node::empty { ret node::leaf_iterator::empty() } - node::content(x) { ret node::leaf_iterator::start(x) } + node::empty { return node::leaf_iterator::empty() } + node::content(x) { return node::leaf_iterator::start(x) } } } fn next(it: node::leaf_iterator::t) -> option<node::leaf> { - ret node::leaf_iterator::next(it); + return node::leaf_iterator::next(it); } } mod char { fn start(rope: rope) -> node::char_iterator::t { alt(rope) { - node::empty { ret node::char_iterator::empty() } - node::content(x) { ret node::char_iterator::start(x) } + node::empty { return node::char_iterator::empty() } + node::content(x) { return node::char_iterator::start(x) } } } fn next(it: node::char_iterator::t) -> option<char> { - ret node::char_iterator::next(it) + return node::char_iterator::next(it) } } } @@ -474,8 +474,8 @@ mod iterator { */ fn height(rope: rope) -> uint { alt(rope) { - node::empty { ret 0u; } - node::content(x) { ret node::height(x); } + node::empty { return 0u; } + node::content(x) { return node::height(x); } } } @@ -490,8 +490,8 @@ fn height(rope: rope) -> uint { */ pure fn char_len(rope: rope) -> uint { alt(rope) { - node::empty { ret 0u; } - node::content(x) { ret node::char_len(x) } + node::empty { return 0u; } + node::content(x) { return node::char_len(x) } } } @@ -504,8 +504,8 @@ pure fn char_len(rope: rope) -> uint { */ pure fn byte_len(rope: rope) -> uint { alt(rope) { - node::empty { ret 0u; } - node::content(x) { ret node::byte_len(x) } + node::empty { return 0u; } + node::content(x) { return node::byte_len(x) } } } @@ -528,7 +528,7 @@ pure fn byte_len(rope: rope) -> uint { fn char_at(rope: rope, pos: uint) -> char { alt(rope) { node::empty { fail } - node::content(x) { ret node::char_at(x, pos) } + node::content(x) { return node::char_at(x, pos) } } } @@ -628,7 +628,7 @@ mod node { * the length of `str`. */ fn of_str(str: @~str) -> @node { - ret of_substr(str, 0u, str::len(*str)); + return of_substr(str, 0u, str::len(*str)); } /** @@ -649,7 +649,7 @@ mod node { * valid positions in `str` */ fn of_substr(str: @~str, byte_start: uint, byte_len: uint) -> @node { - ret of_substr_unsafer(str, byte_start, byte_len, + return of_substr_unsafer(str, byte_start, byte_len, str::count_chars(*str, byte_start, byte_len)); } @@ -683,7 +683,7 @@ mod node { char_len: char_len, content: str}); if char_len <= hint_max_leaf_char_len { - ret candidate; + return candidate; } else { //Firstly, split `str` in slices of hint_max_leaf_char_len let mut leaves = uint::div_ceil(char_len, hint_max_leaf_char_len); @@ -728,22 +728,22 @@ mod node { } leaves = uint::div_ceil(leaves, 2u); } - ret nodes[0u]; + return nodes[0u]; } } pure fn byte_len(node: @node) -> uint { //FIXME (#2744): Could we do this without the pattern-matching? alt(*node) { - leaf(y) { ret y.byte_len; } - concat(y){ ret y.byte_len; } + leaf(y) { return y.byte_len; } + concat(y){ return y.byte_len; } } } pure fn char_len(node: @node) -> uint { alt(*node) { - leaf(y) { ret y.char_len; } - concat(y) { ret y.char_len; } + leaf(y) { return y.char_len; } + concat(y) { return y.char_len; } } } @@ -796,7 +796,7 @@ mod node { } len = uint::div_ceil(len, 2u); } - ret forest[0]; + return forest[0]; } fn serialize_node(node: @node) -> ~str unsafe { @@ -820,7 +820,7 @@ mod node { } } } - ret unsafe::transmute(buf); + return unsafe::transmute(buf); } /** @@ -832,9 +832,9 @@ mod node { */ fn flatten(node: @node) -> @node unsafe { alt(*node) { - leaf(_) { ret node } + leaf(_) { return node } concat(x) { - ret @leaf({ + return @leaf({ byte_offset: 0u, byte_len: x.byte_len, char_len: x.char_len, @@ -860,7 +860,7 @@ mod node { * as `node` bot lower height and/or fragmentation. */ fn bal(node: @node) -> option<@node> { - if height(node) < hint_max_node_height { ret option::none; } + if height(node) < hint_max_node_height { return option::none; } //1. Gather all leaves as a forest let mut forest = ~[mut]; let it = leaf_iterator::start(node); @@ -872,7 +872,7 @@ mod node { } //2. Rebuild tree from forest let root = @*tree_from_forest_destructive(forest); - ret option::some(root); + return option::some(root); } @@ -900,13 +900,13 @@ mod node { let mut byte_offset = byte_offset; loop { if byte_offset == 0u && byte_len == node::byte_len(node) { - ret node; + return node; } alt(*node) { node::leaf(x) { let char_len = str::count_chars(*x.content, byte_offset, byte_len); - ret @leaf({byte_offset: byte_offset, + return @leaf({byte_offset: byte_offset, byte_len: byte_len, char_len: char_len, content: x.content}); @@ -925,7 +925,7 @@ mod node { sub_bytes(x.left, byte_offset, left_len); let right_result = sub_bytes(x.right, 0u, left_len - byte_offset); - ret concat2(left_result, right_result); + return concat2(left_result, right_result); } } else { //Case 3: Everything fits in x.right @@ -963,19 +963,19 @@ mod node { alt(*node) { node::leaf(x) { if char_offset == 0u && char_len == x.char_len { - ret node; + return node; } let byte_offset = str::count_bytes(*x.content, 0u, char_offset); let byte_len = str::count_bytes(*x.content, byte_offset, char_len); - ret @leaf({byte_offset: byte_offset, + return @leaf({byte_offset: byte_offset, byte_len: byte_len, char_len: char_len, content: x.content}); } node::concat(x) { - if char_offset == 0u && char_len == x.char_len {ret node;} + if char_offset == 0u && char_len == x.char_len {return node;} let left_len : uint = node::char_len(x.left); if char_offset <= left_len { if char_offset + char_len <= left_len { @@ -989,7 +989,7 @@ mod node { sub_chars(x.left, char_offset, left_len); let right_result = sub_chars(x.right, 0u, left_len - char_offset); - ret concat2(left_result, right_result); + return concat2(left_result, right_result); } } else { //Case 3: Everything fits in x.right, tail call @@ -1002,7 +1002,7 @@ mod node { } fn concat2(left: @node, right: @node) -> @node { - ret @concat({left : left, + return @concat({left : left, right : right, char_len: char_len(left) + char_len(right), byte_len: byte_len(left) + byte_len(right), @@ -1012,8 +1012,8 @@ mod node { fn height(node: @node) -> uint { alt(*node) { - leaf(_) { ret 0u; } - concat(x) { ret x.height; } + leaf(_) { return 0u; } + concat(x) { return x.height; } } } @@ -1037,11 +1037,11 @@ mod node { } } } - ret result; + return result; } fn loop_chars(node: @node, it: fn(char) -> bool) -> bool { - ret loop_leaves(node,|leaf| { + return loop_leaves(node,|leaf| { str::all_between(*leaf.content, leaf.byte_offset, leaf.byte_len, it) @@ -1067,13 +1067,13 @@ mod node { loop { alt(*current) { leaf(x) { - ret it(x); + return it(x); } concat(x) { if loop_leaves(x.left, it) { //non tail call current = x.right; //tail call } else { - ret false; + return false; } } } @@ -1103,7 +1103,7 @@ mod node { loop { alt *node { leaf(x) { - ret str::char_at(*x.content, pos); + return str::char_at(*x.content, pos); } concat({left, right, _}) { let left_len = char_len(left); @@ -1122,19 +1122,19 @@ mod node { fn empty() -> t { let stack : ~[mut @node] = ~[mut]; - ret {stack: stack, mut stackpos: -1} + return {stack: stack, mut stackpos: -1} } fn start(node: @node) -> t { let stack = vec::to_mut(vec::from_elem(height(node)+1u, node)); - ret { + return { stack: stack, mut stackpos: 0 } } fn next(it: t) -> option<leaf> { - if it.stackpos < 0 { ret option::none; } + if it.stackpos < 0 { return option::none; } loop { let current = it.stack[it.stackpos]; it.stackpos -= 1; @@ -1146,7 +1146,7 @@ mod node { it.stack[it.stackpos] = x.left; } leaf(x) { - ret option::some(x); + return option::some(x); } } }; @@ -1161,7 +1161,7 @@ mod node { }; fn start(node: @node) -> t { - ret { + return { leaf_iterator: leaf_iterator::start(node), mut leaf: option::none, mut leaf_byte_pos: 0u @@ -1169,7 +1169,7 @@ mod node { } fn empty() -> t { - ret { + return { leaf_iterator: leaf_iterator::empty(), mut leaf: option::none, mut leaf_byte_pos: 0u @@ -1179,7 +1179,7 @@ mod node { fn next(it: t) -> option<char> { loop { alt(get_current_or_next_leaf(it)) { - option::none { ret option::none; } + option::none { return option::none; } option::some(_) { let next_char = get_next_char_in_leaf(it); alt(next_char) { @@ -1187,7 +1187,7 @@ mod node { again; } option::some(_) { - ret next_char; + return next_char; } } } @@ -1197,15 +1197,15 @@ mod node { fn get_current_or_next_leaf(it: t) -> option<leaf> { alt(it.leaf) { - option::some(_) { ret it.leaf } + option::some(_) { return it.leaf } option::none { let next = leaf_iterator::next(it.leaf_iterator); alt(next) { - option::none { ret option::none } + option::none { return option::none } option::some(_) { it.leaf = next; it.leaf_byte_pos = 0u; - ret next; + return next; } } } @@ -1214,18 +1214,18 @@ mod node { fn get_next_char_in_leaf(it: t) -> option<char> { alt copy it.leaf { - option::none { ret option::none } + option::none { return option::none } option::some(aleaf) { if it.leaf_byte_pos >= aleaf.byte_len { //We are actually past the end of the leaf it.leaf = option::none; - ret option::none + return option::none } else { let {ch, next} = str::char_range_at(*aleaf.content, it.leaf_byte_pos + aleaf.byte_offset); it.leaf_byte_pos = next - aleaf.byte_offset; - ret option::some(ch) + return option::some(ch) } } } @@ -1239,7 +1239,7 @@ mod tests { //Utility function, used for sanity check fn rope_to_string(r: rope) -> ~str { alt(r) { - node::empty { ret ~"" } + node::empty { return ~"" } node::content(x) { let str = @mut ~""; fn aux(str: @mut ~str, node: @node::node) unsafe { @@ -1256,7 +1256,7 @@ mod tests { } } aux(str, x); - ret *str + return *str } } } diff --git a/src/libstd/sha1.rs b/src/libstd/sha1.rs index eef757f4516..14410eed636 100644 --- a/src/libstd/sha1.rs +++ b/src/libstd/sha1.rs @@ -155,7 +155,7 @@ fn sha1() -> sha1 { st.msg_block_idx = 0u; } fn circular_shift(bits: u32, word: u32) -> u32 { - ret word << bits | word >> 32u32 - bits; + return word << bits | word >> 32u32 - bits; } fn mk_result(st: sha1state) -> ~[u8] { if !st.computed { pad_msg(st); st.computed = true; } @@ -167,7 +167,7 @@ fn sha1() -> sha1 { let d = (hpart & 0xFFu32) as u8; rs = vec::append(rs, ~[a, b, c, d]); } - ret rs; + return rs; } /* @@ -233,12 +233,12 @@ fn sha1() -> sha1 { } 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] { return mk_result(self); } fn result_str() -> ~str { let r = mk_result(self); let mut s = ~""; for vec::each(r) |b| { s += uint::to_str(b as uint, 16u); } - ret s; + return s; } } let st = { @@ -252,7 +252,7 @@ fn sha1() -> sha1 { }; let sh = st as sha1; sh.reset(); - ret sh; + return sh; } #[cfg(test)] @@ -266,7 +266,7 @@ mod tests { let mut i = 0; let mut rs = ~""; while i < 100000 { str::push_str(rs, ~"aaaaaaaaaa"); i += 1; } - ret rs; + return rs; } // Test messages from FIPS 180-1 diff --git a/src/libstd/smallintmap.rs b/src/libstd/smallintmap.rs index 37f829396ab..825630cf4a4 100644 --- a/src/libstd/smallintmap.rs +++ b/src/libstd/smallintmap.rs @@ -18,7 +18,7 @@ enum smallintmap<T:copy> { /// Create a smallintmap fn mk<T: copy>() -> smallintmap<T> { let v = dvec(); - ret smallintmap_(@{v: v}); + return smallintmap_(@{v: v}); } /** @@ -36,8 +36,8 @@ fn insert<T: copy>(self: smallintmap<T>, key: uint, val: T) { * in the map then returns none */ pure fn find<T: copy>(self: smallintmap<T>, key: uint) -> option<T> { - if key < self.v.len() { ret self.v.get_elt(key); } - ret none::<T>; + if key < self.v.len() { return self.v.get_elt(key); } + return none::<T>; } /** @@ -50,13 +50,13 @@ pure fn find<T: copy>(self: smallintmap<T>, key: uint) -> option<T> { pure fn get<T: copy>(self: smallintmap<T>, key: uint) -> T { alt find(self, key) { none { error!{"smallintmap::get(): key not present"}; fail; } - some(v) { ret v; } + some(v) { return v; } } } /// Returns true if the map contains a value for the specified key fn contains_key<T: copy>(self: smallintmap<T>, key: uint) -> bool { - ret !option::is_none(find(self, key)); + return !option::is_none(find(self, key)); } /// Implements the map::map interface for smallintmap @@ -72,10 +72,10 @@ impl <V: copy> of map::map<uint, V> for smallintmap<V> { fn insert(+key: uint, +value: V) -> bool { let exists = contains_key(self, key); insert(self, key, value); - ret !exists; + return !exists; } fn remove(&&key: uint) -> option<V> { - if key >= self.v.len() { ret none; } + if key >= self.v.len() { return none; } let old = self.v.get_elt(key); self.v.set_elt(key, none); old @@ -105,7 +105,7 @@ impl <V: copy> of map::map<uint, V> for smallintmap<V> { fn each_key(it: fn(&&uint) -> bool) { let mut idx = 0u, l = self.v.len(); while idx < l { - if self.v.get_elt(idx) != none && !it(idx) { ret; } + if self.v.get_elt(idx) != none && !it(idx) { return; } idx += 1u; } } diff --git a/src/libstd/sort.rs b/src/libstd/sort.rs index 95dbf5f97dc..84aa3c26482 100644 --- a/src/libstd/sort.rs +++ b/src/libstd/sort.rs @@ -18,7 +18,7 @@ type le<T> = fn(T, T) -> bool; fn merge_sort<T: copy>(le: le<T>, v: ~[const T]) -> ~[T] { type slice = (uint, uint); - ret merge_sort_(le, v, (0u, len(v))); + return merge_sort_(le, v, (0u, len(v))); fn merge_sort_<T: copy>(le: le<T>, v: ~[const T], slice: slice) -> ~[T] { @@ -26,13 +26,13 @@ fn merge_sort<T: copy>(le: le<T>, v: ~[const T]) -> ~[T] { let end = slice.second(); let v_len = end - begin; - if v_len == 0u { ret ~[]; } - if v_len == 1u { ret ~[v[begin]]; } + if v_len == 0u { return ~[]; } + if v_len == 1u { return ~[v[begin]]; } let mid = v_len / 2u + begin; let a = (begin, mid); let b = (mid, end); - ret merge(le, merge_sort_(le, v, a), merge_sort_(le, v, b)); + return merge(le, merge_sort_(le, v, a), merge_sort_(le, v, b)); } fn merge<T: copy>(le: le<T>, a: ~[T], b: ~[T]) -> ~[T] { @@ -50,7 +50,7 @@ fn merge_sort<T: copy>(le: le<T>, v: ~[const T]) -> ~[T] { } rs = vec::append(rs, vec::slice(a, a_ix, a_len)); rs = vec::append(rs, vec::slice(b, b_ix, b_len)); - ret rs; + return rs; } } @@ -68,7 +68,7 @@ fn part<T: copy>(compare_func: le<T>, arr: ~[mut T], left: uint, i += 1u; } arr[storage_index] <-> arr[right]; - ret storage_index; + return storage_index; } fn qsort<T: copy>(compare_func: le<T>, arr: ~[mut T], left: uint, @@ -91,13 +91,13 @@ fn qsort<T: copy>(compare_func: le<T>, arr: ~[mut T], left: uint, * This is an unstable sort. */ fn quick_sort<T: copy>(compare_func: le<T>, arr: ~[mut T]) { - if len::<T>(arr) == 0u { ret; } + if len::<T>(arr) == 0u { return; } 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) { - if right <= left { ret; } + if right <= left { return; } let v: T = arr[right]; let mut i: int = left - 1; let mut j: int = right; @@ -154,7 +154,7 @@ fn qsort3<T: copy>(compare_func_lt: le<T>, compare_func_eq: le<T>, * This is an unstable sort. */ fn quick_sort3<T: copy ord eq>(arr: ~[mut T]) { - if len::<T>(arr) == 0u { ret; } + if len::<T>(arr) == 0u { return; } qsort3::<T>(|x, y| x.lt(y), |x, y| x.eq(y), arr, 0, (len::<T>(arr) as int) - 1); } @@ -202,7 +202,7 @@ mod test_qsort3 { mod test_qsort { 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; } + fn leual(&&a: int, &&b: int) -> bool { return a <= b; } let f = leual; quick_sort::<int>(f, v1); let mut i = 0u; @@ -264,7 +264,7 @@ mod tests { fn check_sort(v1: ~[int], v2: ~[int]) { let len = vec::len::<int>(v1); - fn le(&&a: int, &&b: int) -> bool { ret a <= b; } + fn le(&&a: int, &&b: int) -> bool { return a <= b; } let f = le; let v3 = merge_sort::<int>(f, v1); let mut i = 0u; @@ -294,7 +294,7 @@ mod tests { #[test] fn test_merge_sort_mutable() { - fn le(&&a: int, &&b: int) -> bool { ret a <= b; } + fn le(&&a: int, &&b: int) -> bool { return a <= b; } let v1 = ~[mut 3, 2, 1]; let v2 = merge_sort(le, v1); assert v2 == ~[1, 2, 3]; diff --git a/src/libstd/tempfile.rs b/src/libstd/tempfile.rs index b6f5c81f57e..80a075dbe53 100644 --- a/src/libstd/tempfile.rs +++ b/src/libstd/tempfile.rs @@ -11,11 +11,11 @@ fn mkdtemp(prefix: ~str, suffix: ~str) -> option<~str> { while (i < 1000u) { let s = prefix + r.gen_str(16u) + suffix; if os::make_dir(s, 0x1c0i32) { // FIXME: u+rwx (#2349) - ret some(s); + return some(s); } i += 1u; } - ret none; + return none; } #[test] diff --git a/src/libstd/term.rs b/src/libstd/term.rs index aa2d52822be..0667acb8dd2 100644 --- a/src/libstd/term.rs +++ b/src/libstd/term.rs @@ -35,10 +35,10 @@ fn reset(writer: io::writer) { fn color_supported() -> bool { let supported_terms = ~[~"xterm-color", ~"xterm", ~"screen-bce", ~"xterm-256color"]; - ret alt os::getenv(~"TERM") { + return alt os::getenv(~"TERM") { option::some(env) { for vec::each(supported_terms) |term| { - if str::eq(term, env) { ret true; } + if str::eq(term, env) { return true; } } false } @@ -56,12 +56,12 @@ fn set_color(writer: io::writer, first_char: u8, color: u8) { /// Set the foreground color fn fg(writer: io::writer, color: u8) { - ret set_color(writer, '3' as u8, color); + return set_color(writer, '3' as u8, color); } /// Set the background color fn bg(writer: io::writer, color: u8) { - ret set_color(writer, '4' as u8, color); + return set_color(writer, '4' as u8, color); } // Local Variables: diff --git a/src/libstd/test.rs b/src/libstd/test.rs index 4c9cd41d48a..5d503e4c15f 100644 --- a/src/libstd/test.rs +++ b/src/libstd/test.rs @@ -71,7 +71,7 @@ fn parse_opts(args: ~[~str]) -> opt_res { let matches = alt getopts::getopts(args_, opts) { ok(m) { m } - err(f) { ret either::right(getopts::fail_str(f)) } + err(f) { return either::right(getopts::fail_str(f)) } }; let filter = @@ -85,7 +85,7 @@ fn parse_opts(args: ~[~str]) -> opt_res { let test_opts = {filter: filter, run_ignored: run_ignored, logfile: logfile}; - ret either::left(test_opts); + return either::left(test_opts); } enum test_result { tr_ok, tr_failed, tr_ignored, } @@ -180,7 +180,7 @@ fn run_tests_console(opts: test_opts, st.out.write_str(fmt!{". %u passed; %u failed; %u ignored\n\n", st.passed, st.failed, st.ignored}); - ret success; + return success; fn write_log(out: io::writer, result: test_result, test: test_desc) { out.write_line(fmt!{"%s %s", @@ -262,7 +262,7 @@ fn should_sort_failures_before_printing_them() { assert apos < bpos; } -fn use_color() -> bool { ret get_concurrency() == 1u; } +fn use_color() -> bool { return get_concurrency() == 1u; } enum testevent { te_filtered(~[test_desc]), @@ -346,8 +346,8 @@ fn filter_tests(opts: test_opts, fn filter_fn(test: test_desc, filter_str: ~str) -> option<test_desc> { if str::contains(test.name, filter_str) { - ret option::some(copy test); - } else { ret option::none; } + return option::some(copy test); + } else { return option::none; } } let filter = |x| filter_fn(x, filter_str); @@ -361,11 +361,11 @@ fn filter_tests(opts: test_opts, } else { fn filter(test: test_desc) -> option<test_desc> { if test.ignore { - ret option::some({name: test.name, + return option::some({name: test.name, fn: copy test.fn, ignore: false, should_fail: test.should_fail}); - } else { ret option::none; } + } else { return option::none; } }; vec::filter_map(filtered, |x| filter(x)) @@ -380,7 +380,7 @@ fn filter_tests(opts: test_opts, sort::merge_sort(|x,y| lteq(x, y), filtered) }; - ret filtered; + return filtered; } type test_future = {test: test_desc, wait: fn@() -> test_result}; @@ -388,7 +388,7 @@ type test_future = {test: test_desc, wait: fn@() -> test_result}; fn run_test(+test: test_desc, monitor_ch: comm::chan<monitor_msg>) { if test.ignore { comm::send(monitor_ch, (copy test, tr_ignored)); - ret; + return; } do task::spawn { diff --git a/src/libstd/time.rs b/src/libstd/time.rs index 7cbf16f2ec0..3ec2975db18 100644 --- a/src/libstd/time.rs +++ b/src/libstd/time.rs @@ -40,7 +40,7 @@ fn get_time() -> timespec { let mut sec = 0i64; let mut nsec = 0i32; rustrt::get_time(sec, nsec); - ret {sec: sec, nsec: nsec}; + return {sec: sec, nsec: nsec}; } /** @@ -58,7 +58,7 @@ fn precise_time_ns() -> u64 { * in seconds since an unspecified epoch. */ fn precise_time_s() -> float { - ret (precise_time_ns() as float) / 1000000000.; + return (precise_time_ns() as float) / 1000000000.; } fn tzset() { @@ -148,11 +148,11 @@ fn strptime(s: ~str, format: ~str) -> result<tm, ~str> { let mut i = pos; for str::each(needle) |ch| { if s[i] != ch { - ret false; + return false; } i += 1u; } - ret true; + return true; } fn match_strs(s: ~str, pos: uint, strs: ~[(~str, i32)]) @@ -163,7 +163,7 @@ fn strptime(s: ~str, format: ~str) -> result<tm, ~str> { let (needle, value) = strs[i]; if match_str(s, pos, needle) { - ret some((value, pos + str::len(needle))); + return some((value, pos + str::len(needle))); } i += 1u; } @@ -186,7 +186,7 @@ fn strptime(s: ~str, format: ~str) -> result<tm, ~str> { value = value * 10_i32 + (ch as i32 - '0' as i32); } ' ' if ws { } - _ { ret none; } + _ { return none; } } i += 1u; } diff --git a/src/libstd/treemap.rs b/src/libstd/treemap.rs index 3def5fbd0d1..b6dc2bfa579 100644 --- a/src/libstd/treemap.rs +++ b/src/libstd/treemap.rs @@ -36,7 +36,7 @@ fn insert<K: copy, V: copy>(m: &mut tree_edge<K, V>, k: K, v: V) { mut value: v, mut left: none, mut right: none})); - ret; + return; } some(node) { if k == node.key { diff --git a/src/libstd/unicode.rs b/src/libstd/unicode.rs index df2c28be7c9..31d2e51e160 100644 --- a/src/libstd/unicode.rs +++ b/src/libstd/unicode.rs @@ -160,12 +160,12 @@ mod icu { } pure fn is_XID_start(c: char) -> bool { - ret icu::libicu::u_hasBinaryProperty(c, icu::UCHAR_XID_START) + return icu::libicu::u_hasBinaryProperty(c, icu::UCHAR_XID_START) == icu::TRUE; } pure fn is_XID_continue(c: char) -> bool { - ret icu::libicu::u_hasBinaryProperty(c, icu::UCHAR_XID_START) + return icu::libicu::u_hasBinaryProperty(c, icu::UCHAR_XID_START) == icu::TRUE; } @@ -175,7 +175,7 @@ Function: is_digit Returns true if a character is a digit. */ pure fn is_digit(c: char) -> bool { - ret icu::libicu::u_isdigit(c) == icu::TRUE; + return icu::libicu::u_isdigit(c) == icu::TRUE; } /* @@ -184,7 +184,7 @@ Function: is_lower Returns true if a character is a lowercase letter. */ pure fn is_lower(c: char) -> bool { - ret icu::libicu::u_islower(c) == icu::TRUE; + return icu::libicu::u_islower(c) == icu::TRUE; } /* @@ -193,7 +193,7 @@ Function: is_space Returns true if a character is space. */ pure fn is_space(c: char) -> bool { - ret icu::libicu::u_isspace(c) == icu::TRUE; + return icu::libicu::u_isspace(c) == icu::TRUE; } /* @@ -202,7 +202,7 @@ Function: is_upper Returns true if a character is an uppercase letter. */ pure fn is_upper(c: char) -> bool { - ret icu::libicu::u_isupper(c) == icu::TRUE; + return icu::libicu::u_isupper(c) == icu::TRUE; } #[cfg(test)] diff --git a/src/libstd/uv_global_loop.rs b/src/libstd/uv_global_loop.rs index d3b9795b85b..2b5beda2e37 100644 --- a/src/libstd/uv_global_loop.rs +++ b/src/libstd/uv_global_loop.rs @@ -28,7 +28,7 @@ extern mod rustrt { * loop. */ fn get() -> iotask { - ret get_monitor_task_gl(); + return get_monitor_task_gl(); } #[doc(hidden)] diff --git a/src/libstd/uv_iotask.rs b/src/libstd/uv_iotask.rs index bc9878ccc40..d7de26228ca 100644 --- a/src/libstd/uv_iotask.rs +++ b/src/libstd/uv_iotask.rs @@ -213,7 +213,7 @@ mod test { run_loop(iotask_ch); exit_ch.send(()); }; - ret comm::recv(iotask_port); + return comm::recv(iotask_port); } extern fn lifetime_handle_close(handle: *libc::c_void) unsafe { diff --git a/src/libstd/uv_ll.rs b/src/libstd/uv_ll.rs index 96c3b5b1609..7b4033d0ff3 100644 --- a/src/libstd/uv_ll.rs +++ b/src/libstd/uv_ll.rs @@ -303,15 +303,15 @@ type uv_getaddrinfo_t = { mod uv_ll_struct_stubgen { fn gen_stub_uv_tcp_t() -> uv_tcp_t { - ret gen_stub_os(); + return gen_stub_os(); #[cfg(target_os = "linux")] #[cfg(target_os = "macos")] #[cfg(target_os = "freebsd")] fn gen_stub_os() -> uv_tcp_t { - ret gen_stub_arch(); + return gen_stub_arch(); #[cfg(target_arch="x86_64")] fn gen_stub_arch() -> uv_tcp_t { - ret { fields: { loop_handle: ptr::null(), type_: 0u32, + return { fields: { loop_handle: ptr::null(), type_: 0u32, close_cb: ptr::null(), mut data: ptr::null() }, a00: 0 as *u8, a01: 0 as *u8, a02: 0 as *u8, @@ -336,7 +336,7 @@ mod uv_ll_struct_stubgen { } #[cfg(target_arch="x86")] fn gen_stub_arch() -> uv_tcp_t { - ret { fields: { loop_handle: ptr::null(), type_: 0u32, + return { fields: { loop_handle: ptr::null(), type_: 0u32, close_cb: ptr::null(), mut data: ptr::null() }, a00: 0 as *u8, a01: 0 as *u8, a02: 0 as *u8, @@ -364,7 +364,7 @@ mod uv_ll_struct_stubgen { } #[cfg(windows)] fn gen_stub_os() -> uv_tcp_t { - ret { fields: { loop_handle: ptr::null(), type_: 0u32, + return { fields: { loop_handle: ptr::null(), type_: 0u32, close_cb: ptr::null(), mut data: ptr::null() }, a00: 0 as *u8, a01: 0 as *u8, a02: 0 as *u8, @@ -385,7 +385,7 @@ mod uv_ll_struct_stubgen { } #[cfg(unix)] fn gen_stub_uv_connect_t() -> uv_connect_t { - ret { + return { a00: 0 as *u8, a01: 0 as *u8, a02: 0 as *u8, a03: 0 as *u8, a04: 0 as *u8, a05: 0 as *u8 @@ -393,7 +393,7 @@ mod uv_ll_struct_stubgen { } #[cfg(windows)] fn gen_stub_uv_connect_t() -> uv_connect_t { - ret { + return { a00: 0 as *u8, a01: 0 as *u8, a02: 0 as *u8, a03: 0 as *u8, a04: 0 as *u8, a05: 0 as *u8, a06: 0 as *u8, @@ -403,10 +403,10 @@ mod uv_ll_struct_stubgen { } #[cfg(unix)] fn gen_stub_uv_async_t() -> uv_async_t { - ret gen_stub_arch(); + return gen_stub_arch(); #[cfg(target_arch = "x86_64")] fn gen_stub_arch() -> uv_async_t { - ret { fields: { loop_handle: ptr::null(), type_: 0u32, + return { fields: { loop_handle: ptr::null(), type_: 0u32, close_cb: ptr::null(), mut data: ptr::null() }, a00: 0 as *u8, a01: 0 as *u8, a02: 0 as *u8, @@ -421,7 +421,7 @@ mod uv_ll_struct_stubgen { } #[cfg(target_arch = "x86")] fn gen_stub_arch() -> uv_async_t { - ret { fields: { loop_handle: ptr::null(), type_: 0u32, + return { fields: { loop_handle: ptr::null(), type_: 0u32, close_cb: ptr::null(), mut data: ptr::null() }, a00: 0 as *u8, a01: 0 as *u8, a02: 0 as *u8, @@ -438,7 +438,7 @@ mod uv_ll_struct_stubgen { } #[cfg(windows)] fn gen_stub_uv_async_t() -> uv_async_t { - ret { fields: { loop_handle: ptr::null(), type_: 0u32, + return { fields: { loop_handle: ptr::null(), type_: 0u32, close_cb: ptr::null(), mut data: ptr::null() }, a00: 0 as *u8, a01: 0 as *u8, a02: 0 as *u8, @@ -452,10 +452,10 @@ mod uv_ll_struct_stubgen { } #[cfg(unix)] fn gen_stub_uv_timer_t() -> uv_timer_t { - ret gen_stub_arch(); + return gen_stub_arch(); #[cfg(target_arch = "x86_64")] fn gen_stub_arch() -> uv_timer_t { - ret { fields: { loop_handle: ptr::null(), type_: 0u32, + return { fields: { loop_handle: ptr::null(), type_: 0u32, close_cb: ptr::null(), mut data: ptr::null() }, a00: 0 as *u8, a01: 0 as *u8, a02: 0 as *u8, @@ -470,7 +470,7 @@ mod uv_ll_struct_stubgen { } #[cfg(target_arch = "x86")] fn gen_stub_arch() -> uv_timer_t { - ret { fields: { loop_handle: ptr::null(), type_: 0u32, + return { fields: { loop_handle: ptr::null(), type_: 0u32, close_cb: ptr::null(), mut data: ptr::null() }, a00: 0 as *u8, a01: 0 as *u8, a02: 0 as *u8, @@ -489,7 +489,7 @@ mod uv_ll_struct_stubgen { } #[cfg(windows)] fn gen_stub_uv_timer_t() -> uv_timer_t { - ret { fields: { loop_handle: ptr::null(), type_: 0u32, + return { fields: { loop_handle: ptr::null(), type_: 0u32, close_cb: ptr::null(), mut data: ptr::null() }, a00: 0 as *u8, a01: 0 as *u8, a02: 0 as *u8, @@ -502,10 +502,10 @@ mod uv_ll_struct_stubgen { } #[cfg(unix)] fn gen_stub_uv_write_t() -> uv_write_t { - ret gen_stub_arch(); + return gen_stub_arch(); #[cfg(target_arch="x86_64")] fn gen_stub_arch() -> uv_write_t { - ret { fields: { loop_handle: ptr::null(), type_: 0u32, + return { fields: { loop_handle: ptr::null(), type_: 0u32, close_cb: ptr::null(), mut data: ptr::null() }, a00: 0 as *u8, a01: 0 as *u8, a02: 0 as *u8, @@ -519,7 +519,7 @@ mod uv_ll_struct_stubgen { } #[cfg(target_arch="x86")] fn gen_stub_arch() -> uv_write_t { - ret { fields: { loop_handle: ptr::null(), type_: 0u32, + return { fields: { loop_handle: ptr::null(), type_: 0u32, close_cb: ptr::null(), mut data: ptr::null() }, a00: 0 as *u8, a01: 0 as *u8, a02: 0 as *u8, @@ -534,7 +534,7 @@ mod uv_ll_struct_stubgen { } #[cfg(windows)] fn gen_stub_uv_write_t() -> uv_write_t { - ret { fields: { loop_handle: ptr::null(), type_: 0u32, + return { fields: { loop_handle: ptr::null(), type_: 0u32, close_cb: ptr::null(), mut data: ptr::null() }, a00: 0 as *u8, a01: 0 as *u8, a02: 0 as *u8, @@ -676,7 +676,7 @@ extern mod rustrt { } unsafe fn loop_new() -> *libc::c_void { - ret rustrt::rust_uv_loop_new(); + return rustrt::rust_uv_loop_new(); } unsafe fn loop_delete(loop_handle: *libc::c_void) { @@ -684,7 +684,7 @@ unsafe fn loop_delete(loop_handle: *libc::c_void) { } unsafe fn loop_refcount(loop_ptr: *libc::c_void) -> libc::c_int { - ret rustrt::rust_uv_loop_refcount(loop_ptr); + return rustrt::rust_uv_loop_refcount(loop_ptr); } unsafe fn run(loop_handle: *libc::c_void) { @@ -697,7 +697,7 @@ unsafe fn close<T>(handle: *T, cb: *u8) { unsafe fn tcp_init(loop_handle: *libc::c_void, handle: *uv_tcp_t) -> libc::c_int { - ret rustrt::rust_uv_tcp_init(loop_handle, handle); + return rustrt::rust_uv_tcp_init(loop_handle, handle); } // FIXME ref #2064 unsafe fn tcp_connect(connect_ptr: *uv_connect_t, @@ -707,7 +707,7 @@ unsafe fn tcp_connect(connect_ptr: *uv_connect_t, -> libc::c_int { log(debug, fmt!{"b4 foreign tcp_connect--addr port: %u cb: %u", (*addr_ptr).sin_port as uint, after_connect_cb as uint}); - ret rustrt::rust_uv_tcp_connect(connect_ptr, tcp_handle_ptr, + return rustrt::rust_uv_tcp_connect(connect_ptr, tcp_handle_ptr, after_connect_cb, addr_ptr); } // FIXME ref #2064 @@ -716,30 +716,30 @@ unsafe fn tcp_connect6(connect_ptr: *uv_connect_t, addr_ptr: *sockaddr_in6, ++after_connect_cb: *u8) -> libc::c_int { - ret rustrt::rust_uv_tcp_connect6(connect_ptr, tcp_handle_ptr, + return rustrt::rust_uv_tcp_connect6(connect_ptr, tcp_handle_ptr, after_connect_cb, addr_ptr); } // FIXME ref #2064 unsafe fn tcp_bind(tcp_server_ptr: *uv_tcp_t, addr_ptr: *sockaddr_in) -> libc::c_int { - ret rustrt::rust_uv_tcp_bind(tcp_server_ptr, + return rustrt::rust_uv_tcp_bind(tcp_server_ptr, addr_ptr); } // FIXME ref #2064 unsafe fn tcp_bind6(tcp_server_ptr: *uv_tcp_t, addr_ptr: *sockaddr_in6) -> libc::c_int { - ret rustrt::rust_uv_tcp_bind6(tcp_server_ptr, + return rustrt::rust_uv_tcp_bind6(tcp_server_ptr, addr_ptr); } unsafe fn listen<T>(stream: *T, backlog: libc::c_int, cb: *u8) -> libc::c_int { - ret rustrt::rust_uv_listen(stream as *libc::c_void, backlog, cb); + return rustrt::rust_uv_listen(stream as *libc::c_void, backlog, cb); } unsafe fn accept(server: *libc::c_void, client: *libc::c_void) -> libc::c_int { - ret rustrt::rust_uv_accept(server as *libc::c_void, + return rustrt::rust_uv_accept(server as *libc::c_void, client as *libc::c_void); } @@ -747,41 +747,41 @@ unsafe fn write<T>(req: *uv_write_t, stream: *T, 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, + return rustrt::rust_uv_write(req as *libc::c_void, stream as *libc::c_void, buf_ptr, buf_cnt, cb); } unsafe fn read_start(stream: *uv_stream_t, on_alloc: *u8, on_read: *u8) -> libc::c_int { - ret rustrt::rust_uv_read_start(stream as *libc::c_void, + return rustrt::rust_uv_read_start(stream as *libc::c_void, on_alloc, on_read); } unsafe fn read_stop(stream: *uv_stream_t) -> libc::c_int { - ret rustrt::rust_uv_read_stop(stream as *libc::c_void); + return rustrt::rust_uv_read_stop(stream as *libc::c_void); } unsafe fn last_error(loop_handle: *libc::c_void) -> uv_err_t { - ret rustrt::rust_uv_last_error(loop_handle); + return rustrt::rust_uv_last_error(loop_handle); } unsafe fn strerror(err: *uv_err_t) -> *libc::c_char { - ret rustrt::rust_uv_strerror(err); + return rustrt::rust_uv_strerror(err); } unsafe fn err_name(err: *uv_err_t) -> *libc::c_char { - ret rustrt::rust_uv_err_name(err); + return rustrt::rust_uv_err_name(err); } unsafe fn async_init(loop_handle: *libc::c_void, async_handle: *uv_async_t, cb: *u8) -> libc::c_int { - ret rustrt::rust_uv_async_init(loop_handle, + return rustrt::rust_uv_async_init(loop_handle, async_handle, cb); } unsafe fn async_send(async_handle: *uv_async_t) { - ret rustrt::rust_uv_async_send(async_handle); + return rustrt::rust_uv_async_send(async_handle); } unsafe fn buf_init(++input: *u8, len: uint) -> uv_buf_t { let out_buf = { base: ptr::null(), len: 0 as libc::size_t }; @@ -800,8 +800,8 @@ unsafe fn buf_init(++input: *u8, len: uint) -> uv_buf_t { log(debug, fmt!{"buf_init - result %u len %u", res_base as uint, res_len as uint}); - ret out_buf; - //ret result; + return out_buf; + //return result; } unsafe fn ip4_addr(ip: ~str, port: int) -> sockaddr_in { @@ -860,15 +860,15 @@ unsafe fn ip6_name(src: &sockaddr_in6) -> ~str { unsafe fn timer_init(loop_ptr: *libc::c_void, timer_ptr: *uv_timer_t) -> libc::c_int { - ret rustrt::rust_uv_timer_init(loop_ptr, timer_ptr); + return rustrt::rust_uv_timer_init(loop_ptr, timer_ptr); } unsafe fn timer_start(timer_ptr: *uv_timer_t, cb: *u8, timeout: uint, repeat: uint) -> libc::c_int { - ret rustrt::rust_uv_timer_start(timer_ptr, cb, timeout as libc::c_uint, + return rustrt::rust_uv_timer_start(timer_ptr, cb, timeout as libc::c_uint, repeat as libc::c_uint); } unsafe fn timer_stop(timer_ptr: *uv_timer_t) -> libc::c_int { - ret rustrt::rust_uv_timer_stop(timer_ptr); + return rustrt::rust_uv_timer_stop(timer_ptr); } unsafe fn getaddrinfo(loop_ptr: *libc::c_void, handle: *uv_getaddrinfo_t, @@ -889,38 +889,38 @@ unsafe fn freeaddrinfo(res: *addrinfo) { // libuv struct initializers unsafe fn tcp_t() -> uv_tcp_t { - ret uv_ll_struct_stubgen::gen_stub_uv_tcp_t(); + return uv_ll_struct_stubgen::gen_stub_uv_tcp_t(); } unsafe fn connect_t() -> uv_connect_t { - ret uv_ll_struct_stubgen::gen_stub_uv_connect_t(); + return uv_ll_struct_stubgen::gen_stub_uv_connect_t(); } unsafe fn write_t() -> uv_write_t { - ret uv_ll_struct_stubgen::gen_stub_uv_write_t(); + return uv_ll_struct_stubgen::gen_stub_uv_write_t(); } unsafe fn async_t() -> uv_async_t { - ret uv_ll_struct_stubgen::gen_stub_uv_async_t(); + return uv_ll_struct_stubgen::gen_stub_uv_async_t(); } unsafe fn timer_t() -> uv_timer_t { - ret uv_ll_struct_stubgen::gen_stub_uv_timer_t(); + return uv_ll_struct_stubgen::gen_stub_uv_timer_t(); } unsafe fn getaddrinfo_t() -> uv_getaddrinfo_t { - ret uv_ll_struct_stubgen::gen_stub_uv_getaddrinfo_t(); + return uv_ll_struct_stubgen::gen_stub_uv_getaddrinfo_t(); } // data access helpers unsafe fn get_loop_for_uv_handle<T>(handle: *T) -> *libc::c_void { - ret rustrt::rust_uv_get_loop_for_uv_handle(handle as *libc::c_void); + return rustrt::rust_uv_get_loop_for_uv_handle(handle as *libc::c_void); } unsafe fn get_stream_handle_from_connect_req(connect: *uv_connect_t) -> *uv_stream_t { - ret rustrt::rust_uv_get_stream_handle_from_connect_req( + return rustrt::rust_uv_get_stream_handle_from_connect_req( connect); } unsafe fn get_stream_handle_from_write_req( write_req: *uv_write_t) -> *uv_stream_t { - ret rustrt::rust_uv_get_stream_handle_from_write_req( + return rustrt::rust_uv_get_stream_handle_from_write_req( write_req); } unsafe fn get_data_for_uv_loop(loop_ptr: *libc::c_void) -> *libc::c_void { @@ -930,7 +930,7 @@ unsafe fn set_data_for_uv_loop(loop_ptr: *libc::c_void, data: *libc::c_void) { rustrt::rust_uv_set_data_for_uv_loop(loop_ptr, data); } unsafe fn get_data_for_uv_handle<T>(handle: *T) -> *libc::c_void { - ret rustrt::rust_uv_get_data_for_uv_handle(handle as *libc::c_void); + return rustrt::rust_uv_get_data_for_uv_handle(handle as *libc::c_void); } unsafe fn set_data_for_uv_handle<T, U>(handle: *T, data: *U) { @@ -938,7 +938,7 @@ unsafe fn set_data_for_uv_handle<T, U>(handle: *T, data as *libc::c_void); } unsafe fn get_data_for_req<T>(req: *T) -> *libc::c_void { - ret rustrt::rust_uv_get_data_for_req(req as *libc::c_void); + return rustrt::rust_uv_get_data_for_req(req as *libc::c_void); } unsafe fn set_data_for_req<T, U>(req: *T, data: *U) { @@ -946,14 +946,14 @@ unsafe fn set_data_for_req<T, U>(req: *T, data as *libc::c_void); } unsafe fn get_base_from_buf(buf: uv_buf_t) -> *u8 { - ret rustrt::rust_uv_get_base_from_buf(buf); + return rustrt::rust_uv_get_base_from_buf(buf); } unsafe fn get_len_from_buf(buf: uv_buf_t) -> libc::size_t { - ret rustrt::rust_uv_get_len_from_buf(buf); + return rustrt::rust_uv_get_len_from_buf(buf); } unsafe fn malloc_buf_base_of(suggested_size: libc::size_t) -> *u8 { - ret rustrt::rust_uv_malloc_buf_base_of(suggested_size); + return rustrt::rust_uv_malloc_buf_base_of(suggested_size); } unsafe fn free_base_of_buf(buf: uv_buf_t) { rustrt::rust_uv_free_base_of_buf(buf); @@ -964,7 +964,7 @@ unsafe fn get_last_err_info(uv_loop: *libc::c_void) -> ~str { let err_ptr = ptr::addr_of(err); let err_name = str::unsafe::from_c_str(err_name(err_ptr)); let err_msg = str::unsafe::from_c_str(strerror(err_ptr)); - ret fmt!{"LIBUV ERROR: name: %s msg: %s", + return fmt!{"LIBUV ERROR: name: %s msg: %s", err_name, err_msg}; } @@ -1028,7 +1028,7 @@ mod test { handle, char_ptr as uint, suggested_size as uint}); - ret buf_init(char_ptr, suggested_size as uint); + return buf_init(char_ptr, suggested_size as uint); } extern fn on_read_cb(stream: *uv_stream_t, @@ -1277,7 +1277,7 @@ mod test { let err_msg = get_last_err_info(test_loop); log(debug, fmt!{"server_connect_cb: non-zero status: %?", err_msg}); - ret; + return; } let server_data = get_data_for_uv_handle( server_stream_ptr as *libc::c_void) as *tcp_server_data; |
