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/libcore | |
| parent | dc499f193e473abc78c557feaa86969bbe7aa159 (diff) | |
| download | rust-b355936b4da0831f47afe8f251daee503c8caa32.tar.gz rust-b355936b4da0831f47afe8f251daee503c8caa32.zip | |
Convert ret to return
Diffstat (limited to 'src/libcore')
36 files changed, 482 insertions, 482 deletions
diff --git a/src/libcore/arc.rs b/src/libcore/arc.rs index 6a27c0b7ade..30bed71aa95 100644 --- a/src/libcore/arc.rs +++ b/src/libcore/arc.rs @@ -61,7 +61,7 @@ fn get<T: const send>(rc: &arc<T>) -> &T { // Cast us back into the correct region let r = unsafe::reinterpret_cast(&ptr.data); unsafe::forget(ptr); - ret r; + return r; } } diff --git a/src/libcore/at_vec.rs b/src/libcore/at_vec.rs index 95b7c1c830e..b5d6e655e4a 100644 --- a/src/libcore/at_vec.rs +++ b/src/libcore/at_vec.rs @@ -60,7 +60,7 @@ pure fn build_sized<A>(size: uint, builder: fn(push: pure fn(+A))) -> @[A] { <fn(push: pure fn(+A)), fn(push: fn(+A))> (builder)(|+x| unsafe::push(vec, x)); } - ret vec; + return vec; } /** diff --git a/src/libcore/char.rs b/src/libcore/char.rs index af65c3f4b96..5849d19d8c1 100644 --- a/src/libcore/char.rs +++ b/src/libcore/char.rs @@ -51,7 +51,7 @@ import is_XID_continue = unicode::derived_property::XID_Continue; * in terms of the Unicode General Category 'Ll' */ pure fn is_lowercase(c: char) -> bool { - ret unicode::general_category::Ll(c); + return unicode::general_category::Ll(c); } /** @@ -59,7 +59,7 @@ pure fn is_lowercase(c: char) -> bool { * in terms of the Unicode General Category 'Lu'. */ pure fn is_uppercase(c: char) -> bool { - ret unicode::general_category::Lu(c); + return unicode::general_category::Lu(c); } /** @@ -68,7 +68,7 @@ pure fn is_uppercase(c: char) -> bool { * additional 'Cc'-category control codes in the range [0x09, 0x0d] */ pure fn is_whitespace(c: char) -> bool { - ret ('\x09' <= c && c <= '\x0d') + return ('\x09' <= c && c <= '\x0d') || unicode::general_category::Zs(c) || unicode::general_category::Zl(c) || unicode::general_category::Zp(c); @@ -80,7 +80,7 @@ pure fn is_whitespace(c: char) -> bool { * 'Nl', 'No' and the Derived Core Property 'Alphabetic'. */ pure fn is_alphanumeric(c: char) -> bool { - ret unicode::derived_property::Alphabetic(c) || + return unicode::derived_property::Alphabetic(c) || unicode::general_category::Nd(c) || unicode::general_category::Nl(c) || unicode::general_category::No(c); @@ -93,7 +93,7 @@ pure fn is_ascii(c: char) -> bool { /// Indicates whether the character is numeric (Nd, Nl, or No) pure fn is_digit(c: char) -> bool { - ret unicode::general_category::Nd(c) || + return unicode::general_category::Nd(c) || unicode::general_category::Nl(c) || unicode::general_category::No(c); } @@ -117,7 +117,7 @@ pure fn to_digit(c: char, radix: uint) -> option<uint> { '0' to '9' { c as uint - ('0' as uint) } 'a' to 'z' { c as uint + 10u - ('a' as uint) } 'A' to 'Z' { c as uint + 10u - ('A' as uint) } - _ { ret none; } + _ { return none; } }; if val < radix { some(val) } else { none } @@ -142,7 +142,7 @@ fn escape_unicode(c: char) -> ~str { str::push_str(out, str::from_char(c)); for uint::range(str::len(s), pad) |_i| { str::push_str(out, ~"0"); } str::push_str(out, s); - ret out; + return out; } /** @@ -178,7 +178,7 @@ fn escape_default(c: char) -> ~str { * -1 if a < b, 0 if a == b, +1 if a > b */ pure fn cmp(a: char, b: char) -> int { - ret if b > a { -1 } + return if b > a { -1 } else if b < a { 1 } else { 0 } } diff --git a/src/libcore/comm.rs b/src/libcore/comm.rs index a4bd25e5b9d..fd1067241a8 100644 --- a/src/libcore/comm.rs +++ b/src/libcore/comm.rs @@ -207,7 +207,7 @@ fn recv_<T: send>(p: *rust_port) -> T { // this is a good place to yield task::yield(); } - ret res; + return res; } fn peek_(p: *rust_port) -> bool { diff --git a/src/libcore/dvec.rs b/src/libcore/dvec.rs index 9db3d0bc2c4..4f1e02d674d 100644 --- a/src/libcore/dvec.rs +++ b/src/libcore/dvec.rs @@ -72,7 +72,7 @@ fn from_vec<A>(+v: ~[mut A]) -> dvec<A> { /// Consumes the vector and returns its contents fn unwrap<A>(-d: dvec<A>) -> ~[mut A] { let dvec_({data: v}) <- d; - ret v; + return v; } impl private_methods<A> for dvec<A> { @@ -92,7 +92,7 @@ impl private_methods<A> for dvec<A> { data <-> self.data; let data_ptr: *() = unsafe::reinterpret_cast(data); if data_ptr.is_null() { fail ~"Recursive use of dvec"; } - ret f(data); + return f(data); } } @@ -263,7 +263,7 @@ impl extensions<A:copy> for dvec<A> { #[inline(always)] pure fn get_elt(idx: uint) -> A { self.check_not_borrowed(); - ret self.data[idx]; + return self.data[idx]; } /// Overwrites the contents of the element at `idx` with `a` @@ -295,7 +295,7 @@ impl extensions<A:copy> for dvec<A> { fail ~"attempt to retrieve the last element of an empty vector"; } - ret self.data[length - 1u]; + return self.data[length - 1u]; } /// Iterates over the elements in reverse order diff --git a/src/libcore/either.rs b/src/libcore/either.rs index d1ea214ef0a..64a7abd0f35 100644 --- a/src/libcore/either.rs +++ b/src/libcore/either.rs @@ -28,7 +28,7 @@ fn lefts<T: copy, U>(eithers: ~[either<T, U>]) -> ~[T] { for vec::each(eithers) |elt| { alt elt { left(l) { vec::push(result, l); } _ {/* fallthrough */ } } } - ret result; + return result; } fn rights<T, U: copy>(eithers: ~[either<T, U>]) -> ~[U] { @@ -38,7 +38,7 @@ fn rights<T, U: copy>(eithers: ~[either<T, U>]) -> ~[U] { for vec::each(eithers) |elt| { alt elt { right(r) { vec::push(result, r); } _ {/* fallthrough */ } } } - ret result; + return result; } fn partition<T: copy, U: copy>(eithers: ~[either<T, U>]) @@ -58,7 +58,7 @@ fn partition<T: copy, U: copy>(eithers: ~[either<T, U>]) right(r) { vec::push(rights, r); } } } - ret {lefts: lefts, rights: rights}; + return {lefts: lefts, rights: rights}; } pure fn flip<T: copy, U: copy>(eith: either<T, U>) -> either<U, T> { diff --git a/src/libcore/extfmt.rs b/src/libcore/extfmt.rs index 7eec13c1b1a..a4e3b2144c9 100644 --- a/src/libcore/extfmt.rs +++ b/src/libcore/extfmt.rs @@ -90,7 +90,7 @@ mod ct { let piece = piece_string(buf); vec::push(pieces, piece); } - ret ~""; + return ~""; } let mut i = 0u; while i < lim { @@ -114,15 +114,15 @@ mod ct { } else { buf += curr; i += size; } } flush_buf(buf, pieces); - ret pieces; + return pieces; } fn peek_num(s: ~str, i: uint, lim: uint) -> option<{num: uint, next: uint}> { - if i >= lim { ret none; } + if i >= lim { return none; } let c = s[i]; - if !('0' as u8 <= c && c <= '9' as u8) { ret option::none; } + if !('0' as u8 <= c && c <= '9' as u8) { return option::none; } let n = (c - ('0' as u8)) as uint; - ret alt peek_num(s, i + 1u, lim) { + return alt peek_num(s, i + 1u, lim) { none { some({num: n, next: i + 1u}) } some(next) { let m = next.num; @@ -138,7 +138,7 @@ mod ct { let width = parse_count(s, flags.next, lim); let prec = parse_precision(s, width.next, lim); let ty = parse_type(s, prec.next, lim, error); - ret {piece: + return {piece: piece_conv({param: parm.param, flags: flags.flags, width: width.count, @@ -148,9 +148,9 @@ mod ct { } fn parse_parameter(s: ~str, i: uint, lim: uint) -> {param: option<int>, next: uint} { - if i >= lim { ret {param: none, next: i}; } + if i >= lim { return {param: none, next: i}; } let num = peek_num(s, i, lim); - ret alt num { + return alt num { none { {param: none, next: i} } some(t) { let n = t.num; @@ -164,7 +164,7 @@ mod ct { fn parse_flags(s: ~str, i: uint, lim: uint) -> {flags: ~[flag], next: uint} { let noflags: ~[flag] = ~[]; - if i >= lim { ret {flags: noflags, next: i}; } + if i >= lim { return {flags: noflags, next: i}; } fn more_(f: flag, s: ~str, i: uint, lim: uint) -> {flags: ~[flag], next: uint} { @@ -172,11 +172,11 @@ mod ct { let rest = next.flags; let j = next.next; let curr: ~[flag] = ~[f]; - ret {flags: vec::append(curr, rest), next: j}; + return {flags: vec::append(curr, rest), next: j}; } let more = |x| more_(x, s, i, lim); let f = s[i]; - ret if f == '-' as u8 { + return if f == '-' as u8 { more(flag_left_justify) } else if f == '0' as u8 { more(flag_left_zero_pad) @@ -190,7 +190,7 @@ mod ct { } fn parse_count(s: ~str, i: uint, lim: uint) -> {count: count, next: uint} { - ret if i >= lim { + return if i >= lim { {count: count_implied, next: i} } else if s[i] == '*' as u8 { let param = parse_parameter(s, i + 1u, lim); @@ -211,7 +211,7 @@ mod ct { } fn parse_precision(s: ~str, i: uint, lim: uint) -> {count: count, next: uint} { - ret if i >= lim { + return if i >= lim { {count: count_implied, next: i} } else if s[i] == '.' as u8 { let count = parse_count(s, i + 1u, lim); @@ -255,7 +255,7 @@ mod ct { } else if str::eq(tstr, ~"?") { ty_poly } else { error(~"unknown type in conversion: " + tstr) }; - ret {ty: t, next: i + 1u}; + return {ty: t, next: i + 1u}; } } @@ -288,7 +288,7 @@ mod rt { unchecked { str::unshift_char(s, ' ') }; } } - ret unchecked { pad(cv, s, pad_signed) }; + return unchecked { pad(cv, s, pad_signed) }; } pure fn conv_uint(cv: conv, u: uint) -> ~str { let prec = get_int_precision(cv); @@ -300,17 +300,17 @@ mod rt { ty_bits { uint_to_str_prec(u, 2u, prec) } ty_octal { uint_to_str_prec(u, 8u, prec) } }; - ret unchecked { pad(cv, rs, pad_unsigned) }; + return unchecked { pad(cv, rs, pad_unsigned) }; } pure 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); + return conv_str(cv, s); } pure fn conv_char(cv: conv, c: char) -> ~str { let mut s = str::from_char(c); - ret unchecked { pad(cv, s, pad_nozero) }; + return unchecked { pad(cv, s, pad_nozero) }; } pure fn conv_str(cv: conv, s: &str) -> ~str { // For strings, precision is the maximum characters @@ -323,7 +323,7 @@ mod rt { } else { s.to_unique() } } }; - ret unchecked { pad(cv, unpadded, pad_nozero) }; + return unchecked { pad(cv, unpadded, pad_nozero) }; } pure fn conv_float(cv: conv, f: float) -> ~str { let (to_str, digits) = alt cv.precision { @@ -338,17 +338,17 @@ mod rt { s = ~" " + s; } } - ret unchecked { pad(cv, s, pad_float) }; + return unchecked { pad(cv, s, pad_float) }; } pure fn conv_poly<T>(cv: conv, v: T) -> ~str { let s = sys::log_str(v); - ret conv_str(cv, s); + return conv_str(cv, s); } // Convert an int to string with minimum number of digits. If precision is // 0 and num is 0 then the result is the empty string. pure fn int_to_str_prec(num: int, radix: uint, prec: uint) -> ~str { - ret if num < 0 { + return if num < 0 { ~"-" + uint_to_str_prec(-num as uint, radix, prec) } else { uint_to_str_prec(num as uint, radix, prec) }; } @@ -357,7 +357,7 @@ mod rt { // is 0 and num is 0 then the result is the empty string. Could move this // to uint: but it doesn't seem all that useful. pure fn uint_to_str_prec(num: uint, radix: uint, prec: uint) -> ~str { - ret if prec == 0u && num == 0u { + return if prec == 0u && num == 0u { ~"" } else { let s = uint::to_str(num, radix); @@ -370,7 +370,7 @@ mod rt { }; } pure fn get_int_precision(cv: conv) -> uint { - ret alt cv.precision { + return alt cv.precision { count_is(c) { c as uint } count_implied { 1u } }; @@ -378,19 +378,19 @@ mod rt { enum pad_mode { pad_signed, pad_unsigned, pad_nozero, pad_float } fn pad(cv: conv, &s: ~str, mode: pad_mode) -> ~str { let uwidth : uint = alt cv.width { - count_implied { ret s; } + count_implied { return s; } count_is(width) { // FIXME: width should probably be uint (see Issue #1996) width as uint } }; let strlen = str::char_len(s); - if uwidth <= strlen { ret s; } + if uwidth <= strlen { return s; } let mut padchar = ' '; let diff = uwidth - strlen; if have_flag(cv.flags, flag_left_justify) { let padstr = str::from_chars(vec::from_elem(diff, padchar)); - ret s + padstr; + return s + padstr; } let {might_zero_pad, signed} = alt mode { pad_nozero { {might_zero_pad:false, signed:false} } @@ -399,7 +399,7 @@ mod rt { pad_unsigned { {might_zero_pad:true, signed:false} } }; pure fn have_precision(cv: conv) -> bool { - ret alt cv.precision { count_implied { false } _ { true } }; + return alt cv.precision { count_implied { false } _ { true } }; } let zero_padding = { if might_zero_pad && have_flag(cv.flags, flag_left_zero_pad) && @@ -420,13 +420,13 @@ mod rt { let head = str::shift_char(s); if head == '+' || head == '-' || head == ' ' { let headstr = str::from_chars(vec::from_elem(1u, head)); - ret headstr + padstr + s; + return headstr + padstr + s; } else { str::unshift_char(s, head); } } - ret padstr + s; + return padstr + s; } pure fn have_flag(flags: u32, f: u32) -> bool { flags & f != 0 diff --git a/src/libcore/f32.rs b/src/libcore/f32.rs index 3e7bc0097f7..c9852eb67b6 100644 --- a/src/libcore/f32.rs +++ b/src/libcore/f32.rs @@ -31,38 +31,38 @@ const neg_infinity: f32 = -1.0_f32/0.0_f32; pure fn is_NaN(f: f32) -> bool { f != f } -pure fn add(x: f32, y: f32) -> f32 { ret x + y; } +pure fn add(x: f32, y: f32) -> f32 { return x + y; } -pure fn sub(x: f32, y: f32) -> f32 { ret x - y; } +pure fn sub(x: f32, y: f32) -> f32 { return x - y; } -pure fn mul(x: f32, y: f32) -> f32 { ret x * y; } +pure fn mul(x: f32, y: f32) -> f32 { return x * y; } -pure fn div(x: f32, y: f32) -> f32 { ret x / y; } +pure fn div(x: f32, y: f32) -> f32 { return x / y; } -pure fn rem(x: f32, y: f32) -> f32 { ret x % y; } +pure fn rem(x: f32, y: f32) -> f32 { return x % y; } -pure fn lt(x: f32, y: f32) -> bool { ret x < y; } +pure fn lt(x: f32, y: f32) -> bool { return x < y; } -pure fn le(x: f32, y: f32) -> bool { ret x <= y; } +pure fn le(x: f32, y: f32) -> bool { return x <= y; } -pure fn eq(x: f32, y: f32) -> bool { ret x == y; } +pure fn eq(x: f32, y: f32) -> bool { return x == y; } -pure fn ne(x: f32, y: f32) -> bool { ret x != y; } +pure fn ne(x: f32, y: f32) -> bool { return x != y; } -pure fn ge(x: f32, y: f32) -> bool { ret x >= y; } +pure fn ge(x: f32, y: f32) -> bool { return x >= y; } -pure fn gt(x: f32, y: f32) -> bool { ret x > y; } +pure fn gt(x: f32, y: f32) -> bool { return x > y; } // FIXME (#1999): replace the predicates below with llvm intrinsics or // calls to the libmath macros in the rust runtime for performance. /// Returns true if `x` is a positive number, including +0.0f320 and +Infinity pure fn is_positive(x: f32) -> bool - { ret x > 0.0f32 || (1.0f32/x) == infinity; } + { return x > 0.0f32 || (1.0f32/x) == infinity; } /// Returns true if `x` is a negative number, including -0.0f320 and -Infinity pure fn is_negative(x: f32) -> bool - { ret x < 0.0f32 || (1.0f32/x) == neg_infinity; } + { return x < 0.0f32 || (1.0f32/x) == neg_infinity; } /** * Returns true if `x` is a negative number, including -0.0f320 and -Infinity @@ -70,7 +70,7 @@ pure fn is_negative(x: f32) -> bool * This is the same as `f32::is_negative`. */ pure fn is_nonpositive(x: f32) -> bool { - ret x < 0.0f32 || (1.0f32/x) == neg_infinity; + return x < 0.0f32 || (1.0f32/x) == neg_infinity; } /** @@ -79,22 +79,22 @@ pure fn is_nonpositive(x: f32) -> bool { * This is the same as `f32::is_positive`.) */ pure fn is_nonnegative(x: f32) -> bool { - ret x > 0.0f32 || (1.0f32/x) == infinity; + return x > 0.0f32 || (1.0f32/x) == infinity; } /// Returns true if `x` is a zero number (positive or negative zero) pure fn is_zero(x: f32) -> bool { - ret x == 0.0f32 || x == -0.0f32; + return x == 0.0f32 || x == -0.0f32; } /// Returns true if `x`is an infinite number pure fn is_infinite(x: f32) -> bool { - ret x == infinity || x == neg_infinity; + return x == infinity || x == neg_infinity; } /// Returns true if `x`is a finite number pure fn is_finite(x: f32) -> bool { - ret !(is_NaN(x) || is_infinite(x)); + return !(is_NaN(x) || is_infinite(x)); } // FIXME (#1999): add is_normal, is_subnormal, and fpclassify. @@ -145,38 +145,38 @@ mod consts { } pure fn signbit(x: f32) -> int { - if is_negative(x) { ret 1; } else { ret 0; } + if is_negative(x) { return 1; } else { return 0; } } #[cfg(target_os="linux")] #[cfg(target_os="macos")] #[cfg(target_os="win32")] pure fn logarithm(n: f32, b: f32) -> f32 { - ret log2(n) / log2(b); + return log2(n) / log2(b); } #[cfg(target_os="freebsd")] pure fn logarithm(n: f32, b: f32) -> f32 { // FIXME (#2000): check if it is good to use log2 instead of ln here; // in theory should be faster since the radix is 2 - ret ln(n) / ln(b); + return ln(n) / ln(b); } #[cfg(target_os="freebsd")] pure fn log2(n: f32) -> f32 { - ret ln(n) / consts::ln_2; + return ln(n) / consts::ln_2; } impl num of num::num for f32 { - pure fn add(&&other: f32) -> f32 { ret self + other; } - pure fn sub(&&other: f32) -> f32 { ret self - other; } - pure fn mul(&&other: f32) -> f32 { ret self * other; } - pure fn div(&&other: f32) -> f32 { ret self / other; } - pure fn modulo(&&other: f32) -> f32 { ret self % other; } - pure fn neg() -> f32 { ret -self; } - - pure fn to_int() -> int { ret self as int; } - pure fn from_int(n: int) -> f32 { ret n as f32; } + pure fn add(&&other: f32) -> f32 { return self + other; } + pure fn sub(&&other: f32) -> f32 { return self - other; } + pure fn mul(&&other: f32) -> f32 { return self * other; } + pure fn div(&&other: f32) -> f32 { return self / other; } + pure fn modulo(&&other: f32) -> f32 { return self % other; } + pure fn neg() -> f32 { return -self; } + + pure fn to_int() -> int { return self as int; } + pure fn from_int(n: int) -> f32 { return n as f32; } } // diff --git a/src/libcore/f64.rs b/src/libcore/f64.rs index 9e84c432bad..550ed568be4 100644 --- a/src/libcore/f64.rs +++ b/src/libcore/f64.rs @@ -57,27 +57,27 @@ const neg_infinity: f64 = -1.0_f64/0.0_f64; pure fn is_NaN(f: f64) -> bool { f != f } -pure fn add(x: f64, y: f64) -> f64 { ret x + y; } +pure fn add(x: f64, y: f64) -> f64 { return x + y; } -pure fn sub(x: f64, y: f64) -> f64 { ret x - y; } +pure fn sub(x: f64, y: f64) -> f64 { return x - y; } -pure fn mul(x: f64, y: f64) -> f64 { ret x * y; } +pure fn mul(x: f64, y: f64) -> f64 { return x * y; } -pure fn div(x: f64, y: f64) -> f64 { ret x / y; } +pure fn div(x: f64, y: f64) -> f64 { return x / y; } -pure fn rem(x: f64, y: f64) -> f64 { ret x % y; } +pure fn rem(x: f64, y: f64) -> f64 { return x % y; } -pure fn lt(x: f64, y: f64) -> bool { ret x < y; } +pure fn lt(x: f64, y: f64) -> bool { return x < y; } -pure fn le(x: f64, y: f64) -> bool { ret x <= y; } +pure fn le(x: f64, y: f64) -> bool { return x <= y; } -pure fn eq(x: f64, y: f64) -> bool { ret x == y; } +pure fn eq(x: f64, y: f64) -> bool { return x == y; } -pure fn ne(x: f64, y: f64) -> bool { ret x != y; } +pure fn ne(x: f64, y: f64) -> bool { return x != y; } -pure fn ge(x: f64, y: f64) -> bool { ret x >= y; } +pure fn ge(x: f64, y: f64) -> bool { return x >= y; } -pure fn gt(x: f64, y: f64) -> bool { ret x > y; } +pure fn gt(x: f64, y: f64) -> bool { return x > y; } pure fn sqrt(x: f64) -> f64 { cmath::c_double::sqrt(x as libc::c_double) as f64 @@ -85,11 +85,11 @@ pure fn sqrt(x: f64) -> f64 { /// Returns true if `x` is a positive number, including +0.0f640 and +Infinity pure fn is_positive(x: f64) -> bool - { ret x > 0.0f64 || (1.0f64/x) == infinity; } + { return x > 0.0f64 || (1.0f64/x) == infinity; } /// Returns true if `x` is a negative number, including -0.0f640 and -Infinity pure fn is_negative(x: f64) -> bool - { ret x < 0.0f64 || (1.0f64/x) == neg_infinity; } + { return x < 0.0f64 || (1.0f64/x) == neg_infinity; } /** * Returns true if `x` is a negative number, including -0.0f640 and -Infinity @@ -97,7 +97,7 @@ pure fn is_negative(x: f64) -> bool * This is the same as `f64::is_negative`. */ pure fn is_nonpositive(x: f64) -> bool { - ret x < 0.0f64 || (1.0f64/x) == neg_infinity; + return x < 0.0f64 || (1.0f64/x) == neg_infinity; } /** @@ -106,22 +106,22 @@ pure fn is_nonpositive(x: f64) -> bool { * This is the same as `f64::positive`. */ pure fn is_nonnegative(x: f64) -> bool { - ret x > 0.0f64 || (1.0f64/x) == infinity; + return x > 0.0f64 || (1.0f64/x) == infinity; } /// Returns true if `x` is a zero number (positive or negative zero) pure fn is_zero(x: f64) -> bool { - ret x == 0.0f64 || x == -0.0f64; + return x == 0.0f64 || x == -0.0f64; } /// Returns true if `x`is an infinite number pure fn is_infinite(x: f64) -> bool { - ret x == infinity || x == neg_infinity; + return x == infinity || x == neg_infinity; } /// Returns true if `x`is a finite number pure fn is_finite(x: f64) -> bool { - ret !(is_NaN(x) || is_infinite(x)); + return !(is_NaN(x) || is_infinite(x)); } // FIXME (#1999): add is_normal, is_subnormal, and fpclassify @@ -172,38 +172,38 @@ mod consts { } pure fn signbit(x: f64) -> int { - if is_negative(x) { ret 1; } else { ret 0; } + if is_negative(x) { return 1; } else { return 0; } } #[cfg(target_os="linux")] #[cfg(target_os="macos")] #[cfg(target_os="win32")] pure fn logarithm(n: f64, b: f64) -> f64 { - ret log2(n) / log2(b); + return log2(n) / log2(b); } #[cfg(target_os="freebsd")] pure fn logarithm(n: f64, b: f64) -> f64 { // FIXME (#2000): check if it is good to use log2 instead of ln here; in // theory should be faster since the radix is 2 - ret ln(n) / ln(b); + return ln(n) / ln(b); } #[cfg(target_os="freebsd")] pure fn log2(n: f64) -> f64 { - ret ln(n) / consts::ln_2; + return ln(n) / consts::ln_2; } impl num of num::num for f64 { - pure fn add(&&other: f64) -> f64 { ret self + other; } - pure fn sub(&&other: f64) -> f64 { ret self - other; } - pure fn mul(&&other: f64) -> f64 { ret self * other; } - pure fn div(&&other: f64) -> f64 { ret self / other; } - pure fn modulo(&&other: f64) -> f64 { ret self % other; } - pure fn neg() -> f64 { ret -self; } - - pure fn to_int() -> int { ret self as int; } - pure fn from_int(n: int) -> f64 { ret n as f64; } + pure fn add(&&other: f64) -> f64 { return self + other; } + pure fn sub(&&other: f64) -> f64 { return self - other; } + pure fn mul(&&other: f64) -> f64 { return self * other; } + pure fn div(&&other: f64) -> f64 { return self / other; } + pure fn modulo(&&other: f64) -> f64 { return self % other; } + pure fn neg() -> f64 { return -self; } + + pure fn to_int() -> int { return self as int; } + pure fn from_int(n: int) -> f64 { return n as f64; } } // diff --git a/src/libcore/float.rs b/src/libcore/float.rs index d2efba51131..e9dd26d23ce 100644 --- a/src/libcore/float.rs +++ b/src/libcore/float.rs @@ -103,9 +103,9 @@ mod consts { * * exact - Whether to enforce the exact number of significant digits */ fn to_str_common(num: float, digits: uint, exact: bool) -> ~str { - if is_NaN(num) { ret ~"NaN"; } - if num == infinity { ret ~"inf"; } - if num == neg_infinity { ret ~"-inf"; } + if is_NaN(num) { return ~"NaN"; } + if num == infinity { return ~"inf"; } + if num == neg_infinity { return ~"-inf"; } let mut (num, sign) = if num < 0.0 { (-num, ~"-") } else { (num, ~"") }; @@ -122,7 +122,7 @@ fn to_str_common(num: float, digits: uint, exact: bool) -> ~str { // This used to return right away without rounding, as "~[-]num", // but given epsilon like in f64.rs, I don't see how the comparison // to epsilon did much when only used there. - // if (frac < epsilon && !exact) || digits == 0u { ret accum; } + // if (frac < epsilon && !exact) || digits == 0u { return accum; } // // With something better, possibly weird results like this can be avoided: // assert "3.14158999999999988262" == my_to_str_exact(3.14159, 20u); @@ -176,7 +176,7 @@ fn to_str_common(num: float, digits: uint, exact: bool) -> ~str { acc = sign + ones + ~"." + racc; } - ret acc; + return acc; } /** @@ -240,25 +240,25 @@ fn to_str(num: float, digits: uint) -> ~str { */ fn from_str(num: ~str) -> option<float> { if num == ~"inf" { - ret some(infinity as float); + return some(infinity as float); } else if num == ~"-inf" { - ret some(neg_infinity as float); + return some(neg_infinity as float); } else if num == ~"NaN" { - ret some(NaN as float); + return some(NaN as float); } let mut pos = 0u; //Current byte position in the string. //Used to walk the string in O(n). let len = str::len(num); //Length of the string, in bytes. - if len == 0u { ret none; } + if len == 0u { return none; } let mut total = 0f; //Accumulated result let mut c = 'z'; //Latest char. //The string must start with one of the following characters. alt str::char_at(num, 0u) { '-' | '+' | '0' to '9' | '.' {} - _ { ret none; } + _ { return none; } } //Determine if first char is '-'/'+'. Set [pos] and [neg] accordingly. @@ -288,7 +288,7 @@ fn from_str(num: ~str) -> option<float> { break; } _ { - ret none; + return none; } } } @@ -308,7 +308,7 @@ fn from_str(num: ~str) -> option<float> { break; } _ { - ret none; + return none; } } } @@ -353,17 +353,17 @@ fn from_str(num: ~str) -> option<float> { total = total * multiplier; } } else { - ret none; + return none; } } if(pos < len) { - ret none; + return none; } else { if(neg) { total *= -1f; } - ret some(total); + return some(total); } } @@ -386,9 +386,9 @@ fn from_str(num: ~str) -> option<float> { fn pow_with_uint(base: uint, pow: uint) -> float { if base == 0u { if pow == 0u { - ret NaN as float; + return NaN as float; } - ret 0.; + return 0.; } let mut my_pow = pow; let mut total = 1f; @@ -400,7 +400,7 @@ fn pow_with_uint(base: uint, pow: uint) -> float { my_pow /= 2u; multiplier *= multiplier; } - ret total; + return total; } pure fn is_positive(x: float) -> bool { f64::is_positive(x as f64) } @@ -420,15 +420,15 @@ pure fn cos(x: float) -> float { f64::cos(x as f64) as float } pure fn tan(x: float) -> float { f64::tan(x as f64) as float } impl num of num::num for float { - pure fn add(&&other: float) -> float { ret self + other; } - pure fn sub(&&other: float) -> float { ret self - other; } - pure fn mul(&&other: float) -> float { ret self * other; } - pure fn div(&&other: float) -> float { ret self / other; } - pure fn modulo(&&other: float) -> float { ret self % other; } - pure fn neg() -> float { ret -self; } - - pure fn to_int() -> int { ret self as int; } - pure fn from_int(n: int) -> float { ret n as float; } + pure fn add(&&other: float) -> float { return self + other; } + pure fn sub(&&other: float) -> float { return self - other; } + pure fn mul(&&other: float) -> float { return self * other; } + pure fn div(&&other: float) -> float { return self / other; } + pure fn modulo(&&other: float) -> float { return self % other; } + pure fn neg() -> float { return -self; } + + pure fn to_int() -> int { return self as int; } + pure fn from_int(n: int) -> float { return n as float; } } #[test] diff --git a/src/libcore/hash.rs b/src/libcore/hash.rs index 8f8f7dd40ed..1b2a933c67f 100644 --- a/src/libcore/hash.rs +++ b/src/libcore/hash.rs @@ -10,7 +10,7 @@ */ pure fn hash_bytes(buf: &[const u8]) -> u64 { - ret hash_bytes_keyed(buf, 0u64, 0u64); + return hash_bytes_keyed(buf, 0u64, 0u64); } pure fn hash_u64(val: u64) -> u64 { @@ -113,7 +113,7 @@ pure fn hash_bytes_keyed(buf: &[const u8], k0: u64, k1: u64) -> u64 { compress!{v0,v1,v2,v3}; compress!{v0,v1,v2,v3}; - ret v0 ^ v1 ^ v2 ^ v3; + return v0 ^ v1 ^ v2 ^ v3; } @@ -156,7 +156,7 @@ fn siphash(key0 : u64, key1 : u64) -> streaming { } st.ntail += length; - ret; + return; } let mut t = 0; @@ -229,7 +229,7 @@ fn siphash(key0 : u64, key1 : u64) -> streaming { let h = v0 ^ v1 ^ v2 ^ v3; - ret ~[ + return ~[ (h >> 0) as u8, (h >> 8) as u8, (h >> 16) as u8, @@ -252,12 +252,12 @@ fn siphash(key0 : u64, key1 : u64) -> streaming { } 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; } } @@ -275,7 +275,7 @@ fn siphash(key0 : u64, key1 : u64) -> streaming { let sh = st as streaming; sh.reset(); - ret sh; + return sh; } #[test] @@ -357,7 +357,7 @@ fn test_siphash() { fn to_hex_str(r:[u8]/8) -> ~str { let mut s = ~""; for vec::each(r) |b| { s += uint::to_str(b as uint, 16u); } - ret s; + return s; } while t < 64 { diff --git a/src/libcore/int-template.rs b/src/libcore/int-template.rs index b58e00d2e9c..46413517a5b 100644 --- a/src/libcore/int-template.rs +++ b/src/libcore/int-template.rs @@ -67,7 +67,7 @@ pure fn abs(i: T) -> T { * * radix - The base of the number */ fn parse_buf(buf: ~[u8], radix: uint) -> option<T> { - if vec::len(buf) == 0u { ret none; } + if vec::len(buf) == 0u { return none; } let mut i = vec::len(buf) - 1u; let mut start = 0u; let mut power = 1 as T; @@ -80,10 +80,10 @@ fn parse_buf(buf: ~[u8], radix: uint) -> option<T> { loop { alt char::to_digit(buf[i] as char, radix) { some(d) { n += (d as T) * power; } - none { ret none; } + none { return none; } } power *= radix as T; - if i <= start { ret some(n); } + if i <= start { return some(n); } i -= 1u; }; } @@ -109,30 +109,30 @@ fn to_str_bytes<U>(n: T, radix: uint, f: fn(v: &[u8]) -> U) -> U { } /// Convert to a string -fn str(i: T) -> ~str { ret to_str(i, 10u); } +fn str(i: T) -> ~str { return to_str(i, 10u); } impl ord of ord for T { pure fn lt(&&other: T) -> bool { - ret self < other; + return self < other; } } impl eq of eq for T { pure fn eq(&&other: T) -> bool { - ret self == other; + return self == other; } } impl num of num::num for T { - pure fn add(&&other: T) -> T { ret self + other; } - pure fn sub(&&other: T) -> T { ret self - other; } - pure fn mul(&&other: T) -> T { ret self * other; } - pure fn div(&&other: T) -> T { ret self / other; } - pure fn modulo(&&other: T) -> T { ret self % other; } - pure fn neg() -> T { ret -self; } - - pure fn to_int() -> int { ret self as int; } - pure fn from_int(n: int) -> T { ret n as T; } + pure fn add(&&other: T) -> T { return self + other; } + pure fn sub(&&other: T) -> T { return self - other; } + pure fn mul(&&other: T) -> T { return self * other; } + pure fn div(&&other: T) -> T { return self / other; } + pure fn modulo(&&other: T) -> T { return self % other; } + pure fn neg() -> T { return -self; } + + pure fn to_int() -> int { return self as int; } + pure fn from_int(n: int) -> T { return n as T; } } impl times of iter::times for T { diff --git a/src/libcore/int-template/int.rs b/src/libcore/int-template/int.rs index 07acb4be8ce..500316de2f7 100644 --- a/src/libcore/int-template/int.rs +++ b/src/libcore/int-template/int.rs @@ -7,12 +7,12 @@ const bits: T = 32 as T; const bits: T = 64 as T; /// Produce a uint suitable for use in a hash table -pure fn hash(&&x: int) -> uint { ret x as uint; } +pure fn hash(&&x: int) -> uint { return x as uint; } /// Returns `base` raised to the power of `exponent` fn pow(base: int, exponent: uint) -> int { - if exponent == 0u { ret 1; } //Not mathemtically true if ~[base == 0] - if base == 0 { ret 0; } + if exponent == 0u { return 1; } //Not mathemtically true if ~[base == 0] + if base == 0 { return 0; } let mut my_pow = exponent; let mut acc = 1; let mut multiplier = base; @@ -23,7 +23,7 @@ fn pow(base: int, exponent: uint) -> int { my_pow /= 2u; multiplier *= multiplier; } - ret acc; + return acc; } #[test] diff --git a/src/libcore/io.rs b/src/libcore/io.rs index 510be3f89b9..1831938496a 100644 --- a/src/libcore/io.rs +++ b/src/libcore/io.rs @@ -69,7 +69,7 @@ impl reader_util for reader { } // can't satisfy this char with the existing data if end > vec::len(buf) { - ret (i - 1u, end - vec::len(buf)); + return (i - 1u, end - vec::len(buf)); } let mut val = 0u; while i < end { @@ -85,7 +85,7 @@ impl reader_util for reader { << (w - 1u) * 6u - w - 1u; vec::push(chars, val as char ); } - ret (i, 0u); + return (i, 0u); } let mut buf: ~[u8] = ~[]; let mut chars: ~[char] = ~[]; @@ -115,10 +115,10 @@ impl reader_util for reader { fn read_char() -> char { let c = self.read_chars(1u); if vec::len(c) == 0u { - ret -1 as char; // FIXME will this stay valid? // #2004 + return -1 as char; // FIXME will this stay valid? // #2004 } assert(vec::len(c) == 1u); - ret c[0]; + return c[0]; } fn read_line() -> ~str { @@ -196,7 +196,7 @@ impl reader_util for reader { // Reader implementations fn convert_whence(whence: seek_style) -> i32 { - ret alt whence { + return alt whence { seek_set { 0i32 } seek_cur { 1i32 } seek_end { 2i32 } @@ -214,14 +214,14 @@ impl of reader for *libc::FILE { count as uint } } - fn read_byte() -> int { ret libc::fgetc(self) as int; } + fn read_byte() -> int { return libc::fgetc(self) as int; } fn unread_byte(byte: int) { libc::ungetc(byte as c_int, self); } - fn eof() -> bool { ret libc::feof(self) != 0 as c_int; } + fn eof() -> bool { return libc::feof(self) != 0 as c_int; } fn seek(offset: int, whence: seek_style) { assert libc::fseek(self, offset as c_long, convert_whence(whence)) == 0 as c_int; } - fn tell() -> uint { ret libc::ftell(self) as uint; } + fn tell() -> uint { return libc::ftell(self) as uint; } } // A forwarding impl of reader that also holds on to a resource for the @@ -262,7 +262,7 @@ fn file_reader(path: ~str) -> result<reader, ~str> { libc::fopen(pathbuf, modebuf) ) }); - ret if f as uint == 0u { result::err(~"error opening " + path) } + return if f as uint == 0u { result::err(~"error opening " + path) } else { result::ok(FILE_reader(f, true)) } @@ -285,10 +285,10 @@ impl of reader for byte_buf { count } fn read_byte() -> int { - if self.pos == self.len { ret -1; } + if self.pos == self.len { return -1; } let b = self.buf[self.pos]; self.pos += 1u; - ret b as int; + return b as int; } // FIXME (#2738): implement this fn unread_byte(_byte: int) { error!{"Unimplemented: unread_byte"}; fail; } @@ -530,7 +530,7 @@ fn u64_from_be_bytes(data: ~[u8], start: uint, size: uint) -> u64 { val += (data[pos] as u64) << ((sz * 8u) as u64); pos += 1u; } - ret val; + return val; } impl writer_util for writer { @@ -616,7 +616,7 @@ fn buffered_file_writer(path: ~str) -> result<writer, ~str> { libc::fopen(pathbuf, modebuf) } }; - ret if f as uint == 0u { result::err(~"error opening " + path) } + return if f as uint == 0u { result::err(~"error opening " + path) } else { result::ok(FILE_writer(f, true)) } } @@ -639,7 +639,7 @@ impl of writer for mem_buffer { if self.pos == buf_len { self.buf.push_all(v); self.pos += vlen; - ret; + return; } // FIXME #2004--use memcpy here? @@ -696,7 +696,7 @@ fn seek_in_buf(offset: int, pos: uint, len: uint, whence: seek_style) -> seek_end { bpos = blen + offset; } } if bpos < 0 { bpos = 0; } else if bpos > blen { bpos = blen; } - ret bpos as uint; + return bpos as uint; } fn read_whole_file_str(file: ~str) -> result<~str, ~str> { @@ -764,7 +764,7 @@ mod fsync { blk(res({ val: file.f, opt_level: opt_level, fsync_fn: fn@(&&file: *libc::FILE, l: level) -> int { - ret os::fsync_fd(libc::fileno(file), l) as int; + return os::fsync_fd(libc::fileno(file), l) as int; } })); } @@ -775,7 +775,7 @@ mod fsync { blk(res({ val: fd.fd, opt_level: opt_level, fsync_fn: fn@(&&fd: fd_t, l: level) -> int { - ret os::fsync_fd(fd, l) as int; + return os::fsync_fd(fd, l) as int; } })); } @@ -787,7 +787,7 @@ mod fsync { fn obj_sync(&&o: t, opt_level: option<level>, blk: fn(&&res<t>)) { blk(res({ val: o, opt_level: opt_level, - fsync_fn: fn@(&&o: t, l: level) -> int { ret o.fsync(l); } + fsync_fn: fn@(&&o: t, l: level) -> int { return o.fsync(l); } })); } } diff --git a/src/libcore/iter-trait.rs b/src/libcore/iter-trait.rs index e31824d066d..a7ba67ec1bd 100644 --- a/src/libcore/iter-trait.rs +++ b/src/libcore/iter-trait.rs @@ -41,8 +41,8 @@ impl extensions<A:copy> of iter::copyable_iter<A> for IMPL_T<A> { fn find(p: fn(A) -> bool) -> option<A> { for self.each |i| { - if p(i) { ret some(i) } + if p(i) { return some(i) } } - ret none; + return none; } } diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs index 092f69cd47a..0e635eeb002 100644 --- a/src/libcore/iter.rs +++ b/src/libcore/iter.rs @@ -39,16 +39,16 @@ fn eachi<A,IA:base_iter<A>>(self: IA, blk: fn(uint, A) -> bool) { fn all<A,IA:base_iter<A>>(self: IA, blk: fn(A) -> bool) -> bool { for self.each |a| { - if !blk(a) { ret false; } + if !blk(a) { return false; } } - ret true; + return true; } fn any<A,IA:base_iter<A>>(self: IA, blk: fn(A) -> bool) -> bool { for self.each |a| { - if blk(a) { ret true; } + if blk(a) { return true; } } - ret false; + return false; } fn filter_to_vec<A:copy,IA:base_iter<A>>(self: IA, @@ -58,7 +58,7 @@ fn filter_to_vec<A:copy,IA:base_iter<A>>(self: IA, for self.each |a| { if prd(a) { vec::push(result, a); } } - ret result; + return result; } fn map_to_vec<A:copy,B,IA:base_iter<A>>(self: IA, op: fn(A) -> B) -> ~[B] { @@ -67,7 +67,7 @@ fn map_to_vec<A:copy,B,IA:base_iter<A>>(self: IA, op: fn(A) -> B) -> ~[B] { for self.each |a| { vec::push(result, op(a)); } - ret result; + return result; } fn flat_map_to_vec<A:copy,B:copy,IA:base_iter<A>,IB:base_iter<B>>( @@ -79,7 +79,7 @@ fn flat_map_to_vec<A:copy,B:copy,IA:base_iter<A>,IB:base_iter<B>>( vec::push(result, b); } } - ret result; + return result; } fn foldl<A,B,IA:base_iter<A>>(self: IA, +b0: B, blk: fn(B, A) -> B) -> B { @@ -87,7 +87,7 @@ fn foldl<A,B,IA:base_iter<A>>(self: IA, +b0: B, blk: fn(B, A) -> B) -> B { for self.each |a| { b = blk(b, a); } - ret b; + return b; } fn to_vec<A:copy,IA:base_iter<A>>(self: IA) -> ~[A] { @@ -96,9 +96,9 @@ fn to_vec<A:copy,IA:base_iter<A>>(self: IA) -> ~[A] { fn contains<A,IA:base_iter<A>>(self: IA, x: A) -> bool { for self.each |a| { - if a == x { ret true; } + if a == x { return true; } } - ret false; + return false; } fn count<A,IA:base_iter<A>>(self: IA, x: A) -> uint { @@ -115,10 +115,10 @@ fn position<A,IA:base_iter<A>>(self: IA, f: fn(A) -> bool) -> option<uint> { let mut i = 0; for self.each |a| { - if f(a) { ret some(i); } + if f(a) { return some(i); } i += 1; } - ret none; + return none; } // note: 'rposition' would only make sense to provide with a bidirectional @@ -191,7 +191,7 @@ fn test_map_directly_on_vec() { #[test] fn test_filter_on_int_range() { fn is_even(&&i: int) -> bool { - ret (i % 2) == 0; + return (i % 2) == 0; } let l = to_vec(bind filter(bind int::range(0, 10, _), is_even, _)); @@ -201,7 +201,7 @@ fn test_filter_on_int_range() { #[test] fn test_filter_on_uint_range() { fn is_even(&&i: uint) -> bool { - ret (i % 2u) == 0u; + return (i % 2u) == 0u; } let l = to_vec(bind filter(bind uint::range(0u, 10u, _), is_even, _)); diff --git a/src/libcore/option.rs b/src/libcore/option.rs index 074dd086926..84fa8ec3544 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -23,7 +23,7 @@ pure fn get<T: copy>(opt: option<T>) -> T { * Fails if the value equals `none` */ - alt opt { some(x) { ret x; } none { fail ~"option none"; } } + alt opt { some(x) { return x; } none { fail ~"option none"; } } } pure fn expect<T: copy>(opt: option<T>, reason: ~str) -> T { @@ -116,7 +116,7 @@ pure fn unwrap<T>(-opt: option<T>) -> T { }; let liberated_value = unsafe::reinterpret_cast(*addr); unsafe::forget(opt); - ret liberated_value; + return liberated_value; } } diff --git a/src/libcore/os.rs b/src/libcore/os.rs index 4edf5af5f80..f758c1b62cb 100644 --- a/src/libcore/os.rs +++ b/src/libcore/os.rs @@ -100,7 +100,7 @@ mod win32 { } } } - ret res; + return res; } fn as_utf16_p<T>(s: ~str, f: fn(*u16) -> T) -> T { @@ -209,14 +209,14 @@ mod global_env { assert vec::len(vs) == 2u; vec::push(pairs, (vs[0], vs[1])); } - ret pairs; + return pairs; } #[cfg(unix)] fn getenv(n: ~str) -> option<~str> { unsafe { let s = str::as_c_str(n, libc::getenv); - ret if unsafe::reinterpret_cast(s) == 0 { + return if unsafe::reinterpret_cast(s) == 0 { option::none::<~str> } else { let s = unsafe::reinterpret_cast(s); @@ -267,7 +267,7 @@ mod global_env { } fn fdopen(fd: c_int) -> *FILE { - ret do as_c_charp(~"r") |modebuf| { + return do as_c_charp(~"r") |modebuf| { libc::fdopen(fd, modebuf) }; } @@ -278,7 +278,7 @@ fn fdopen(fd: c_int) -> *FILE { #[cfg(windows)] fn fsync_fd(fd: c_int, _level: io::fsync::level) -> c_int { import libc::funcs::extra::msvcrt::*; - ret commit(fd); + return commit(fd); } #[cfg(target_os = "linux")] @@ -286,8 +286,8 @@ fn fsync_fd(fd: c_int, level: io::fsync::level) -> c_int { import libc::funcs::posix01::unistd::*; alt level { io::fsync::fsync - | io::fsync::fullfsync { ret fsync(fd); } - io::fsync::fdatasync { ret fdatasync(fd); } + | io::fsync::fullfsync { return fsync(fd); } + io::fsync::fdatasync { return fdatasync(fd); } } } @@ -297,13 +297,13 @@ fn fsync_fd(fd: c_int, level: io::fsync::level) -> c_int { import libc::funcs::posix88::fcntl::*; import libc::funcs::posix01::unistd::*; alt level { - io::fsync::fsync { ret fsync(fd); } + io::fsync::fsync { return fsync(fd); } _ { // According to man fnctl, the ok retval is only specified to be !=-1 if (fcntl(F_FULLFSYNC as c_int, fd) == -1 as c_int) - { ret -1 as c_int; } + { return -1 as c_int; } else - { ret 0 as c_int; } + { return 0 as c_int; } } } } @@ -311,13 +311,13 @@ fn fsync_fd(fd: c_int, level: io::fsync::level) -> c_int { #[cfg(target_os = "freebsd")] fn fsync_fd(fd: c_int, _l: io::fsync::level) -> c_int { import libc::funcs::posix01::unistd::*; - ret fsync(fd); + return fsync(fd); } #[cfg(windows)] fn waitpid(pid: pid_t) -> c_int { - ret rustrt::rust_process_wait(pid); + return rustrt::rust_process_wait(pid); } #[cfg(unix)] @@ -327,7 +327,7 @@ fn waitpid(pid: pid_t) -> c_int { assert (waitpid(pid, ptr::mut_addr_of(status), 0 as c_int) != (-1 as c_int)); - ret status; + return status; } @@ -336,7 +336,7 @@ fn pipe() -> {in: c_int, out: c_int} { let fds = {mut in: 0 as c_int, mut out: 0 as c_int }; assert (libc::pipe(ptr::mut_addr_of(fds.in)) == (0 as c_int)); - ret {in: fds.in, out: fds.out}; + return {in: fds.in, out: fds.out}; } @@ -358,12 +358,12 @@ fn pipe() -> {in: c_int, out: c_int} { assert (res == 0 as c_int); assert (fds.in != -1 as c_int && fds.in != 0 as c_int); assert (fds.out != -1 as c_int && fds.in != 0 as c_int); - ret {in: fds.in, out: fds.out}; + return {in: fds.in, out: fds.out}; } fn dll_filename(base: ~str) -> ~str { - ret pre() + base + dll_suffix(); + return pre() + base + dll_suffix(); #[cfg(unix)] fn pre() -> ~str { ~"lib" } @@ -442,7 +442,7 @@ fn self_exe_path() -> option<path> { * Otherwise, homedir returns option::none. */ fn homedir() -> option<path> { - ret alt getenv(~"HOME") { + return alt getenv(~"HOME") { some(p) { if !str::is_empty(p) { some(p) @@ -497,7 +497,7 @@ fn walk_dir(p: path, f: fn(path) -> bool) { } } } - ret keepgoing; + return keepgoing; } } @@ -538,7 +538,7 @@ fn make_absolute(p: path) -> path { /// Creates a directory at the specified path fn make_dir(p: path, mode: c_int) -> bool { - ret mkdir(p, mode); + return mkdir(p, mode); #[cfg(windows)] fn mkdir(p: path, _mode: c_int) -> bool { @@ -600,7 +600,7 @@ fn list_dir_path(p: path) -> ~[~str] { /// Removes a directory at the specified path fn remove_dir(p: path) -> bool { - ret rmdir(p); + return rmdir(p); #[cfg(windows)] fn rmdir(p: path) -> bool { @@ -608,21 +608,21 @@ fn remove_dir(p: path) -> bool { import libc::funcs::extra::kernel32::*; import libc::types::os::arch::extra::*; import win32::*; - ret do as_utf16_p(p) |buf| { + return do as_utf16_p(p) |buf| { RemoveDirectoryW(buf) != (0 as BOOL) }; } #[cfg(unix)] fn rmdir(p: path) -> bool { - ret do as_c_charp(p) |buf| { + return do as_c_charp(p) |buf| { libc::rmdir(buf) == (0 as c_int) }; } } fn change_dir(p: path) -> bool { - ret chdir(p); + return chdir(p); #[cfg(windows)] fn chdir(p: path) -> bool { @@ -630,14 +630,14 @@ fn change_dir(p: path) -> bool { import libc::funcs::extra::kernel32::*; import libc::types::os::arch::extra::*; import win32::*; - ret do as_utf16_p(p) |buf| { + return do as_utf16_p(p) |buf| { SetCurrentDirectoryW(buf) != (0 as BOOL) }; } #[cfg(unix)] fn chdir(p: path) -> bool { - ret do as_c_charp(p) |buf| { + return do as_c_charp(p) |buf| { libc::chdir(buf) == (0 as c_int) }; } @@ -645,7 +645,7 @@ fn change_dir(p: path) -> bool { /// Copies a file from one location to another fn copy_file(from: path, to: path) -> bool { - ret do_copy_file(from, to); + return do_copy_file(from, to); #[cfg(windows)] fn do_copy_file(from: path, to: path) -> bool { @@ -653,7 +653,7 @@ fn copy_file(from: path, to: path) -> bool { import libc::funcs::extra::kernel32::*; import libc::types::os::arch::extra::*; import win32::*; - ret do as_utf16_p(from) |fromp| { + return do as_utf16_p(from) |fromp| { do as_utf16_p(to) |top| { CopyFileW(fromp, top, (0 as BOOL)) != (0 as BOOL) } @@ -668,7 +668,7 @@ fn copy_file(from: path, to: path) -> bool { } }; if istream as uint == 0u { - ret false; + return false; } let ostream = do as_c_charp(to) |top| { do as_c_charp(~"w+b") |modebuf| { @@ -677,7 +677,7 @@ fn copy_file(from: path, to: path) -> bool { }; if ostream as uint == 0u { fclose(istream); - ret false; + return false; } let mut buf : ~[mut u8] = ~[mut]; let bufsize = 8192u; @@ -702,13 +702,13 @@ fn copy_file(from: path, to: path) -> bool { } fclose(istream); fclose(ostream); - ret ok; + return ok; } } /// Deletes an existing file fn remove_file(p: path) -> bool { - ret unlink(p); + return unlink(p); #[cfg(windows)] fn unlink(p: path) -> bool { @@ -717,14 +717,14 @@ fn remove_file(p: path) -> bool { import libc::funcs::extra::kernel32::*; import libc::types::os::arch::extra::*; import win32::*; - ret do as_utf16_p(p) |buf| { + return do as_utf16_p(p) |buf| { DeleteFileW(buf) != (0 as BOOL) }; } #[cfg(unix)] fn unlink(p: path) -> bool { - ret do as_c_charp(p) |buf| { + return do as_c_charp(p) |buf| { libc::unlink(buf) == (0 as c_int) }; } diff --git a/src/libcore/path.rs b/src/libcore/path.rs index 8331284bf10..beccdcf0538 100644 --- a/src/libcore/path.rs +++ b/src/libcore/path.rs @@ -51,14 +51,14 @@ fn path_is_absolute(p: path) -> bool { #[cfg(windows)] fn path_is_absolute(p: ~str) -> bool { - ret str::char_at(p, 0u) == '/' || + return str::char_at(p, 0u) == '/' || str::char_at(p, 1u) == ':' && (str::char_at(p, 2u) == consts::path_sep || str::char_at(p, 2u) == consts::alt_path_sep); } /// Get the default path separator for the host platform -fn path_sep() -> ~str { ret str::from_char(consts::path_sep); } +fn path_sep() -> ~str { return str::from_char(consts::path_sep); } fn split_dirname_basename (pp: path) -> {dirname: ~str, basename: ~str} { alt str::rfind(pp, |ch| @@ -82,7 +82,7 @@ fn split_dirname_basename (pp: path) -> {dirname: ~str, basename: ~str} { * If the path is not prefixed with a directory, then "." is returned. */ fn dirname(pp: path) -> path { - ret split_dirname_basename(pp).dirname; + return split_dirname_basename(pp).dirname; } /** @@ -95,7 +95,7 @@ fn dirname(pp: path) -> path { * with a path separator then an empty path is returned. */ fn basename(pp: path) -> path { - ret split_dirname_basename(pp).basename; + return split_dirname_basename(pp).basename; } /** @@ -119,7 +119,7 @@ fn connect(pre: path, post: path) -> path { str::unsafe::shift_byte(post_); } } - ret pre_ + path_sep() + post_; + return pre_ + path_sep() + post_; } /** @@ -128,7 +128,7 @@ fn connect(pre: path, post: path) -> path { * Inserts path separators as needed. */ fn connect_many(paths: ~[path]) -> path { - ret if vec::len(paths) == 1u { + return if vec::len(paths) == 1u { paths[0] } else { let rest = vec::slice(paths, 1u, vec::len(paths)); @@ -231,7 +231,7 @@ fn normalize(p: path) -> path { s }; - ret s; + return s; fn strip_dots(s: ~[path]) -> ~[path] { vec::filter_map(s, |elem| @@ -244,7 +244,7 @@ fn normalize(p: path) -> path { fn rollup_doubledots(s: ~[path]) -> ~[path] { if vec::is_empty(s) { - ret ~[]; + return ~[]; } let mut t = ~[]; @@ -267,7 +267,7 @@ fn normalize(p: path) -> path { vec::push(t, ~".."); skip -= 1; } - ret t; + return t; } #[cfg(unix)] @@ -292,9 +292,9 @@ fn normalize(p: path) -> path { let last = orig[str::len(orig) - 1u]; if last == consts::path_sep as u8 || last == consts::path_sep as u8 { - ret newp + path_sep(); + return newp + path_sep(); } else { - ret newp; + return newp; } } } diff --git a/src/libcore/pipes.rs b/src/libcore/pipes.rs index 429651616a7..bc8785b45ac 100644 --- a/src/libcore/pipes.rs +++ b/src/libcore/pipes.rs @@ -390,11 +390,11 @@ fn try_recv<T: send, Tbuffer: send>(-p: recv_packet_buffered<T, Tbuffer>) let mut payload = none; payload <-> p.payload; p.header.state = empty; - ret some(option::unwrap(payload)) + return some(option::unwrap(payload)) } terminated { assert old_state == terminated; - ret none; + return none; } } first = false; @@ -906,7 +906,7 @@ struct port_set<T: send> : recv<T> { // It'd be nice to use self.port.each, but that version isn't // pure. for vec::each(self.ports) |p| { - if p.peek() { ret true } + if p.peek() { return true } } false } diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs index cc60d18af21..d82c46832fe 100644 --- a/src/libcore/ptr.rs +++ b/src/libcore/ptr.rs @@ -79,7 +79,7 @@ unsafe fn buf_len<T>(buf: **T) -> uint { unsafe fn position<T>(buf: *T, f: fn(T) -> bool) -> uint { let mut i = 0u; loop { - if f(*offset(buf, i)) { ret i; } + if f(*offset(buf, i)) { return i; } else { i += 1u; } } } diff --git a/src/libcore/rand.rs b/src/libcore/rand.rs index cda205a98b5..82a88e6718f 100644 --- a/src/libcore/rand.rs +++ b/src/libcore/rand.rs @@ -110,7 +110,7 @@ impl extensions for rng { let u2 = self.next() as f64; let u3 = self.next() as f64; const scale : f64 = (u32::max_value as f64) + 1.0f64; - ret ((u1 / scale + u2) / scale + u3) / scale; + return ((u1 / scale + u2) / scale + u3) / scale; } /// Return a random char @@ -195,14 +195,14 @@ impl extensions for rng { total += item.weight; } if total == 0u { - ret none; + return none; } let chosen = self.gen_uint_range(0u, total); let mut so_far = 0u; for v.each |item| { so_far += item.weight; if so_far > chosen { - ret some(item.item); + return some(item.item); } } unreachable(); @@ -226,7 +226,7 @@ impl extensions for rng { fn shuffle<T:copy>(values: ~[T]) -> ~[T] { let mut m = vec::to_mut(values); self.shuffle_mut(m); - ret vec::from_mut(m); + return vec::from_mut(m); } /// Shuffle a mutable vec in place @@ -249,7 +249,7 @@ class rand_res { } impl of rng for @rand_res { - fn next() -> u32 { ret rustrt::rand_next((*self).c); } + fn next() -> u32 { return rustrt::rand_next((*self).c); } } /// Create a new random seed for seeded_rng diff --git a/src/libcore/result.rs b/src/libcore/result.rs index 2e9fd977536..58a4c558050 100644 --- a/src/libcore/result.rs +++ b/src/libcore/result.rs @@ -244,8 +244,8 @@ impl extensions<T:copy, E:copy> for result<T,E> { * checking for overflow: * * fn inc_conditionally(x: uint) -> result<uint,str> { - * if x == uint::max_value { ret err("overflow"); } - * else { ret ok(x+1u); } + * if x == uint::max_value { return err("overflow"); } + * else { return ok(x+1u); } * } * map(~[1u, 2u, 3u], inc_conditionally).chain {|incd| * assert incd == ~[2u, 3u, 4u]; @@ -259,10 +259,10 @@ fn map_vec<T,U:copy,V:copy>( for vec::each(ts) |t| { alt op(t) { ok(v) { vec::push(vs, v); } - err(u) { ret err(u); } + err(u) { return err(u); } } } - ret ok(vs); + return ok(vs); } fn map_opt<T,U:copy,V:copy>( @@ -299,11 +299,11 @@ fn map_vec2<S,T,U:copy,V:copy>(ss: ~[S], ts: ~[T], while i < n { alt op(ss[i],ts[i]) { ok(v) { vec::push(vs, v); } - err(u) { ret err(u); } + err(u) { return err(u); } } i += 1u; } - ret ok(vs); + return ok(vs); } /** @@ -320,11 +320,11 @@ fn iter_vec2<S,T,U:copy>(ss: ~[S], ts: ~[T], while i < n { alt op(ss[i],ts[i]) { ok(()) { } - err(u) { ret err(u); } + err(u) { return err(u); } } i += 1u; } - ret ok(()); + return ok(()); } /// Unwraps a result, assuming it is an `ok(T)` @@ -336,7 +336,7 @@ fn unwrap<T, U>(-res: result<T, U>) -> T { }; let liberated_value = unsafe::reinterpret_cast(*addr); unsafe::forget(res); - ret liberated_value; + return liberated_value; } } diff --git a/src/libcore/rt.rs b/src/libcore/rt.rs index 8990891112d..0b4038656ef 100644 --- a/src/libcore/rt.rs +++ b/src/libcore/rt.rs @@ -34,7 +34,7 @@ fn rt_fail(expr: *c_char, file: *c_char, line: size_t) { #[rt(exchange_malloc)] fn rt_exchange_malloc(td: *c_char, size: uintptr_t) -> *c_char { - ret rustrt::rust_upcall_exchange_malloc(td, size); + return rustrt::rust_upcall_exchange_malloc(td, size); } // NB: Calls to free CANNOT be allowed to fail, as throwing an exception from @@ -47,7 +47,7 @@ fn rt_exchange_free(ptr: *c_char) { #[rt(malloc)] fn rt_malloc(td: *c_char, size: uintptr_t) -> *c_char { - ret rustrt::rust_upcall_malloc(td, size); + return rustrt::rust_upcall_malloc(td, size); } // NB: Calls to free CANNOT be allowed to fail, as throwing an exception from diff --git a/src/libcore/run.rs b/src/libcore/run.rs index 09dbf2c37c3..bb604d7748a 100644 --- a/src/libcore/run.rs +++ b/src/libcore/run.rs @@ -169,7 +169,7 @@ fn run_program(prog: ~str, args: ~[~str]) -> int { let pid = spawn_process(prog, args, none, none, 0i32, 0i32, 0i32); if pid == -1 as pid_t { fail; } - ret waitpid(pid); + return waitpid(pid); } /** @@ -216,10 +216,10 @@ fn start_program(prog: ~str, args: ~[~str]) -> program { } } fn finish_repr(r: prog_repr) -> int { - if r.finished { ret 0; } + if r.finished { return 0; } r.finished = true; close_repr_input(r); - ret waitpid(r.pid); + return waitpid(r.pid); } fn destroy_repr(r: prog_repr) { finish_repr(r); @@ -233,7 +233,7 @@ fn start_program(prog: ~str, args: ~[~str]) -> program { } impl of program for prog_res { - fn get_id() -> pid_t { ret self.r.pid; } + fn get_id() -> pid_t { return self.r.pid; } fn input() -> io::writer { io::fd_writer(self.r.in_fd, false) } fn output() -> io::reader { io::FILE_reader(self.r.out_file, false) } fn err() -> io::reader { io::FILE_reader(self.r.err_file, false) } @@ -246,7 +246,7 @@ fn start_program(prog: ~str, args: ~[~str]) -> program { out_file: os::fdopen(pipe_output.in), err_file: os::fdopen(pipe_err.in), mut finished: false}; - ret prog_res(repr) as program; + return prog_res(repr) as program; } fn read_all(rd: io::reader) -> ~str { @@ -255,7 +255,7 @@ fn read_all(rd: io::reader) -> ~str { let bytes = rd.read_bytes(4096u); buf += str::from_bytes(bytes); } - ret buf; + return buf; } /** @@ -323,7 +323,7 @@ fn program_output(prog: ~str, args: ~[~str]) -> }; count -= 1; }; - ret {status: status, out: outs, err: errs}; + return {status: status, out: outs, err: errs}; } fn writeclose(fd: c_int, s: ~str) { @@ -345,12 +345,12 @@ fn readclose(fd: c_int) -> ~str { buf += str::from_bytes(bytes); } os::fclose(file); - ret buf; + return buf; } /// Waits for a process to exit and returns the exit code fn waitpid(pid: pid_t) -> int { - ret waitpid_os(pid); + return waitpid_os(pid); #[cfg(windows)] fn waitpid_os(pid: pid_t) -> int { @@ -382,7 +382,7 @@ fn waitpid(pid: pid_t) -> int { } let status = os::waitpid(pid); - ret if WIFEXITED(status) { + return if WIFEXITED(status) { WEXITSTATUS(status) as int } else { 1 diff --git a/src/libcore/send_map.rs b/src/libcore/send_map.rs index 40eae90e96b..df019f57397 100644 --- a/src/libcore/send_map.rs +++ b/src/libcore/send_map.rs @@ -80,7 +80,7 @@ mod linear { unsafe{ // argh. log not considered pure. debug!{"next_bucket(%?, %?) = %?", idx, len_buckets, n}; } - ret n; + return n; } #[inline(always)] @@ -90,11 +90,11 @@ mod linear { let mut idx = start_idx; loop { if !op(idx) { - ret idx; + return idx; } idx = self.next_bucket(idx, len_buckets); if idx == start_idx { - ret start_idx; + return start_idx; } } } @@ -118,15 +118,15 @@ mod linear { alt buckets[i] { some(bkt) { if bkt.hash == hash && self.eqfn(k, &bkt.key) { - ret found_entry(i); + return found_entry(i); } } none => { - ret found_hole(i); + return found_hole(i); } } }; - ret table_full; + return table_full; } } @@ -167,13 +167,13 @@ mod linear { k, v, idx, hash}; self.buckets[idx] = some({hash: hash, key: k, value: v}); self.size += 1; - ret true; + return true; } found_entry(idx) => { debug!{"insert overwrite (%?->%?) at idx %?, hash %?", k, v, idx, hash}; self.buckets[idx] = some({hash: hash, key: k, value: v}); - ret false; + return false; } } } @@ -213,7 +213,7 @@ mod linear { let mut idx = alt self.bucket_for_key(self.buckets, k) { table_full | found_hole(_) => { - ret false; + return false; } found_entry(idx) => { idx @@ -230,7 +230,7 @@ mod linear { idx = self.next_bucket(idx, len_buckets); } self.size -= 1; - ret true; + return true; } } @@ -339,7 +339,7 @@ mod test { pure fn uint_eq(x: &uint, y: &uint) -> bool { *x == *y } fn int_linear_map<V>() -> linear_map<uint,V> { - ret linear_map(uint_hash, uint_eq); + return linear_map(uint_hash, uint_eq); } #[test] diff --git a/src/libcore/stackwalk.rs b/src/libcore/stackwalk.rs index 3539f411006..939cdfade82 100644 --- a/src/libcore/stackwalk.rs +++ b/src/libcore/stackwalk.rs @@ -51,7 +51,7 @@ fn test_simple() { #[test] fn test_simple_deep() { fn run(i: int) { - if i == 0 { ret } + if i == 0 { return } for walk_stack |_frame| { unsafe { diff --git a/src/libcore/str.rs b/src/libcore/str.rs index 6c443dc294a..cdc3a826b67 100644 --- a/src/libcore/str.rs +++ b/src/libcore/str.rs @@ -128,7 +128,7 @@ Section: Creating a string */ pure fn from_bytes(vv: &[const u8]) -> ~str { assert is_utf8(vv); - ret unsafe { unsafe::from_bytes(vv) }; + return unsafe { unsafe::from_bytes(vv) }; } /// Copy a slice into a new unique str @@ -229,7 +229,7 @@ fn push_char(&s: ~str, ch: char) { pure fn from_char(ch: char) -> ~str { let mut buf = ~""; unchecked { push_char(buf, ch); } - ret buf; + return buf; } /// Convert a vector of chars to a string @@ -239,7 +239,7 @@ pure fn from_chars(chs: &[char]) -> ~str { reserve(buf, chs.len()); for vec::each(chs) |ch| { push_char(buf, ch); } } - ret buf; + return buf; } /// Appends a string slice to the back of a string, without overallocating @@ -282,7 +282,7 @@ pure fn append(+lhs: ~str, rhs: &str) -> ~str { unchecked { push_str_no_overallocate(v, rhs); } - ret v; + return v; } @@ -290,7 +290,7 @@ pure fn append(+lhs: ~str, rhs: &str) -> ~str { pure fn concat(v: &[~str]) -> ~str { let mut s: ~str = ~""; for vec::each(v) |ss| { unchecked { push_str(s, ss) }; } - ret s; + return s; } /// Concatenate a vector of strings, placing a given separator between each @@ -300,7 +300,7 @@ pure fn connect(v: &[~str], sep: &str) -> ~str { if first { first = false; } else { unchecked { push_str(s, sep); } } unchecked { push_str(s, ss) }; } - ret s; + return s; } /* @@ -319,7 +319,7 @@ fn pop_char(&s: ~str) -> char { assert end > 0u; let {ch, prev} = char_range_at_reverse(s, end); unsafe { unsafe::set_len(s, prev); } - ret ch; + return ch; } /** @@ -332,7 +332,7 @@ fn pop_char(&s: ~str) -> char { fn shift_char(&s: ~str) -> char { let {ch, next} = char_range_at(s, 0u); s = unsafe { unsafe::slice_bytes(s, next, len(s)) }; - ret ch; + return ch; } /// Prepend a char to a string @@ -376,7 +376,7 @@ pure fn bytes(s: &str) -> ~[u8] { let mut s_copy = from_slice(s); let mut v: ~[u8] = ::unsafe::transmute(s_copy); vec::unsafe::set_len(v, len(s)); - ret v; + return v; } } @@ -397,7 +397,7 @@ pure fn chars(s: &str) -> ~[char] { unchecked { vec::push(buf, ch); } i = next; } - ret buf; + return buf; } /** @@ -643,16 +643,16 @@ pure fn eq(&&a: ~str, &&b: ~str) -> bool { // shape code. let a_len = a.len(); let b_len = b.len(); - if a_len != b_len { ret false; } + if a_len != b_len { return false; } let mut end = uint::min(a_len, b_len); let mut i = 0u; while i < end { - if a[i] != b[i] { ret false; } + if a[i] != b[i] { return false; } i += 1u; } - ret true; + return true; } /// Bytewise less than or equal @@ -663,7 +663,7 @@ pure fn hash(&&s: ~str) -> uint { let x = do as_bytes(s) |bytes| { hash::hash_bytes(bytes) }; - ret x as uint; + return x as uint; } /* @@ -855,10 +855,10 @@ pure fn find_char_between(s: &str, c: char, start: uint, end: uint) let mut i = start; let b = c as u8; while i < end { - if s[i] == b { ret some(i); } + if s[i] == b { return some(i); } i += 1u; } - ret none; + return none; } else { find_between(s, start, end, |x| x == c) } @@ -935,9 +935,9 @@ pure fn rfind_char_between(s: &str, c: char, start: uint, end: uint) let b = c as u8; while i > end { i -= 1u; - if s[i] == b { ret some(i); } + if s[i] == b { return some(i); } } - ret none; + return none; } else { rfind_between(s, start, end, |x| x == c) } @@ -1016,10 +1016,10 @@ pure fn find_between(s: &str, start: uint, end: uint, f: fn(char) -> bool) let mut i = start; while i < end { let {ch, next} = char_range_at(s, i); - if f(ch) { ret some(i); } + if f(ch) { return some(i); } i = next; } - ret none; + return none; } /** @@ -1095,17 +1095,17 @@ pure fn rfind_between(s: &str, start: uint, end: uint, f: fn(char) -> bool) let mut i = start; while i > end { let {ch, prev} = char_range_at_reverse(s, i); - if f(ch) { ret some(prev); } + if f(ch) { return some(prev); } i = prev; } - ret none; + return none; } // Utility used by various searching functions pure fn match_at(haystack: &a/str, needle: &b/str, at: uint) -> bool { let mut i = at; - for each(needle) |c| { if haystack[i] != c { ret false; } i += 1u; } - ret true; + for each(needle) |c| { if haystack[i] != c { return false; } i += 1u; } + return true; } /** @@ -1175,16 +1175,16 @@ pure fn find_str_between(haystack: &a/str, needle: &b/str, start: uint, // See Issue #1932 for why this is a naive search assert end <= len(haystack); let needle_len = len(needle); - if needle_len == 0u { ret some(start); } - if needle_len > end { ret none; } + if needle_len == 0u { return some(start); } + if needle_len > end { return none; } let mut i = start; let e = end - needle_len; while i <= e { - if match_at(haystack, needle, i) { ret some(i); } + if match_at(haystack, needle, i) { return some(i); } i += 1u; } - ret none; + return none; } /** @@ -1248,8 +1248,8 @@ Section: String properties /// Determines if a string contains only ASCII characters pure fn is_ascii(s: &str) -> bool { let mut i: uint = len(s); - while i > 0u { i -= 1u; if !u8::is_ascii(s[i]) { ret false; } } - ret true; + while i > 0u { i -= 1u; if !u8::is_ascii(s[i]) { return false; } } + return true; } /// Returns true if the string has length 0 @@ -1264,7 +1264,7 @@ pure fn is_not_empty(s: &str) -> bool { !is_empty(s) } * Whitespace characters are determined by `char::is_whitespace` */ pure fn is_whitespace(s: &str) -> bool { - ret all(s, char::is_whitespace); + return all(s, char::is_whitespace); } /** @@ -1273,7 +1273,7 @@ pure fn is_whitespace(s: &str) -> bool { * Alphanumeric characters are determined by `char::is_alphanumeric` */ fn is_alphanumeric(s: &str) -> bool { - ret all(s, char::is_alphanumeric); + return all(s, char::is_alphanumeric); } /// Returns the string length/size in bytes not counting the null terminator @@ -1294,16 +1294,16 @@ pure fn is_utf8(v: &[const u8]) -> bool { let total = vec::len::<u8>(v); while i < total { let mut chsize = utf8_char_width(v[i]); - if chsize == 0u { ret false; } - if i + chsize > total { ret false; } + if chsize == 0u { return false; } + if i + chsize > total { return false; } i += 1u; while chsize > 1u { - if v[i] & 192u8 != tag_cont_u8 { ret false; } + if v[i] & 192u8 != tag_cont_u8 { return false; } i += 1u; chsize -= 1u; } } - ret true; + return true; } /// Determines if a vector of `u16` contains valid UTF-16 @@ -1317,14 +1317,14 @@ pure fn is_utf16(v: &[u16]) -> bool { i += 1u; } else { - if i+1u < len { ret false; } + if i+1u < len { return false; } let u2 = v[i+1u]; - if u < 0xD7FF_u16 || u > 0xDBFF_u16 { ret false; } - if u2 < 0xDC00_u16 || u2 > 0xDFFF_u16 { ret false; } + if u < 0xD7FF_u16 || u > 0xDBFF_u16 { return false; } + if u2 < 0xDC00_u16 || u2 > 0xDFFF_u16 { return false; } i += 2u; } } - ret true; + return true; } /// Converts to a vector of `u16` encoded as UTF-16 @@ -1347,7 +1347,7 @@ pure fn to_utf16(s: &str) -> ~[u16] { vec::push_all(u, ~[w1, w2]) } } - ret u; + return u; } pure fn utf16_chars(v: &[u16], f: fn(char)) { @@ -1381,7 +1381,7 @@ pure fn from_utf16(v: &[u16]) -> ~str { reserve(buf, vec::len(v)); utf16_chars(v, |ch| push_char(buf, ch)); } - ret buf; + return buf; } @@ -1407,7 +1407,7 @@ pure fn count_chars(s: &str, start: uint, end: uint) -> uint { len += 1u; i = next; } - ret len; + return len; } /// Counts the number of bytes taken by the `n` in `s` starting from `start`. @@ -1427,14 +1427,14 @@ pure fn count_bytes(s: &b/str, start: uint, n: uint) -> uint { /// Given a first byte, determine how many bytes are in this UTF-8 character pure fn utf8_char_width(b: u8) -> uint { let byte: uint = b as uint; - if byte < 128u { ret 1u; } + if byte < 128u { return 1u; } // Not a valid start byte - if byte < 192u { ret 0u; } - if byte < 224u { ret 2u; } - if byte < 240u { ret 3u; } - if byte < 248u { ret 4u; } - if byte < 252u { ret 5u; } - ret 6u; + if byte < 192u { return 0u; } + if byte < 224u { return 2u; } + if byte < 240u { return 3u; } + if byte < 248u { return 4u; } + if byte < 252u { return 5u; } + return 6u; } /** @@ -1442,9 +1442,9 @@ pure fn utf8_char_width(b: u8) -> uint { * character sequence. */ pure fn is_char_boundary(s: &str, index: uint) -> bool { - if index == len(s) { ret true; } + if index == len(s) { return true; } let b = s[index]; - ret b < 128u8 || b >= 192u8; + return b < 128u8 || b >= 192u8; } /** @@ -1500,7 +1500,7 @@ pure 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); - if w == 1u { ret {ch: b0 as char, next: i + 1u}; } + if w == 1u { return {ch: b0 as char, next: i + 1u}; } let mut val = 0u; let end = i + w; let mut i = i + 1u; @@ -1515,11 +1515,11 @@ pure fn char_range_at(s: &str, i: uint) -> {ch: char, next: uint} { // the first to clip off the marker bits at the left of the byte, and then // a second (as uint) to get it to the right position. val += ((b0 << ((w + 1u) as u8)) as uint) << ((w - 1u) * 6u - w - 1u); - ret {ch: val as char, next: i}; + return {ch: val as char, next: i}; } /// Pluck a character out of a string -pure fn char_at(s: &str, i: uint) -> char { ret char_range_at(s, i).ch; } +pure fn char_at(s: &str, i: uint) -> char { return char_range_at(s, i).ch; } /** * Given a byte position and a str, return the previous char and its position @@ -1540,7 +1540,7 @@ pure fn char_range_at_reverse(ss: &str, start: uint) prev -= 1u; let ch = char_at(ss, prev); - ret {ch:ch, prev:prev}; + return {ch:ch, prev:prev}; } /** @@ -1571,10 +1571,10 @@ pure fn all_between(s: &str, start: uint, end: uint, let mut i = start; while i < end { let {ch, next} = char_range_at(s, i); - if !it(ch) { ret false; } + if !it(ch) { return false; } i = next; } - ret true; + return true; } /** @@ -1747,7 +1747,7 @@ pure fn escape_default(s: &str) -> ~str { reserve_at_least(out, str::len(s)); chars_iter(s, |c| push_str(out, char::escape_default(c))); } - ret out; + return out; } /// Escape each char in `s` with char::escape_unicode. @@ -1757,7 +1757,7 @@ pure fn escape_unicode(s: &str) -> ~str { reserve_at_least(out, str::len(s)); chars_iter(s, |c| push_str(out, char::escape_unicode(c))); } - ret out; + return out; } /// Unsafe operations @@ -1781,7 +1781,7 @@ mod unsafe { i += 1u; curr = ptr::offset(buf, i); } - ret from_buf_len(buf, i); + return from_buf_len(buf, i); } /// Create a Rust string from a *u8 buffer of the given length @@ -1793,7 +1793,7 @@ mod unsafe { vec::push(v, 0u8); assert is_utf8(v); - ret ::unsafe::transmute(v); + return ::unsafe::transmute(v); } /// Create a Rust string from a null-terminated C string @@ -1861,7 +1861,7 @@ mod unsafe { assert (len > 0u); let b = s[len - 1u]; unsafe { set_len(s, len - 1u) }; - ret b; + return b; } /// Removes the first byte from a string and returns it. (Not UTF-8 safe). @@ -1870,7 +1870,7 @@ mod unsafe { assert (len > 0u); let b = s[0]; s = unsafe { unsafe::slice_bytes(s, 1u, len) }; - ret b; + return b; } /// Sets the length of the string and adds the null terminator @@ -2405,13 +2405,13 @@ mod tests { let mut i = 0; let mut rs = ~""; while i < 100000 { push_str(rs, ~"aaaaaaaaaa"); i += 1; } - ret rs; + return rs; } fn half_a_million_letter_a() -> ~str { let mut i = 0; let mut rs = ~""; while i < 100000 { push_str(rs, ~"aaaaa"); i += 1; } - ret rs; + return rs; } assert eq(half_a_million_letter_a(), unsafe::slice_bytes(a_million_letter_a(), @@ -2516,13 +2516,13 @@ mod tests { let mut i = 0; let mut rs = ~""; while i < 100000 { push_str(rs, ~"华华华华华华华华华华"); i += 1; } - ret rs; + return rs; } fn half_a_million_letter_X() -> ~str { let mut i = 0; let mut rs = ~""; while i < 100000 { push_str(rs, ~"华华华华华"); i += 1; } - ret rs; + return rs; } assert eq(half_a_million_letter_X(), slice(a_million_letter_X(), 0u, 3u * 500000u)); diff --git a/src/libcore/task.rs b/src/libcore/task.rs index 6b356819340..b39f384ae0a 100644 --- a/src/libcore/task.rs +++ b/src/libcore/task.rs @@ -833,7 +833,7 @@ fn spawn_raw(opts: task_opts, +f: fn~()) { // if parent_group { // if !enlist_in_group(parent_group) { // leave_group(child_group); // Roll back - // ret; // Parent group failed. Don't run child's f(). + // return; // Parent group failed. Don't run child's f(). // } // } // stash_taskgroup_data_in_TLS(child_group, parent_group); @@ -1024,7 +1024,7 @@ unsafe fn local_get_helper<T: owned>( do_pop: bool) -> option<@T> { let map = get_task_local_map(task); - // Interpret our findings from the map + // Interpreturn our findings from the map do local_data_lookup(map, key).map |result| { // A reference count magically appears on 'data' out of thin air. It // was referenced in the local_data box, though, not here, so before @@ -1743,7 +1743,7 @@ fn test_child_doesnt_ref_parent() { // climbing the task tree to dereference each ancestor. (See #1789) const generations: uint = 128; fn child_no(x: uint) -> fn~() { - ret || { + return || { if x < generations { task::spawn(child_no(x+1)); } diff --git a/src/libcore/tuple.rs b/src/libcore/tuple.rs index 681d94c475b..a92ca63dd8b 100644 --- a/src/libcore/tuple.rs +++ b/src/libcore/tuple.rs @@ -11,19 +11,19 @@ impl extensions <T:copy, U:copy> of tuple_ops<T,U> for (T, U) { /// Return the first element of self pure fn first() -> T { let (t, _) = self; - ret t; + return t; } /// Return the second element of self pure fn second() -> U { let (_, u) = self; - ret u; + return u; } /// Return the results of swapping the two elements of self pure fn swap() -> (U, T) { let (t, u) = self; - ret (u, t); + return (u, t); } } diff --git a/src/libcore/uint-template.rs b/src/libcore/uint-template.rs index 3a420d103a3..13746df2621 100644 --- a/src/libcore/uint-template.rs +++ b/src/libcore/uint-template.rs @@ -54,26 +54,26 @@ pure fn compl(i: T) -> T { impl ord of ord for T { pure fn lt(&&other: T) -> bool { - ret self < other; + return self < other; } } impl eq of eq for T { pure fn eq(&&other: T) -> bool { - ret self == other; + return self == other; } } impl num of num::num for T { - pure fn add(&&other: T) -> T { ret self + other; } - pure fn sub(&&other: T) -> T { ret self - other; } - pure fn mul(&&other: T) -> T { ret self * other; } - pure fn div(&&other: T) -> T { ret self / other; } - pure fn modulo(&&other: T) -> T { ret self % other; } - pure fn neg() -> T { ret -self; } - - pure fn to_int() -> int { ret self as int; } - pure fn from_int(n: int) -> T { ret n as T; } + pure fn add(&&other: T) -> T { return self + other; } + pure fn sub(&&other: T) -> T { return self - other; } + pure fn mul(&&other: T) -> T { return self * other; } + pure fn div(&&other: T) -> T { return self / other; } + pure fn modulo(&&other: T) -> T { return self % other; } + pure fn neg() -> T { return -self; } + + pure fn to_int() -> int { return self as int; } + pure fn from_int(n: int) -> T { return n as T; } } /** @@ -89,17 +89,17 @@ impl num of num::num for T { * `buf` must not be empty */ fn parse_buf(buf: ~[u8], radix: uint) -> option<T> { - if vec::len(buf) == 0u { ret none; } + if vec::len(buf) == 0u { return none; } let mut i = vec::len(buf) - 1u; let mut power = 1u as T; let mut n = 0u as T; loop { alt char::to_digit(buf[i] as char, radix) { some(d) { n += d as T * power; } - none { ret none; } + none { return none; } } power *= radix as T; - if i == 0u { ret some(n); } + if i == 0u { return some(n); } i -= 1u; }; } @@ -138,16 +138,16 @@ fn from_str(s: ~str) -> option<T> { parse_buf(str::bytes(s), 10u) } /// Parse a string as an unsigned integer. fn from_str_radix(buf: ~str, radix: u64) -> option<u64> { - if str::len(buf) == 0u { ret none; } + if str::len(buf) == 0u { return none; } let mut i = str::len(buf) - 1u; let mut power = 1u64, n = 0u64; loop { alt char::to_digit(buf[i] as char, radix as uint) { some(d) { n += d as u64 * power; } - none { ret none; } + none { return none; } } power *= radix; - if i == 0u { ret some(n); } + if i == 0u { return some(n); } i -= 1u; }; } @@ -233,7 +233,7 @@ pure fn to_str_bytes<U>(neg: bool, num: T, radix: uint, } /// Convert to a string -fn str(i: T) -> ~str { ret to_str(i, 10u); } +fn str(i: T) -> ~str { return to_str(i, 10u); } #[test] fn test_to_str() { diff --git a/src/libcore/uint-template/u8.rs b/src/libcore/uint-template/u8.rs index bc73536c4a4..96b2dd6d9c3 100644 --- a/src/libcore/uint-template/u8.rs +++ b/src/libcore/uint-template/u8.rs @@ -3,4 +3,4 @@ type T = u8; // Type-specific functions here. These must be reexported by the // parent module so that they appear in core::u8 and not core::u8::u8; -pure fn is_ascii(x: T) -> bool { ret 0 as T == x & 128 as T; } +pure fn is_ascii(x: T) -> bool { return 0 as T == x & 128 as T; } diff --git a/src/libcore/uint-template/uint.rs b/src/libcore/uint-template/uint.rs index 10d91d73e75..401cb8c04c4 100644 --- a/src/libcore/uint-template/uint.rs +++ b/src/libcore/uint-template/uint.rs @@ -14,8 +14,8 @@ type T = uint; */ pure fn div_ceil(x: uint, y: uint) -> uint { let div = div(x, y); - if x % y == 0u { ret div;} - else { ret div + 1u; } + if x % y == 0u { return div;} + else { return div + 1u; } } /** @@ -32,8 +32,8 @@ pure fn div_ceil(x: uint, y: uint) -> uint { */ pure fn div_round(x: uint, y: uint) -> uint { let div = div(x, y); - if x % y * 2u < y { ret div;} - else { ret div + 1u; } + if x % y * 2u < y { return div;} + else { return div + 1u; } } /** @@ -51,10 +51,10 @@ pure fn div_round(x: uint, y: uint) -> uint { * The smallest integer `q` such that `x/y <= q`. This * is either `x/y` or `x/y + 1`. */ -pure fn div_floor(x: uint, y: uint) -> uint { ret x / y; } +pure fn div_floor(x: uint, y: uint) -> uint { return x / y; } /// Produce a uint suitable for use in a hash table -pure fn hash(&&x: uint) -> uint { ret x; } +pure fn hash(&&x: uint) -> uint { return x; } /** * Iterate over the range [`lo`..`hi`), or stop when requested @@ -74,10 +74,10 @@ pure fn hash(&&x: uint) -> uint { ret x; } pure fn iterate(lo: uint, hi: uint, it: fn(uint) -> bool) -> bool { let mut i = lo; while i < hi { - if (!it(i)) { ret false; } + if (!it(i)) { return false; } i += 1u; } - ret true; + return true; } /// Returns the smallest power of 2 greater than or equal to `n` @@ -87,7 +87,7 @@ fn next_power_of_two(n: uint) -> uint { let mut tmp: uint = n - 1u; let mut shift: uint = 1u; while shift <= halfbits { tmp |= tmp >> shift; shift <<= 1u; } - ret tmp + 1u; + return tmp + 1u; } #[test] diff --git a/src/libcore/unicode.rs b/src/libcore/unicode.rs index 716a59f8ea9..61fd8d40f23 100644 --- a/src/libcore/unicode.rs +++ b/src/libcore/unicode.rs @@ -1,6 +1,6 @@ mod general_category { pure fn Cc(c: char) -> bool { - ret alt c { + return alt c { '\x00' to '\x1f' | '\x7f' to '\x9f' { true } @@ -9,7 +9,7 @@ mod general_category { } pure fn Cf(c: char) -> bool { - ret alt c { + return alt c { '\xad' | '\u0600' to '\u0603' | '\u06dd' @@ -29,7 +29,7 @@ mod general_category { } pure fn Co(c: char) -> bool { - ret alt c { + return alt c { '\ue000' to '\uf8ff' { true } _ { false } @@ -37,7 +37,7 @@ mod general_category { } pure fn Cs(c: char) -> bool { - ret alt c { + return alt c { '\ud800' to '\udfff' { true } _ { false } @@ -45,7 +45,7 @@ mod general_category { } pure fn Ll(c: char) -> bool { - ret alt c { + return alt c { '\x61' to '\x7a' | '\xaa' | '\xb5' @@ -650,7 +650,7 @@ mod general_category { } pure fn Lm(c: char) -> bool { - ret alt c { + return alt c { '\u02b0' to '\u02c1' | '\u02c6' to '\u02d1' | '\u02e0' to '\u02e4' @@ -706,7 +706,7 @@ mod general_category { } pure fn Lo(c: char) -> bool { - ret alt c { + return alt c { '\u01bb' | '\u01c0' to '\u01c3' | '\u0294' @@ -892,7 +892,7 @@ mod general_category { } pure fn Lt(c: char) -> bool { - ret alt c { + return alt c { '\u01c5' | '\u01c8' | '\u01cb' @@ -909,7 +909,7 @@ mod general_category { } pure fn Lu(c: char) -> bool { - ret alt c { + return alt c { '\x41' to '\x5a' | '\xc0' to '\xd6' | '\xd8' to '\xde' @@ -1501,7 +1501,7 @@ mod general_category { } pure fn Mc(c: char) -> bool { - ret alt c { + return alt c { '\u0903' | '\u093b' | '\u093e' to '\u0940' @@ -1612,7 +1612,7 @@ mod general_category { } pure fn Me(c: char) -> bool { - ret alt c { + return alt c { '\u0488' to '\u0489' | '\u20dd' to '\u20e0' | '\u20e2' to '\u20e4' @@ -1623,7 +1623,7 @@ mod general_category { } pure fn Mn(c: char) -> bool { - ret alt c { + return alt c { '\u0300' to '\u036f' | '\u0483' to '\u0487' | '\u0591' to '\u05bd' @@ -1816,7 +1816,7 @@ mod general_category { } pure fn Nd(c: char) -> bool { - ret alt c { + return alt c { '\x30' to '\x39' | '\u0660' to '\u0669' | '\u06f0' to '\u06f9' @@ -1860,7 +1860,7 @@ mod general_category { } pure fn Nl(c: char) -> bool { - ret alt c { + return alt c { '\u16ee' to '\u16f0' | '\u2160' to '\u2182' | '\u2185' to '\u2188' @@ -1879,7 +1879,7 @@ mod general_category { } pure fn No(c: char) -> bool { - ret alt c { + return alt c { '\xb2' to '\xb3' | '\xb9' | '\xbc' to '\xbe' @@ -1927,7 +1927,7 @@ mod general_category { } pure fn Pc(c: char) -> bool { - ret alt c { + return alt c { '\x5f' | '\u203f' to '\u2040' | '\u2054' @@ -1940,7 +1940,7 @@ mod general_category { } pure fn Pd(c: char) -> bool { - ret alt c { + return alt c { '\x2d' | '\u058a' | '\u05be' @@ -1962,7 +1962,7 @@ mod general_category { } pure fn Pe(c: char) -> bool { - ret alt c { + return alt c { '\x29' | '\x5d' | '\x7d' @@ -2039,7 +2039,7 @@ mod general_category { } pure fn Pf(c: char) -> bool { - ret alt c { + return alt c { '\xbb' | '\u2019' | '\u201d' @@ -2056,7 +2056,7 @@ mod general_category { } pure fn Pi(c: char) -> bool { - ret alt c { + return alt c { '\xab' | '\u2018' | '\u201b' to '\u201c' @@ -2074,7 +2074,7 @@ mod general_category { } pure fn Po(c: char) -> bool { - ret alt c { + return alt c { '\x21' to '\x23' | '\x25' to '\x27' | '\x2a' @@ -2207,7 +2207,7 @@ mod general_category { } pure fn Ps(c: char) -> bool { - ret alt c { + return alt c { '\x28' | '\x5b' | '\x7b' @@ -2286,7 +2286,7 @@ mod general_category { } pure fn Sc(c: char) -> bool { - ret alt c { + return alt c { '\x24' | '\xa2' to '\xa5' | '\u060b' @@ -2309,7 +2309,7 @@ mod general_category { } pure fn Sk(c: char) -> bool { - ret alt c { + return alt c { '\x5e' | '\x60' | '\xa8' @@ -2343,7 +2343,7 @@ mod general_category { } pure fn Sm(c: char) -> bool { - ret alt c { + return alt c { '\x2b' | '\x3c' to '\x3e' | '\x7c' @@ -2414,7 +2414,7 @@ mod general_category { } pure fn So(c: char) -> bool { - ret alt c { + return alt c { '\xa6' to '\xa7' | '\xa9' | '\xae' @@ -2533,7 +2533,7 @@ mod general_category { } pure fn Zl(c: char) -> bool { - ret alt c { + return alt c { '\u2028' { true } _ { false } @@ -2541,7 +2541,7 @@ mod general_category { } pure fn Zp(c: char) -> bool { - ret alt c { + return alt c { '\u2029' { true } _ { false } @@ -2549,7 +2549,7 @@ mod general_category { } pure fn Zs(c: char) -> bool { - ret alt c { + return alt c { '\x20' | '\xa0' | '\u1680' @@ -2567,7 +2567,7 @@ mod general_category { mod derived_property { /// Check if a character has the alphabetic unicode property pure fn Alphabetic(c: char) -> bool { - ret alt c { + return alt c { '\x41' to '\x5a' | '\x61' to '\x7a' | '\xaa' @@ -3305,7 +3305,7 @@ mod derived_property { } pure fn XID_Continue(c: char) -> bool { - ret alt c { + return alt c { '\x30' to '\x39' | '\x41' to '\x5a' | '\x5f' @@ -4176,7 +4176,7 @@ mod derived_property { } pure fn XID_Start(c: char) -> bool { - ret alt c { + return alt c { '\x41' to '\x5a' | '\x61' to '\x7a' | '\xaa' diff --git a/src/libcore/unsafe.rs b/src/libcore/unsafe.rs index 343fca55813..e56900876fc 100644 --- a/src/libcore/unsafe.rs +++ b/src/libcore/unsafe.rs @@ -44,7 +44,7 @@ unsafe fn bump_box_refcount<T>(+t: @T) { forget(t); } unsafe fn transmute<L, G>(-thing: L) -> G { let newthing = reinterpret_cast(thing); forget(thing); - ret newthing; + return newthing; } #[cfg(test)] diff --git a/src/libcore/vec.rs b/src/libcore/vec.rs index d0cd011ff12..670df1bd00b 100644 --- a/src/libcore/vec.rs +++ b/src/libcore/vec.rs @@ -191,7 +191,7 @@ pure fn from_fn<T>(n_elts: uint, op: init_op<T>) -> ~[T] { let mut i: uint = 0u; while i < n_elts unsafe { unsafe::set(v, i, op(i)); i += 1u; } unsafe { unsafe::set_len(v, n_elts); } - ret v; + return v; } /** @@ -208,7 +208,7 @@ pure fn from_elem<T: copy>(n_elts: uint, t: T) -> ~[T] { while i < n_elts { unsafe::set(v, i, t); i += 1u; } unsafe { unsafe::set_len(v, n_elts); } } - ret v; + return v; } /** @@ -234,7 +234,7 @@ pure fn build_sized<A>(size: uint, builder: fn(push: pure fn(+A))) -> ~[A] { <fn(push: pure fn(+A)), fn(push: fn(+A))> (builder)(|+x| push(vec, x)); } - ret vec; + return vec; } /** @@ -269,7 +269,7 @@ pure fn head<T: copy>(v: &[const T]) -> T { v[0] } /// Returns a vector containing all but the first element of a slice pure fn tail<T: copy>(v: &[const T]) -> ~[T] { - ret slice(v, 1u, len(v)); + return slice(v, 1u, len(v)); } /** @@ -297,7 +297,7 @@ pure fn last<T: copy>(v: &[const T]) -> T { * or `none` if the vector is empty. */ pure fn last_opt<T: copy>(v: &[const T]) -> option<T> { - if len(v) == 0u { ret none; } + if len(v) == 0u { return none; } some(v[len(v) - 1u]) } @@ -309,7 +309,7 @@ pure fn slice<T: copy>(v: &[const T], start: uint, end: uint) -> ~[T] { unchecked { for uint::range(start, end) |i| { vec::push(result, v[i]) } } - ret result; + return result; } /// Return a slice that points into another slice. @@ -351,7 +351,7 @@ pure fn const_view<T>(v: &[const T], start: uint, end: uint) -> &[const T] { /// Split the vector `v` by applying each element against the predicate `f`. fn split<T: copy>(v: &[T], f: fn(T) -> bool) -> ~[~[T]] { let ln = len(v); - if (ln == 0u) { ret ~[] } + if (ln == 0u) { return ~[] } let mut start = 0u; let mut result = ~[]; @@ -374,7 +374,7 @@ fn split<T: copy>(v: &[T], f: fn(T) -> bool) -> ~[~[T]] { */ fn splitn<T: copy>(v: &[T], n: uint, f: fn(T) -> bool) -> ~[~[T]] { let ln = len(v); - if (ln == 0u) { ret ~[] } + if (ln == 0u) { return ~[] } let mut start = 0u; let mut count = n; @@ -400,7 +400,7 @@ fn splitn<T: copy>(v: &[T], n: uint, f: fn(T) -> bool) -> ~[~[T]] { */ fn rsplit<T: copy>(v: &[T], f: fn(T) -> bool) -> ~[~[T]] { let ln = len(v); - if (ln == 0u) { ret ~[] } + if (ln == 0u) { return ~[] } let mut end = ln; let mut result = ~[]; @@ -423,7 +423,7 @@ fn rsplit<T: copy>(v: &[T], f: fn(T) -> bool) -> ~[~[T]] { */ fn rsplitn<T: copy>(v: &[T], n: uint, f: fn(T) -> bool) -> ~[~[T]] { let ln = len(v); - if (ln == 0u) { ret ~[] } + if (ln == 0u) { return ~[] } let mut end = ln; let mut count = n; @@ -564,7 +564,7 @@ pure fn append<T: copy>(+lhs: ~[T], rhs: &[const T]) -> ~[T] { unchecked { push_all(v, rhs); } - ret v; + return v; } #[inline(always)] @@ -591,7 +591,7 @@ pure fn append_mut<T: copy>(lhs: &[mut T], rhs: &[const T]) -> ~[mut T] { } i += 1u; } - ret v; + return v; } /** @@ -649,7 +649,7 @@ pure fn map<T, U>(v: &[T], f: fn(T) -> U) -> ~[U] { let mut result = ~[]; unchecked{reserve(result, len(v));} for each(v) |elem| { unsafe { push(result, f(elem)); } } - ret result; + return result; } fn map_consume<T, U>(+v: ~[T], f: fn(+T) -> U) -> ~[U] { @@ -665,7 +665,7 @@ pure fn mapi<T, U>(v: &[T], f: fn(uint, T) -> U) -> ~[U] { let mut result = ~[]; unchecked{reserve(result, len(v));} for eachi(v) |i, elem| { unsafe { push(result, f(i, elem)); } } - ret result; + return result; } /** @@ -675,7 +675,7 @@ pure fn mapi<T, U>(v: &[T], f: fn(uint, T) -> U) -> ~[U] { pure fn flat_map<T, U>(v: &[T], f: fn(T) -> ~[U]) -> ~[U] { let mut result = ~[]; for each(v) |elem| { unchecked{ push_all_move(result, f(elem)); } } - ret result; + return result; } /// Apply a function to each pair of elements and return the results @@ -689,7 +689,7 @@ pure fn map2<T: copy, U: copy, V>(v0: &[T], v1: &[U], unsafe { push(u, f(copy v0[i], copy v1[i])) }; i += 1u; } - ret u; + return u; } /** @@ -707,7 +707,7 @@ pure fn filter_map<T, U: copy>(v: &[T], f: fn(T) -> option<U>) some(result_elem) { unsafe { push(result, result_elem); } } } } - ret result; + return result; } /** @@ -722,7 +722,7 @@ pure fn filter<T: copy>(v: &[T], f: fn(T) -> bool) -> ~[T] { for each(v) |elem| { if f(elem) { unsafe { push(result, elem); } } } - ret result; + return result; } /** @@ -733,7 +733,7 @@ pure fn filter<T: copy>(v: &[T], f: fn(T) -> bool) -> ~[T] { pure fn concat<T: copy>(v: &[~[T]]) -> ~[T] { let mut r = ~[]; for each(v) |inner| { unsafe { push_all(r, inner); } } - ret r; + return r; } /// Concatenate a vector of vectors, placing a given separator between each @@ -744,7 +744,7 @@ pure fn connect<T: copy>(v: &[~[T]], sep: T) -> ~[T] { if first { first = false; } else { unsafe { push(r, sep); } } unchecked { push_all(r, inner) }; } - ret r; + return r; } /// Reduce a vector from left to right @@ -753,7 +753,7 @@ pure fn foldl<T: copy, U>(z: T, v: &[U], p: fn(T, U) -> T) -> T { do iter(v) |elt| { accum = p(accum, elt); } - ret accum; + return accum; } /// Reduce a vector from right to left @@ -762,7 +762,7 @@ pure fn foldr<T, U: copy>(v: &[T], z: U, p: fn(T, U) -> U) -> U { do riter(v) |elt| { accum = p(elt, accum); } - ret accum; + return accum; } /** @@ -771,8 +771,8 @@ pure fn foldr<T, U: copy>(v: &[T], z: U, p: fn(T, U) -> U) -> U { * If the vector contains no elements then false is returned. */ pure fn any<T>(v: &[T], f: fn(T) -> bool) -> bool { - for each(v) |elem| { if f(elem) { ret true; } } - ret false; + for each(v) |elem| { if f(elem) { return true; } } + return false; } /** @@ -786,10 +786,10 @@ pure fn any2<T, U>(v0: &[T], v1: &[U], let v1_len = len(v1); let mut i = 0u; while i < v0_len && i < v1_len { - if f(v0[i], v1[i]) { ret true; }; + if f(v0[i], v1[i]) { return true; }; i += 1u; } - ret false; + return false; } /** @@ -798,8 +798,8 @@ pure fn any2<T, U>(v0: &[T], v1: &[U], * If the vector contains no elements then true is returned. */ pure fn all<T>(v: &[T], f: fn(T) -> bool) -> bool { - for each(v) |elem| { if !f(elem) { ret false; } } - ret true; + for each(v) |elem| { if !f(elem) { return false; } } + return true; } /** @@ -808,8 +808,8 @@ pure fn all<T>(v: &[T], f: fn(T) -> bool) -> bool { * If the vector contains no elements then true is returned. */ pure fn alli<T>(v: &[T], f: fn(uint, T) -> bool) -> bool { - for eachi(v) |i, elem| { if !f(i, elem) { ret false; } } - ret true; + for eachi(v) |i, elem| { if !f(i, elem) { return false; } } + return true; } /** @@ -820,23 +820,23 @@ pure fn alli<T>(v: &[T], f: fn(uint, T) -> bool) -> bool { pure fn all2<T, U>(v0: &[T], v1: &[U], f: fn(T, U) -> bool) -> bool { let v0_len = len(v0); - if v0_len != len(v1) { ret false; } + if v0_len != len(v1) { return false; } let mut i = 0u; - while i < v0_len { if !f(v0[i], v1[i]) { ret false; }; i += 1u; } - ret true; + while i < v0_len { if !f(v0[i], v1[i]) { return false; }; i += 1u; } + return true; } /// Return true if a vector contains an element with the given value pure fn contains<T>(v: &[T], x: T) -> bool { - for each(v) |elt| { if x == elt { ret true; } } - ret false; + for each(v) |elt| { if x == elt { return true; } } + return false; } /// Returns the number of elements that are equal to a given value pure fn count<T>(v: &[T], x: T) -> uint { let mut cnt = 0u; for each(v) |elt| { if x == elt { cnt += 1u; } } - ret cnt; + return cnt; } /** @@ -913,8 +913,8 @@ pure fn position_between<T>(v: &[T], start: uint, end: uint, assert start <= end; assert end <= len(v); let mut i = start; - while i < end { if f(v[i]) { ret some::<uint>(i); } i += 1u; } - ret none; + while i < end { if f(v[i]) { return some::<uint>(i); } i += 1u; } + return none; } /// Find the last index containing a matching value @@ -947,10 +947,10 @@ pure fn rposition_between<T>(v: &[T], start: uint, end: uint, assert end <= len(v); let mut i = end; while i > start { - if f(v[i - 1u]) { ret some::<uint>(i - 1u); } + if f(v[i - 1u]) { return some::<uint>(i - 1u); } i -= 1u; } - ret none; + return none; } // FIXME: if issue #586 gets implemented, could have a postcondition @@ -974,7 +974,7 @@ pure fn unzip<T: copy, U: copy>(v: &[(T, U)]) -> (~[T], ~[U]) { vec::push(bs, b); } } - ret (as, bs); + return (as, bs); } /** @@ -989,7 +989,7 @@ pure fn zip<T: copy, U: copy>(v: &[const T], u: &[const U]) -> ~[(T, U)] { let mut i = 0u; assert sz == len(u); while i < sz unchecked { vec::push(zipped, (v[i], u[i])); i += 1u; } - ret zipped; + return zipped; } /** @@ -1017,12 +1017,12 @@ fn reverse<T>(v: ~[mut T]) { pure fn reversed<T: copy>(v: &[const T]) -> ~[T] { let mut rs: ~[T] = ~[]; let mut i = len::<T>(v); - if i == 0u { ret rs; } else { i -= 1u; } + if i == 0u { return rs; } else { i -= 1u; } unchecked { while i != 0u { vec::push(rs, v[i]); i -= 1u; } vec::push(rs, v[0]); } - ret rs; + return rs; } /** @@ -1229,7 +1229,7 @@ pure fn windowed<TT: copy>(nn: uint, xx: &[TT]) -> ~[~[TT]] { vec::push(ww, vec::slice(xx, ii, ii+nn)); } }); - ret ww; + return ww; } /** @@ -1541,7 +1541,7 @@ mod unsafe { */ #[inline(always)] unsafe fn from_buf<T>(ptr: *T, elts: uint) -> ~[T] { - ret ::unsafe::reinterpret_cast( + return ::unsafe::reinterpret_cast( rustrt::vec_from_buf_shared(sys::get_type_desc::<T>(), ptr as *(), elts as size_t)); @@ -1572,14 +1572,14 @@ mod unsafe { #[inline(always)] unsafe fn to_ptr<T>(v: ~[const T]) -> *T { let repr: **vec_repr = ::unsafe::reinterpret_cast(addr_of(v)); - ret ::unsafe::reinterpret_cast(addr_of((**repr).data)); + return ::unsafe::reinterpret_cast(addr_of((**repr).data)); } #[inline(always)] unsafe fn to_ptr_slice<T>(v: &[const T]) -> *T { let repr: **slice_repr = ::unsafe::reinterpret_cast(addr_of(v)); - ret ::unsafe::reinterpret_cast(addr_of((**repr).data)); + return ::unsafe::reinterpret_cast(addr_of((**repr).data)); } @@ -1775,21 +1775,21 @@ impl extensions/&<A:copy> of iter_trait_extensions<A> for &[A] { #[cfg(test)] mod tests { - fn square(n: uint) -> uint { ret n * n; } + fn square(n: uint) -> uint { return n * n; } - fn square_ref(&&n: uint) -> uint { ret n * n; } + fn square_ref(&&n: uint) -> uint { return n * n; } - pure fn is_three(&&n: uint) -> bool { ret n == 3u; } + pure fn is_three(&&n: uint) -> bool { return n == 3u; } - pure fn is_odd(&&n: uint) -> bool { ret n % 2u == 1u; } + pure fn is_odd(&&n: uint) -> bool { return n % 2u == 1u; } - pure fn is_equal(&&x: uint, &&y:uint) -> bool { ret x == y; } + pure fn is_equal(&&x: uint, &&y:uint) -> bool { return x == y; } fn square_if_odd(&&n: uint) -> option<uint> { - ret if n % 2u == 1u { some(n * n) } else { none }; + return if n % 2u == 1u { some(n * n) } else { none }; } - fn add(&&x: uint, &&y: uint) -> uint { ret x + y; } + fn add(&&x: uint, &&y: uint) -> uint { return x + y; } #[test] fn test_unsafe_ptrs() { @@ -2015,7 +2015,7 @@ mod tests { #[test] fn test_map2() { - fn times(&&x: int, &&y: int) -> int { ret x * y; } + fn times(&&x: int, &&y: int) -> int { return x * y; } let f = times; let v0 = ~[1, 2, 3, 4, 5]; let v1 = ~[5, 4, 3, 2, 1]; @@ -2043,10 +2043,10 @@ mod tests { fn halve(&&i: int) -> option<int> { if i % 2 == 0 { - ret option::some::<int>(i / 2); - } else { ret option::none::<int>; } + return option::some::<int>(i / 2); + } else { return option::none::<int>; } } - fn halve_for_sure(&&i: int) -> int { ret i / 2; } + fn halve_for_sure(&&i: int) -> int { return i / 2; } let all_even: ~[int] = ~[0, 2, 8, 6]; let all_odd1: ~[int] = ~[1, 7, 3]; let all_odd2: ~[int] = ~[]; @@ -2230,8 +2230,8 @@ mod tests { #[test] fn test_position() { - fn less_than_three(&&i: int) -> bool { ret i < 3; } - fn is_eighteen(&&i: int) -> bool { ret i == 18; } + fn less_than_three(&&i: int) -> bool { return i < 3; } + fn is_eighteen(&&i: int) -> bool { return i == 18; } assert position(~[], less_than_three) == none; |
