diff --git a/src/libcore/at_vec.rs b/src/libcore/at_vec.rs index 8d3c8561957..29b7e35e24b 100644 --- a/src/libcore/at_vec.rs +++ b/src/libcore/at_vec.rs @@ -38,7 +38,7 @@ pub mod rustrt { /// Returns the number of elements the vector can hold without reallocating #[inline(always)] -pub pure fn capacity(v: @[const T]) -> uint { +pub fn capacity(v: @[const T]) -> uint { unsafe { let repr: **raw::VecRepr = ::cast::reinterpret_cast(&addr_of(&v)); @@ -59,8 +59,7 @@ pub pure fn capacity(v: @[const T]) -> uint { * onto the vector being constructed. */ #[inline(always)] -pub pure fn build_sized(size: uint, - builder: &fn(push: &pure fn(v: A))) -> @[A] { +pub fn build_sized(size: uint, builder: &fn(push: &fn(v: A))) -> @[A] { let mut vec: @[const A] = @[]; unsafe { raw::reserve(&mut vec, size); } builder(|+x| unsafe { raw::push(&mut vec, x) }); @@ -78,7 +77,7 @@ pub pure fn build_sized(size: uint, * onto the vector being constructed. */ #[inline(always)] -pub pure fn build(builder: &fn(push: &pure fn(v: A))) -> @[A] { +pub fn build(builder: &fn(push: &fn(v: A))) -> @[A] { build_sized(4, builder) } @@ -95,14 +94,15 @@ pub pure fn build(builder: &fn(push: &pure fn(v: A))) -> @[A] { * onto the vector being constructed. */ #[inline(always)] -pub pure fn build_sized_opt(size: Option, - builder: &fn(push: &pure fn(v: A))) -> @[A] { +pub fn build_sized_opt(size: Option, + builder: &fn(push: &fn(v: A))) + -> @[A] { build_sized(size.get_or_default(4), builder) } // Appending #[inline(always)] -pub pure fn append(lhs: @[T], rhs: &[const T]) -> @[T] { +pub fn append(lhs: @[T], rhs: &[const T]) -> @[T] { do build_sized(lhs.len() + rhs.len()) |push| { for vec::each(lhs) |x| { push(*x); } for uint::range(0, rhs.len()) |i| { push(rhs[i]); } @@ -111,7 +111,7 @@ pub pure fn append(lhs: @[T], rhs: &[const T]) -> @[T] { /// Apply a function to each element of a vector and return the results -pub pure fn map(v: &[T], f: &fn(x: &T) -> U) -> @[U] { +pub fn map(v: &[T], f: &fn(x: &T) -> U) -> @[U] { do build_sized(v.len()) |push| { for vec::each(v) |elem| { push(f(elem)); @@ -125,7 +125,7 @@ pub pure fn map(v: &[T], f: &fn(x: &T) -> U) -> @[U] { * Creates an immutable vector of size `n_elts` and initializes the elements * to the value returned by the function `op`. */ -pub pure fn from_fn(n_elts: uint, op: iter::InitOp) -> @[T] { +pub fn from_fn(n_elts: uint, op: iter::InitOp) -> @[T] { do build_sized(n_elts) |push| { let mut i: uint = 0u; while i < n_elts { push(op(i)); i += 1u; } @@ -138,7 +138,7 @@ pub pure fn from_fn(n_elts: uint, op: iter::InitOp) -> @[T] { * Creates an immutable vector of size `n_elts` and initializes the elements * to the value `t`. */ -pub pure fn from_elem(n_elts: uint, t: T) -> @[T] { +pub fn from_elem(n_elts: uint, t: T) -> @[T] { do build_sized(n_elts) |push| { let mut i: uint = 0u; while i < n_elts { push(copy t); i += 1u; } @@ -176,7 +176,7 @@ pub mod traits { impl Add<&'self [const T],@[T]> for @[T] { #[inline(always)] - pure fn add(&self, rhs: & &'self [const T]) -> @[T] { + fn add(&self, rhs: & &'self [const T]) -> @[T] { append(*self, (*rhs)) } } diff --git a/src/libcore/bool.rs b/src/libcore/bool.rs index 388542c9934..2b669a285b3 100644 --- a/src/libcore/bool.rs +++ b/src/libcore/bool.rs @@ -17,39 +17,39 @@ use from_str::FromStr; #[cfg(notest)] use cmp; /// Negation / inverse -pub pure fn not(v: bool) -> bool { !v } +pub fn not(v: bool) -> bool { !v } /// Conjunction -pub pure fn and(a: bool, b: bool) -> bool { a && b } +pub fn and(a: bool, b: bool) -> bool { a && b } /// Disjunction -pub pure fn or(a: bool, b: bool) -> bool { a || b } +pub fn or(a: bool, b: bool) -> bool { a || b } /** * Exclusive or * * Identical to `or(and(a, not(b)), and(not(a), b))` */ -pub pure fn xor(a: bool, b: bool) -> bool { (a && !b) || (!a && b) } +pub fn xor(a: bool, b: bool) -> bool { (a && !b) || (!a && b) } /// Implication in the logic, i.e. from `a` follows `b` -pub pure fn implies(a: bool, b: bool) -> bool { !a || b } +pub fn implies(a: bool, b: bool) -> bool { !a || b } /// true if truth values `a` and `b` are indistinguishable in the logic -pub pure fn eq(a: bool, b: bool) -> bool { a == b } +pub fn eq(a: bool, b: bool) -> bool { a == b } /// true if truth values `a` and `b` are distinguishable in the logic -pub pure fn ne(a: bool, b: bool) -> bool { a != b } +pub fn ne(a: bool, b: bool) -> bool { a != b } /// true if `v` represents truth in the logic -pub pure fn is_true(v: bool) -> bool { v } +pub fn is_true(v: bool) -> bool { v } /// true if `v` represents falsehood in the logic -pub pure fn is_false(v: bool) -> bool { !v } +pub fn is_false(v: bool) -> bool { !v } /// Parse logic value from `s` impl FromStr for bool { - pure fn from_str(s: &str) -> Option { + fn from_str(s: &str) -> Option { if s == "true" { Some(true) } else if s == "false" { @@ -61,7 +61,7 @@ impl FromStr for bool { } /// Convert `v` into a string -pub pure fn to_str(v: bool) -> ~str { if v { ~"true" } else { ~"false" } } +pub fn to_str(v: bool) -> ~str { if v { ~"true" } else { ~"false" } } /** * Iterates over all truth values by passing them to `blk` in an unspecified @@ -73,12 +73,12 @@ pub fn all_values(blk: &fn(v: bool)) { } /// converts truth value to an 8 bit byte -pub pure fn to_bit(v: bool) -> u8 { if v { 1u8 } else { 0u8 } } +pub fn to_bit(v: bool) -> u8 { if v { 1u8 } else { 0u8 } } #[cfg(notest)] impl cmp::Eq for bool { - pure fn eq(&self, other: &bool) -> bool { (*self) == (*other) } - pure fn ne(&self, other: &bool) -> bool { (*self) != (*other) } + fn eq(&self, other: &bool) -> bool { (*self) == (*other) } + fn ne(&self, other: &bool) -> bool { (*self) != (*other) } } #[test] diff --git a/src/libcore/cell.rs b/src/libcore/cell.rs index cfd1b8dfef0..bf5f9315938 100644 --- a/src/libcore/cell.rs +++ b/src/libcore/cell.rs @@ -21,14 +21,14 @@ pub struct Cell { } impl cmp::Eq for Cell { - pure fn eq(&self, other: &Cell) -> bool { + fn eq(&self, other: &Cell) -> bool { unsafe { let frozen_self: &Option = transmute(&mut self.value); let frozen_other: &Option = transmute(&mut other.value); frozen_self == frozen_other } } - pure fn ne(&self, other: &Cell) -> bool { !self.eq(other) } + fn ne(&self, other: &Cell) -> bool { !self.eq(other) } } /// Creates a new full cell with the given value. @@ -36,7 +36,7 @@ pub fn Cell(value: T) -> Cell { Cell { value: Some(value) } } -pub pure fn empty_cell() -> Cell { +pub fn empty_cell() -> Cell { Cell { value: None } } @@ -61,7 +61,7 @@ pub impl Cell { } /// Returns true if the cell is empty and false if the cell is full. - pure fn is_empty(&self) -> bool { + fn is_empty(&self) -> bool { self.value.is_none() } diff --git a/src/libcore/char.rs b/src/libcore/char.rs index f2db9ca919d..027329a2355 100644 --- a/src/libcore/char.rs +++ b/src/libcore/char.rs @@ -61,7 +61,7 @@ pub use is_XID_continue = unicode::derived_property::XID_Continue; * in terms of the Unicode General Category 'Ll' */ #[inline(always)] -pub pure fn is_lowercase(c: char) -> bool { +pub fn is_lowercase(c: char) -> bool { return unicode::general_category::Ll(c); } @@ -70,7 +70,7 @@ pub pure fn is_lowercase(c: char) -> bool { * in terms of the Unicode General Category 'Lu'. */ #[inline(always)] -pub pure fn is_uppercase(c: char) -> bool { +pub fn is_uppercase(c: char) -> bool { return unicode::general_category::Lu(c); } @@ -80,7 +80,7 @@ pub pure fn is_uppercase(c: char) -> bool { * additional 'Cc'-category control codes in the range [0x09, 0x0d] */ #[inline(always)] -pub pure fn is_whitespace(c: char) -> bool { +pub fn is_whitespace(c: char) -> bool { return ('\x09' <= c && c <= '\x0d') || unicode::general_category::Zs(c) || unicode::general_category::Zl(c) @@ -93,7 +93,7 @@ pub pure fn is_whitespace(c: char) -> bool { * and the Derived Core Property 'Alphabetic'. */ #[inline(always)] -pub pure fn is_alphanumeric(c: char) -> bool { +pub fn is_alphanumeric(c: char) -> bool { return unicode::derived_property::Alphabetic(c) || unicode::general_category::Nd(c) || unicode::general_category::Nl(c) || @@ -102,13 +102,13 @@ pub pure fn is_alphanumeric(c: char) -> bool { /// Indicates whether the character is an ASCII character #[inline(always)] -pub pure fn is_ascii(c: char) -> bool { +pub fn is_ascii(c: char) -> bool { c - ('\x7F' & c) == '\x00' } /// Indicates whether the character is numeric (Nd, Nl, or No) #[inline(always)] -pub pure fn is_digit(c: char) -> bool { +pub fn is_digit(c: char) -> bool { return unicode::general_category::Nd(c) || unicode::general_category::Nl(c) || unicode::general_category::No(c); @@ -127,7 +127,7 @@ pub pure fn is_digit(c: char) -> bool { * Note: This just wraps `to_digit()`. */ #[inline(always)] -pub pure fn is_digit_radix(c: char, radix: uint) -> bool { +pub fn is_digit_radix(c: char, radix: uint) -> bool { match to_digit(c, radix) { Some(_) => true, None => false @@ -148,7 +148,7 @@ pub pure fn is_digit_radix(c: char, radix: uint) -> bool { * Fails if given a `radix` outside the range `[0..36]`. */ #[inline] -pub pure fn to_digit(c: char, radix: uint) -> Option { +pub fn to_digit(c: char, radix: uint) -> Option { if radix > 36 { fail!(fmt!("to_digit: radix %? is to high (maximum 36)", radix)); } @@ -171,7 +171,7 @@ pub pure fn to_digit(c: char, radix: uint) -> Option { * Fails if given an `radix` > 36. */ #[inline] -pub pure fn from_digit(num: uint, radix: uint) -> Option { +pub fn from_digit(num: uint, radix: uint) -> Option { if radix > 36 { fail!(fmt!("from_digit: radix %? is to high (maximum 36)", num)); } @@ -195,7 +195,7 @@ pub pure fn from_digit(num: uint, radix: uint) -> Option { * - chars in [0x100,0xffff] get 4-digit escapes: `\\uNNNN` * - chars above 0x10000 get 8-digit escapes: `\\UNNNNNNNN` */ -pub pure fn escape_unicode(c: char) -> ~str { +pub fn escape_unicode(c: char) -> ~str { let s = u32::to_str_radix(c as u32, 16u); let (c, pad) = (if c <= '\xff' { ('x', 2u) } else if c <= '\uffff' { ('u', 4u) } @@ -223,7 +223,7 @@ pub pure fn escape_unicode(c: char) -> ~str { * - Any other chars in the range [0x20,0x7e] are not escaped. * - Any other chars are given hex unicode escapes; see `escape_unicode`. */ -pub pure fn escape_default(c: char) -> ~str { +pub fn escape_default(c: char) -> ~str { match c { '\t' => ~"\\t", '\r' => ~"\\r", @@ -244,7 +244,7 @@ pub pure fn escape_default(c: char) -> ~str { * -1 if a < b, 0 if a == b, +1 if a > b */ #[inline(always)] -pub pure fn cmp(a: char, b: char) -> int { +pub fn cmp(a: char, b: char) -> int { return if b > a { -1 } else if b < a { 1 } else { 0 } @@ -252,8 +252,8 @@ pub pure fn cmp(a: char, b: char) -> int { #[cfg(notest)] impl Eq for char { - pure fn eq(&self, other: &char) -> bool { (*self) == (*other) } - pure fn ne(&self, other: &char) -> bool { (*self) != (*other) } + fn eq(&self, other: &char) -> bool { (*self) == (*other) } + fn ne(&self, other: &char) -> bool { (*self) != (*other) } } #[test] diff --git a/src/libcore/cmp.rs b/src/libcore/cmp.rs index fc8ed5d70c3..7c45ecae632 100644 --- a/src/libcore/cmp.rs +++ b/src/libcore/cmp.rs @@ -33,8 +33,8 @@ and `Eq` to overload the `==` and `!=` operators. */ #[lang="eq"] pub trait Eq { - pure fn eq(&self, other: &Self) -> bool; - pure fn ne(&self, other: &Self) -> bool; + fn eq(&self, other: &Self) -> bool; + fn ne(&self, other: &Self) -> bool; } #[deriving(Eq)] @@ -42,11 +42,11 @@ pub enum Ordering { Less, Equal, Greater } /// Trait for types that form a total order pub trait TotalOrd { - pure fn cmp(&self, other: &Self) -> Ordering; + fn cmp(&self, other: &Self) -> Ordering; } #[inline(always)] -pure fn icmp(a: &T, b: &T) -> Ordering { +fn icmp(a: &T, b: &T) -> Ordering { if *a < *b { Less } else if *a > *b { Greater } else { Equal } @@ -54,52 +54,52 @@ pure fn icmp(a: &T, b: &T) -> Ordering { impl TotalOrd for u8 { #[inline(always)] - pure fn cmp(&self, other: &u8) -> Ordering { icmp(self, other) } + fn cmp(&self, other: &u8) -> Ordering { icmp(self, other) } } impl TotalOrd for u16 { #[inline(always)] - pure fn cmp(&self, other: &u16) -> Ordering { icmp(self, other) } + fn cmp(&self, other: &u16) -> Ordering { icmp(self, other) } } impl TotalOrd for u32 { #[inline(always)] - pure fn cmp(&self, other: &u32) -> Ordering { icmp(self, other) } + fn cmp(&self, other: &u32) -> Ordering { icmp(self, other) } } impl TotalOrd for u64 { #[inline(always)] - pure fn cmp(&self, other: &u64) -> Ordering { icmp(self, other) } + fn cmp(&self, other: &u64) -> Ordering { icmp(self, other) } } impl TotalOrd for i8 { #[inline(always)] - pure fn cmp(&self, other: &i8) -> Ordering { icmp(self, other) } + fn cmp(&self, other: &i8) -> Ordering { icmp(self, other) } } impl TotalOrd for i16 { #[inline(always)] - pure fn cmp(&self, other: &i16) -> Ordering { icmp(self, other) } + fn cmp(&self, other: &i16) -> Ordering { icmp(self, other) } } impl TotalOrd for i32 { #[inline(always)] - pure fn cmp(&self, other: &i32) -> Ordering { icmp(self, other) } + fn cmp(&self, other: &i32) -> Ordering { icmp(self, other) } } impl TotalOrd for i64 { #[inline(always)] - pure fn cmp(&self, other: &i64) -> Ordering { icmp(self, other) } + fn cmp(&self, other: &i64) -> Ordering { icmp(self, other) } } impl TotalOrd for int { #[inline(always)] - pure fn cmp(&self, other: &int) -> Ordering { icmp(self, other) } + fn cmp(&self, other: &int) -> Ordering { icmp(self, other) } } impl TotalOrd for uint { #[inline(always)] - pure fn cmp(&self, other: &uint) -> Ordering { icmp(self, other) } + fn cmp(&self, other: &uint) -> Ordering { icmp(self, other) } } /** @@ -114,39 +114,39 @@ impl TotalOrd for uint { */ #[lang="ord"] pub trait Ord { - pure fn lt(&self, other: &Self) -> bool; - pure fn le(&self, other: &Self) -> bool; - pure fn ge(&self, other: &Self) -> bool; - pure fn gt(&self, other: &Self) -> bool; + fn lt(&self, other: &Self) -> bool; + fn le(&self, other: &Self) -> bool; + fn ge(&self, other: &Self) -> bool; + fn gt(&self, other: &Self) -> bool; } #[inline(always)] -pub pure fn lt(v1: &T, v2: &T) -> bool { +pub fn lt(v1: &T, v2: &T) -> bool { (*v1).lt(v2) } #[inline(always)] -pub pure fn le(v1: &T, v2: &T) -> bool { +pub fn le(v1: &T, v2: &T) -> bool { (*v1).le(v2) } #[inline(always)] -pub pure fn eq(v1: &T, v2: &T) -> bool { +pub fn eq(v1: &T, v2: &T) -> bool { (*v1).eq(v2) } #[inline(always)] -pub pure fn ne(v1: &T, v2: &T) -> bool { +pub fn ne(v1: &T, v2: &T) -> bool { (*v1).ne(v2) } #[inline(always)] -pub pure fn ge(v1: &T, v2: &T) -> bool { +pub fn ge(v1: &T, v2: &T) -> bool { (*v1).ge(v2) } #[inline(always)] -pub pure fn gt(v1: &T, v2: &T) -> bool { +pub fn gt(v1: &T, v2: &T) -> bool { (*v1).gt(v2) } @@ -155,16 +155,16 @@ pub pure fn gt(v1: &T, v2: &T) -> bool { /// container types; e.g. it is often desirable to be able to use `&str` /// values to look up entries in a container with `~str` keys. pub trait Equiv { - pure fn equiv(&self, other: &T) -> bool; + fn equiv(&self, other: &T) -> bool; } #[inline(always)] -pub pure fn min(v1: T, v2: T) -> T { +pub fn min(v1: T, v2: T) -> T { if v1 < v2 { v1 } else { v2 } } #[inline(always)] -pub pure fn max(v1: T, v2: T) -> T { +pub fn max(v1: T, v2: T) -> T { if v1 > v2 { v1 } else { v2 } } diff --git a/src/libcore/comm.rs b/src/libcore/comm.rs index 692a7947e20..6dadca8dc57 100644 --- a/src/libcore/comm.rs +++ b/src/libcore/comm.rs @@ -50,7 +50,7 @@ pub trait GenericPort { /// Ports that can `peek` pub trait Peekable { /// Returns true if a message is available - pure fn peek(&self) -> bool; + fn peek(&self) -> bool; } /// Returns the index of an endpoint that is ready to receive. @@ -148,7 +148,7 @@ fn chan_try_send(self: &Chan, x: T) -> bool { pub impl Port { fn recv(&self) -> T { port_recv(self) } fn try_recv(&self) -> Option { port_try_recv(self) } - pure fn peek(&self) -> bool { port_peek(self) } + fn peek(&self) -> bool { port_peek(self) } } impl GenericPort for Port { @@ -180,11 +180,11 @@ fn port_try_recv(self: &Port) -> Option { } impl Peekable for Port { - pure fn peek(&self) -> bool { port_peek(self) } + fn peek(&self) -> bool { port_peek(self) } } #[inline(always)] -pure fn port_peek(self: &Port) -> bool { +fn port_peek(self: &Port) -> bool { unsafe { let mut endp = None; endp <-> self.endp; @@ -198,7 +198,7 @@ pure fn port_peek(self: &Port) -> bool { } impl Selectable for Port { - pure fn header(&self) -> *PacketHeader { + fn header(&self) -> *PacketHeader { unsafe { match self.endp { Some(ref endp) => endp.header(), @@ -223,7 +223,7 @@ pub fn PortSet() -> PortSet{ pub impl PortSet { fn recv(&self) -> T { port_set_recv(self) } fn try_recv(&self) -> Option { port_set_try_recv(self) } - pure fn peek(&self) -> bool { port_set_peek(self) } + fn peek(&self) -> bool { port_set_peek(self) } } pub impl PortSet { @@ -272,11 +272,11 @@ fn port_set_try_recv(self: &PortSet) -> Option { } impl Peekable for PortSet { - pure fn peek(&self) -> bool { port_set_peek(self) } + fn peek(&self) -> bool { port_set_peek(self) } } #[inline(always)] -pure fn port_set_peek(self: &PortSet) -> bool { +fn port_set_peek(self: &PortSet) -> bool { // It'd be nice to use self.port.each, but that version isn't // pure. for uint::range(0, vec::uniq_len(&const self.ports)) |i| { diff --git a/src/libcore/container.rs b/src/libcore/container.rs index 5044b3a6c5d..1cda04ee06e 100644 --- a/src/libcore/container.rs +++ b/src/libcore/container.rs @@ -14,10 +14,10 @@ use option::Option; pub trait Container { /// Return the number of elements in the container - pure fn len(&const self) -> uint; + fn len(&const self) -> uint; /// Return true if the container contains no elements - pure fn is_empty(&const self) -> bool; + fn is_empty(&const self) -> bool; } pub trait Mutable: Container { @@ -27,19 +27,19 @@ pub trait Mutable: Container { pub trait Map: Mutable { /// Return true if the map contains a value for the specified key - pure fn contains_key(&self, key: &K) -> bool; + fn contains_key(&self, key: &K) -> bool; /// Visit all keys - pure fn each_key(&self, f: &fn(&K) -> bool); + fn each_key(&self, f: &fn(&K) -> bool); /// Visit all values - pure fn each_value(&self, f: &fn(&V) -> bool); + fn each_value(&self, f: &fn(&V) -> bool); /// Iterate over the map and mutate the contained values fn mutate_values(&mut self, f: &fn(&K, &mut V) -> bool); /// Return the value corresponding to the key in the map - pure fn find(&self, key: &K) -> Option<&'self V>; + fn find(&self, key: &K) -> Option<&'self V>; /// Insert a key-value pair into the map. An existing value for a /// key is replaced by the new value. Return true if the key did @@ -53,7 +53,7 @@ pub trait Map: Mutable { pub trait Set: Mutable { /// Return true if the set contains a value - pure fn contains(&self, value: &T) -> bool; + fn contains(&self, value: &T) -> bool; /// Add a value to the set. Return true if the value was not already /// present in the set. @@ -65,23 +65,23 @@ pub trait Set: Mutable { /// Return true if the set has no elements in common with `other`. /// This is equivalent to checking for an empty intersection. - pure fn is_disjoint(&self, other: &Self) -> bool; + fn is_disjoint(&self, other: &Self) -> bool; /// Return true if the set is a subset of another - pure fn is_subset(&self, other: &Self) -> bool; + fn is_subset(&self, other: &Self) -> bool; /// Return true if the set is a superset of another - pure fn is_superset(&self, other: &Self) -> bool; + fn is_superset(&self, other: &Self) -> bool; /// Visit the values representing the difference - pure fn difference(&self, other: &Self, f: &fn(&T) -> bool); + fn difference(&self, other: &Self, f: &fn(&T) -> bool); /// Visit the values representing the symmetric difference - pure fn symmetric_difference(&self, other: &Self, f: &fn(&T) -> bool); + fn symmetric_difference(&self, other: &Self, f: &fn(&T) -> bool); /// Visit the values representing the intersection - pure fn intersection(&self, other: &Self, f: &fn(&T) -> bool); + fn intersection(&self, other: &Self, f: &fn(&T) -> bool); /// Visit the values representing the union - pure fn union(&self, other: &Self, f: &fn(&T) -> bool); + fn union(&self, other: &Self, f: &fn(&T) -> bool); } diff --git a/src/libcore/dlist.rs b/src/libcore/dlist.rs index ef3deb11a95..ff86e8d1ffc 100644 --- a/src/libcore/dlist.rs +++ b/src/libcore/dlist.rs @@ -42,7 +42,7 @@ pub struct DList { } priv impl DListNode { - pure fn assert_links(@mut self) { + fn assert_links(@mut self) { match self.next { Some(neighbour) => match neighbour.prev { Some(me) => if !managed::mut_ptr_eq(self, me) { @@ -66,24 +66,24 @@ priv impl DListNode { pub impl DListNode { /// Get the next node in the list, if there is one. - pure fn next_link(@mut self) -> DListLink { + fn next_link(@mut self) -> DListLink { self.assert_links(); self.next } /// Get the next node in the list, failing if there isn't one. - pure fn next_node(@mut self) -> @mut DListNode { + fn next_node(@mut self) -> @mut DListNode { match self.next_link() { Some(nobe) => nobe, None => fail!(~"This dlist node has no next neighbour.") } } /// Get the previous node in the list, if there is one. - pure fn prev_link(@mut self) -> DListLink { + fn prev_link(@mut self) -> DListLink { self.assert_links(); self.prev } /// Get the previous node in the list, failing if there isn't one. - pure fn prev_node(@mut self) -> @mut DListNode { + fn prev_node(@mut self) -> @mut DListNode { match self.prev_link() { Some(nobe) => nobe, None => fail!(~"This dlist node has no previous neighbour.") @@ -92,17 +92,17 @@ pub impl DListNode { } /// Creates a new dlist node with the given data. -pub pure fn new_dlist_node(data: T) -> @mut DListNode { +pub fn new_dlist_node(data: T) -> @mut DListNode { @mut DListNode { data: data, linked: false, prev: None, next: None } } /// Creates a new, empty dlist. -pub pure fn DList() -> @mut DList { +pub fn DList() -> @mut DList { @mut DList { size: 0, hd: None, tl: None } } /// Creates a new dlist with a single element -pub pure fn from_elem(data: T) -> @mut DList { +pub fn from_elem(data: T) -> @mut DList { let list = DList(); unsafe { list.push(data); } list @@ -126,7 +126,7 @@ pub fn concat(lists: @mut DList<@mut DList>) -> @mut DList { } priv impl DList { - pure fn new_link(data: T) -> DListLink { + fn new_link(data: T) -> DListLink { Some(@mut DListNode { data: data, linked: true, @@ -134,7 +134,7 @@ priv impl DList { next: None }) } - pure fn assert_mine(@mut self, nobe: @mut DListNode) { + fn assert_mine(@mut self, nobe: @mut DListNode) { // These asserts could be stronger if we had node-root back-pointers, // but those wouldn't allow for O(1) append. if self.size == 0 { @@ -212,9 +212,9 @@ priv impl DList { pub impl DList { /// Get the size of the list. O(1). - pure fn len(@mut self) -> uint { self.size } + fn len(@mut self) -> uint { self.size } /// Returns true if the list is empty. O(1). - pure fn is_empty(@mut self) -> bool { self.len() == 0 } + fn is_empty(@mut self) -> bool { self.len() == 0 } /// Add data to the head of the list. O(1). fn push_head(@mut self, data: T) { @@ -316,12 +316,12 @@ pub impl DList { tl } /// Get the node at the list's head. O(1). - pure fn peek_n(@mut self) -> DListLink { self.hd } + fn peek_n(@mut self) -> DListLink { self.hd } /// Get the node at the list's tail. O(1). - pure fn peek_tail_n(@mut self) -> DListLink { self.tl } + fn peek_tail_n(@mut self) -> DListLink { self.tl } /// Get the node at the list's head, failing if empty. O(1). - pure fn head_n(@mut self) -> @mut DListNode { + fn head_n(@mut self) -> @mut DListNode { match self.hd { Some(nobe) => nobe, None => fail!( @@ -329,7 +329,7 @@ pub impl DList { } } /// Get the node at the list's tail, failing if empty. O(1). - pure fn tail_n(@mut self) -> @mut DListNode { + fn tail_n(@mut self) -> @mut DListNode { match self.tl { Some(nobe) => nobe, None => fail!( @@ -399,7 +399,7 @@ pub impl DList { } /// Iterate over nodes. - pure fn each_node(@mut self, f: &fn(@mut DListNode) -> bool) { + fn each_node(@mut self, f: &fn(@mut DListNode) -> bool) { let mut link = self.peek_n(); while link.is_some() { let nobe = link.get(); @@ -471,23 +471,23 @@ pub impl DList { } /// Get data at the list's head. O(1). - pure fn peek(@mut self) -> Option { + fn peek(@mut self) -> Option { self.peek_n().map(|nobe| nobe.data) } /// Get data at the list's tail. O(1). - pure fn peek_tail(@mut self) -> Option { + fn peek_tail(@mut self) -> Option { self.peek_tail_n().map (|nobe| nobe.data) } /// Get data at the list's head, failing if empty. O(1). - pure fn head(@mut self) -> T { self.head_n().data } + fn head(@mut self) -> T { self.head_n().data } /// Get data at the list's tail, failing if empty. O(1). - pure fn tail(@mut self) -> T { self.tail_n().data } + fn tail(@mut self) -> T { self.tail_n().data } /// Get the elements of the list as a vector. O(n). - pure fn to_vec(@mut self) -> ~[T] { + fn to_vec(@mut self) -> ~[T] { let mut v = vec::with_capacity(self.size); unsafe { // Take this out of the unchecked when iter's functions are pure @@ -507,7 +507,7 @@ impl BaseIter for @mut DList { * allow for e.g. breadth-first search with in-place enqueues), but * removing the current node is forbidden. */ - pure fn each(&self, f: &fn(v: &T) -> bool) { + fn each(&self, f: &fn(v: &T) -> bool) { let mut link = self.peek_n(); while option::is_some(&link) { let nobe = option::get(link); @@ -536,7 +536,7 @@ impl BaseIter for @mut DList { } #[inline(always)] - pure fn size_hint(&self) -> Option { Some(self.len()) } + fn size_hint(&self) -> Option { Some(self.len()) } } #[cfg(test)] diff --git a/src/libcore/either.rs b/src/libcore/either.rs index a036c19c158..1cf2c5e1fff 100644 --- a/src/libcore/either.rs +++ b/src/libcore/either.rs @@ -87,7 +87,7 @@ pub fn partition(eithers: ~[Either]) } #[inline(always)] -pub pure fn flip(eith: Either) -> Either { +pub fn flip(eith: Either) -> Either { //! Flips between left and right of a given either match eith { @@ -97,7 +97,7 @@ pub pure fn flip(eith: Either) -> Either { } #[inline(always)] -pub pure fn to_result(eith: Either) +pub fn to_result(eith: Either) -> Result { /*! * Converts either::t to a result::t @@ -113,21 +113,21 @@ pub pure fn to_result(eith: Either) } #[inline(always)] -pub pure fn is_left(eith: &Either) -> bool { +pub fn is_left(eith: &Either) -> bool { //! Checks whether the given value is a left match *eith { Left(_) => true, _ => false } } #[inline(always)] -pub pure fn is_right(eith: &Either) -> bool { +pub fn is_right(eith: &Either) -> bool { //! Checks whether the given value is a right match *eith { Right(_) => true, _ => false } } #[inline(always)] -pub pure fn unwrap_left(eith: Either) -> T { +pub fn unwrap_left(eith: Either) -> T { //! Retrieves the value in the left branch. Fails if the either is Right. match eith { @@ -137,7 +137,7 @@ pub pure fn unwrap_left(eith: Either) -> T { } #[inline(always)] -pub pure fn unwrap_right(eith: Either) -> U { +pub fn unwrap_right(eith: Either) -> U { //! Retrieves the value in the right branch. Fails if the either is Left. match eith { diff --git a/src/libcore/from_str.rs b/src/libcore/from_str.rs index f3577d66cff..ebf6d212466 100644 --- a/src/libcore/from_str.rs +++ b/src/libcore/from_str.rs @@ -13,5 +13,5 @@ use option::Option; pub trait FromStr { - pure fn from_str(s: &str) -> Option; + fn from_str(s: &str) -> Option; } diff --git a/src/libcore/hash.rs b/src/libcore/hash.rs index 7f2189df20e..1bfa0e9522d 100644 --- a/src/libcore/hash.rs +++ b/src/libcore/hash.rs @@ -50,17 +50,17 @@ pub trait Hash { * function and require most types to only implement the * IterBytes trait, that feeds SipHash. */ - pure fn hash_keyed(&self, k0: u64, k1: u64) -> u64; + fn hash_keyed(&self, k0: u64, k1: u64) -> u64; } // When we have default methods, won't need this. pub trait HashUtil { - pure fn hash(&self) -> u64; + fn hash(&self) -> u64; } impl HashUtil for A { #[inline(always)] - pure fn hash(&self) -> u64 { self.hash_keyed(0,0) } + fn hash(&self) -> u64 { self.hash_keyed(0,0) } } /// Streaming hash-functions should implement this. @@ -75,7 +75,7 @@ pub trait Streaming { impl Hash for A { #[inline(always)] - pure fn hash_keyed(&self, k0: u64, k1: u64) -> u64 { + fn hash_keyed(&self, k0: u64, k1: u64) -> u64 { unsafe { let s = &State(k0, k1); for self.iter_bytes(true) |bytes| { @@ -86,9 +86,8 @@ impl Hash for A { } } -pure fn hash_keyed_2(a: &A, b: &B, - k0: u64, k1: u64) -> u64 { +fn hash_keyed_2(a: &A, b: &B, k0: u64, k1: u64) -> u64 { unsafe { let s = &State(k0, k1); for a.iter_bytes(true) |bytes| { s.input(bytes); } @@ -97,10 +96,9 @@ pure fn hash_keyed_2(a: &A, b: &B, c: &C, - k0: u64, k1: u64) -> u64 { +fn hash_keyed_3(a: &A, b: &B, c: &C, k0: u64, k1: u64) -> u64 { unsafe { let s = &State(k0, k1); for a.iter_bytes(true) |bytes| { s.input(bytes); } @@ -110,11 +108,11 @@ pure fn hash_keyed_3(a: &A, b: &B, c: &C, d: &D, - k0: u64, k1: u64) -> u64 { +fn hash_keyed_4(a: &A, b: &B, c: &C, d: &D, k0: u64, k1: u64) + -> u64 { unsafe { let s = &State(k0, k1); for a.iter_bytes(true) |bytes| { s.input(bytes); } @@ -125,12 +123,12 @@ pure fn hash_keyed_4(a: &A, b: &B, c: &C, d: &D, e: &E, - k0: u64, k1: u64) -> u64 { +fn hash_keyed_5(a: &A, b: &B, c: &C, d: &D, e: &E, + k0: u64, k1: u64) -> u64 { unsafe { let s = &State(k0, k1); for a.iter_bytes(true) |bytes| { s.input(bytes); } diff --git a/src/libcore/hashmap.rs b/src/libcore/hashmap.rs index 0ca7c4b540d..64806cd21aa 100644 --- a/src/libcore/hashmap.rs +++ b/src/libcore/hashmap.rs @@ -48,7 +48,7 @@ pub mod linear { } #[inline(always)] - pure fn resize_at(capacity: uint) -> uint { + fn resize_at(capacity: uint) -> uint { ((capacity as float) * 3. / 4.) as uint } @@ -59,7 +59,7 @@ pub mod linear { initial_capacity) } - pure fn linear_map_with_capacity_and_keys( + fn linear_map_with_capacity_and_keys( k0: u64, k1: u64, initial_capacity: uint) -> LinearMap { LinearMap { @@ -72,21 +72,21 @@ pub mod linear { priv impl LinearMap { #[inline(always)] - pure fn to_bucket(&self, h: uint) -> uint { + fn to_bucket(&self, h: uint) -> uint { // A good hash function with entropy spread over all of the // bits is assumed. SipHash is more than good enough. h % self.buckets.len() } #[inline(always)] - pure fn next_bucket(&self, idx: uint, len_buckets: uint) -> uint { + fn next_bucket(&self, idx: uint, len_buckets: uint) -> uint { let n = (idx + 1) % len_buckets; debug!("next_bucket(%?, %?) = %?", idx, len_buckets, n); n } #[inline(always)] - pure fn bucket_sequence(&self, hash: uint, + fn bucket_sequence(&self, hash: uint, op: &fn(uint) -> bool) -> uint { let start_idx = self.to_bucket(hash); let len_buckets = self.buckets.len(); @@ -103,24 +103,24 @@ pub mod linear { } #[inline(always)] - pure fn bucket_for_key(&self, k: &K) -> SearchResult { + fn bucket_for_key(&self, k: &K) -> SearchResult { let hash = k.hash_keyed(self.k0, self.k1) as uint; self.bucket_for_key_with_hash(hash, k) } #[inline(always)] - pure fn bucket_for_key_equiv>( - &self, - k: &Q) - -> SearchResult { + fn bucket_for_key_equiv>(&self, + k: &Q) + -> SearchResult { let hash = k.hash_keyed(self.k0, self.k1) as uint; self.bucket_for_key_with_hash_equiv(hash, k) } #[inline(always)] - pure fn bucket_for_key_with_hash(&self, - hash: uint, - k: &K) -> SearchResult { + fn bucket_for_key_with_hash(&self, + hash: uint, + k: &K) + -> SearchResult { let _ = for self.bucket_sequence(hash) |i| { match self.buckets[i] { Some(ref bkt) => if bkt.hash == hash && *k == bkt.key { @@ -133,10 +133,10 @@ pub mod linear { } #[inline(always)] - pure fn bucket_for_key_with_hash_equiv>(&self, - hash: uint, - k: &Q) - -> SearchResult { + fn bucket_for_key_with_hash_equiv>(&self, + hash: uint, + k: &Q) + -> SearchResult { let _ = for self.bucket_sequence(hash) |i| { match self.buckets[i] { Some(ref bkt) => { @@ -185,7 +185,7 @@ pub mod linear { } #[inline(always)] - pure fn value_for_bucket(&self, idx: uint) -> &'self V { + fn value_for_bucket(&self, idx: uint) -> &'self V { match self.buckets[idx] { Some(ref bkt) => &bkt.value, None => fail!(~"LinearMap::find: internal logic error"), @@ -273,7 +273,7 @@ pub mod linear { BaseIter<(&'self K, &'self V)> for LinearMap { /// Visit all key-value pairs - pure fn each(&self, blk: &fn(&(&'self K, &'self V)) -> bool) { + fn each(&self, blk: &fn(&(&'self K, &'self V)) -> bool) { for uint::range(0, self.buckets.len()) |i| { let mut broke = false; do self.buckets[i].map |bucket| { @@ -284,16 +284,16 @@ pub mod linear { if broke { break; } } } - pure fn size_hint(&self) -> Option { Some(self.len()) } + fn size_hint(&self) -> Option { Some(self.len()) } } impl Container for LinearMap { /// Return the number of elements in the map - pure fn len(&const self) -> uint { self.size } + fn len(&const self) -> uint { self.size } /// Return true if the map contains no elements - pure fn is_empty(&const self) -> bool { self.len() == 0 } + fn is_empty(&const self) -> bool { self.len() == 0 } } impl Mutable for LinearMap { @@ -308,7 +308,7 @@ pub mod linear { impl Map for LinearMap { /// Return true if the map contains a value for the specified key - pure fn contains_key(&self, k: &K) -> bool { + fn contains_key(&self, k: &K) -> bool { match self.bucket_for_key(k) { FoundEntry(_) => {true} TableFull | FoundHole(_) => {false} @@ -316,12 +316,12 @@ pub mod linear { } /// Visit all keys - pure fn each_key(&self, blk: &fn(k: &K) -> bool) { + fn each_key(&self, blk: &fn(k: &K) -> bool) { self.each(|&(k, _)| blk(k)) } /// Visit all values - pure fn each_value(&self, blk: &fn(v: &V) -> bool) { + fn each_value(&self, blk: &fn(v: &V) -> bool) { self.each(|&(_, v)| blk(v)) } @@ -339,7 +339,7 @@ pub mod linear { } /// Return the value corresponding to the key in the map - pure fn find(&self, k: &K) -> Option<&'self V> { + fn find(&self, k: &K) -> Option<&'self V> { match self.bucket_for_key(k) { FoundEntry(idx) => Some(self.value_for_bucket(idx)), TableFull | FoundHole(_) => None, @@ -487,7 +487,7 @@ pub mod linear { } } - pure fn get(&self, k: &K) -> &'self V { + fn get(&self, k: &K) -> &'self V { match self.find(k) { Some(v) => v, None => fail!(fmt!("No entry found for key: %?", k)), @@ -496,10 +496,8 @@ pub mod linear { /// Return true if the map contains a value for the specified key, /// using equivalence - pure fn contains_key_equiv>( - &self, - key: &Q) - -> bool { + fn contains_key_equiv>(&self, key: &Q) + -> bool { match self.bucket_for_key_equiv(key) { FoundEntry(_) => {true} TableFull | FoundHole(_) => {false} @@ -508,8 +506,8 @@ pub mod linear { /// Return the value corresponding to the key in the map, using /// equivalence - pure fn find_equiv>(&self, k: &Q) - -> Option<&'self V> { + fn find_equiv>(&self, k: &Q) + -> Option<&'self V> { match self.bucket_for_key_equiv(k) { FoundEntry(idx) => Some(self.value_for_bucket(idx)), TableFull | FoundHole(_) => None, @@ -518,7 +516,7 @@ pub mod linear { } impl Eq for LinearMap { - pure fn eq(&self, other: &LinearMap) -> bool { + fn eq(&self, other: &LinearMap) -> bool { if self.len() != other.len() { return false; } for self.each |&(key, value)| { @@ -531,7 +529,7 @@ pub mod linear { true } - pure fn ne(&self, other: &LinearMap) -> bool { !self.eq(other) } + fn ne(&self, other: &LinearMap) -> bool { !self.eq(other) } } pub struct LinearSet { @@ -540,25 +538,21 @@ pub mod linear { impl BaseIter for LinearSet { /// Visit all values in order - pure fn each(&self, f: &fn(&T) -> bool) { self.map.each_key(f) } - pure fn size_hint(&self) -> Option { Some(self.len()) } + fn each(&self, f: &fn(&T) -> bool) { self.map.each_key(f) } + fn size_hint(&self) -> Option { Some(self.len()) } } impl Eq for LinearSet { - pure fn eq(&self, other: &LinearSet) -> bool { - self.map == other.map - } - pure fn ne(&self, other: &LinearSet) -> bool { - self.map != other.map - } + fn eq(&self, other: &LinearSet) -> bool { self.map == other.map } + fn ne(&self, other: &LinearSet) -> bool { self.map != other.map } } impl Container for LinearSet { /// Return the number of elements in the set - pure fn len(&const self) -> uint { self.map.len() } + fn len(&const self) -> uint { self.map.len() } /// Return true if the set contains no elements - pure fn is_empty(&const self) -> bool { self.map.is_empty() } + fn is_empty(&const self) -> bool { self.map.is_empty() } } impl Mutable for LinearSet { @@ -568,9 +562,7 @@ pub mod linear { impl Set for LinearSet { /// Return true if the set contains a value - pure fn contains(&self, value: &T) -> bool { - self.map.contains_key(value) - } + fn contains(&self, value: &T) -> bool { self.map.contains_key(value) } /// Add a value to the set. Return true if the value was not already /// present in the set. @@ -582,22 +574,22 @@ pub mod linear { /// Return true if the set has no elements in common with `other`. /// This is equivalent to checking for an empty intersection. - pure fn is_disjoint(&self, other: &LinearSet) -> bool { + fn is_disjoint(&self, other: &LinearSet) -> bool { iter::all(self, |v| !other.contains(v)) } /// Return true if the set is a subset of another - pure fn is_subset(&self, other: &LinearSet) -> bool { + fn is_subset(&self, other: &LinearSet) -> bool { iter::all(self, |v| other.contains(v)) } /// Return true if the set is a superset of another - pure fn is_superset(&self, other: &LinearSet) -> bool { + fn is_superset(&self, other: &LinearSet) -> bool { other.is_subset(self) } /// Visit the values representing the difference - pure fn difference(&self, other: &LinearSet, f: &fn(&T) -> bool) { + fn difference(&self, other: &LinearSet, f: &fn(&T) -> bool) { for self.each |v| { if !other.contains(v) { if !f(v) { return } @@ -606,16 +598,15 @@ pub mod linear { } /// Visit the values representing the symmetric difference - pure fn symmetric_difference(&self, other: &LinearSet, - f: &fn(&T) -> bool) { + fn symmetric_difference(&self, + other: &LinearSet, + f: &fn(&T) -> bool) { self.difference(other, f); other.difference(self, f); } /// Visit the values representing the intersection - pure fn intersection(&self, - other: &LinearSet, - f: &fn(&T) -> bool) { + fn intersection(&self, other: &LinearSet, f: &fn(&T) -> bool) { for self.each |v| { if other.contains(v) { if !f(v) { return } @@ -624,7 +615,7 @@ pub mod linear { } /// Visit the values representing the union - pure fn union(&self, other: &LinearSet, f: &fn(&T) -> bool) { + fn union(&self, other: &LinearSet, f: &fn(&T) -> bool) { for self.each |v| { if !f(v) { return } } diff --git a/src/libcore/io.rs b/src/libcore/io.rs index 833eb7d2c77..fb305560ba3 100644 --- a/src/libcore/io.rs +++ b/src/libcore/io.rs @@ -646,11 +646,11 @@ impl Reader for BytesReader<'self> { fn tell(&self) -> uint { self.pos } } -pub pure fn with_bytes_reader(bytes: &[u8], f: &fn(@Reader) -> t) -> t { +pub fn with_bytes_reader(bytes: &[u8], f: &fn(@Reader) -> t) -> t { f(@BytesReader { bytes: bytes, pos: 0u } as @Reader) } -pub pure fn with_str_reader(s: &str, f: &fn(@Reader) -> T) -> T { +pub fn with_str_reader(s: &str, f: &fn(@Reader) -> T) -> T { str::byte_slice(s, |bytes| with_bytes_reader(bytes, f)) } @@ -1165,18 +1165,18 @@ impl Writer for BytesWriter { fn get_type(&self) -> WriterType { File } } -pub pure fn BytesWriter() -> BytesWriter { +pub fn BytesWriter() -> BytesWriter { BytesWriter { bytes: ~[], mut pos: 0u } } -pub pure fn with_bytes_writer(f: &fn(@Writer)) -> ~[u8] { +pub fn with_bytes_writer(f: &fn(@Writer)) -> ~[u8] { let wr = @BytesWriter(); f(wr as @Writer); let @BytesWriter{bytes, _} = wr; return bytes; } -pub pure fn with_str_writer(f: &fn(@Writer)) -> ~str { +pub fn with_str_writer(f: &fn(@Writer)) -> ~str { let mut v = with_bytes_writer(f); // FIXME (#3758): This should not be needed. diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs index 2042584add7..f94c62d23ec 100644 --- a/src/libcore/iter.rs +++ b/src/libcore/iter.rs @@ -23,12 +23,12 @@ use vec; pub type InitOp = &'self fn(uint) -> T; pub trait BaseIter { - pure fn each(&self, blk: &fn(v: &A) -> bool); - pure fn size_hint(&self) -> Option; + fn each(&self, blk: &fn(v: &A) -> bool); + fn size_hint(&self) -> Option; } pub trait ReverseIter: BaseIter { - pure fn each_reverse(&self, blk: &fn(&A) -> bool); + fn each_reverse(&self, blk: &fn(&A) -> bool); } pub trait MutableIter: BaseIter { @@ -36,41 +36,40 @@ pub trait MutableIter: BaseIter { } pub trait ExtendedIter { - pure fn eachi(&self, blk: &fn(uint, v: &A) -> bool); - pure fn all(&self, blk: &fn(&A) -> bool) -> bool; - pure fn any(&self, blk: &fn(&A) -> bool) -> bool; - pure fn foldl(&self, b0: B, blk: &fn(&B, &A) -> B) -> B; - pure fn position(&self, f: &fn(&A) -> bool) -> Option; - pure fn map_to_vec(&self, op: &fn(&A) -> B) -> ~[B]; - pure fn flat_map_to_vec>(&self, op: &fn(&A) -> IB) - -> ~[B]; + fn eachi(&self, blk: &fn(uint, v: &A) -> bool); + fn all(&self, blk: &fn(&A) -> bool) -> bool; + fn any(&self, blk: &fn(&A) -> bool) -> bool; + fn foldl(&self, b0: B, blk: &fn(&B, &A) -> B) -> B; + fn position(&self, f: &fn(&A) -> bool) -> Option; + fn map_to_vec(&self, op: &fn(&A) -> B) -> ~[B]; + fn flat_map_to_vec>(&self, op: &fn(&A) -> IB) -> ~[B]; } pub trait EqIter { - pure fn contains(&self, x: &A) -> bool; - pure fn count(&self, x: &A) -> uint; + fn contains(&self, x: &A) -> bool; + fn count(&self, x: &A) -> uint; } pub trait Times { - pure fn times(&self, it: &fn() -> bool); + fn times(&self, it: &fn() -> bool); } pub trait CopyableIter { - pure fn filter_to_vec(&self, pred: &fn(&A) -> bool) -> ~[A]; - pure fn to_vec(&self) -> ~[A]; - pure fn find(&self, p: &fn(&A) -> bool) -> Option; + fn filter_to_vec(&self, pred: &fn(&A) -> bool) -> ~[A]; + fn to_vec(&self) -> ~[A]; + fn find(&self, p: &fn(&A) -> bool) -> Option; } pub trait CopyableOrderedIter { - pure fn min(&self) -> A; - pure fn max(&self) -> A; + fn min(&self) -> A; + fn max(&self) -> A; } pub trait CopyableNonstrictIter { // Like "each", but copies out the value. If the receiver is mutated while // iterating over it, the semantics must not be memory-unsafe but are // otherwise undefined. - pure fn each_val(&const self, f: &fn(A) -> bool); + fn each_val(&const self, f: &fn(A) -> bool); } // A trait for sequences that can be built by imperatively pushing elements @@ -89,13 +88,11 @@ pub trait Buildable { * as an argument a function that will push an element * onto the sequence being constructed. */ - pure fn build_sized(size: uint, - builder: &fn(push: &pure fn(A))) -> Self; + fn build_sized(size: uint, builder: &fn(push: &fn(A))) -> Self; } #[inline(always)] -pub pure fn eachi>(self: &IA, - blk: &fn(uint, &A) -> bool) { +pub fn eachi>(self: &IA, blk: &fn(uint, &A) -> bool) { let mut i = 0; for self.each |a| { if !blk(i, a) { break; } @@ -104,8 +101,7 @@ pub pure fn eachi>(self: &IA, } #[inline(always)] -pub pure fn all>(self: &IA, - blk: &fn(&A) -> bool) -> bool { +pub fn all>(self: &IA, blk: &fn(&A) -> bool) -> bool { for self.each |a| { if !blk(a) { return false; } } @@ -113,8 +109,7 @@ pub pure fn all>(self: &IA, } #[inline(always)] -pub pure fn any>(self: &IA, - blk: &fn(&A) -> bool) -> bool { +pub fn any>(self: &IA, blk: &fn(&A) -> bool) -> bool { for self.each |a| { if blk(a) { return true; } } @@ -122,8 +117,9 @@ pub pure fn any>(self: &IA, } #[inline(always)] -pub pure fn filter_to_vec>( - self: &IA, prd: &fn(&A) -> bool) -> ~[A] { +pub fn filter_to_vec>(self: &IA, + prd: &fn(&A) -> bool) + -> ~[A] { do vec::build_sized_opt(self.size_hint()) |push| { for self.each |a| { if prd(a) { push(*a); } @@ -132,9 +128,7 @@ pub pure fn filter_to_vec>( } #[inline(always)] -pub pure fn map_to_vec>(self: &IA, - op: &fn(&A) -> B) - -> ~[B] { +pub fn map_to_vec>(self: &IA, op: &fn(&A) -> B) -> ~[B] { do vec::build_sized_opt(self.size_hint()) |push| { for self.each |a| { push(op(a)); @@ -143,8 +137,9 @@ pub pure fn map_to_vec>(self: &IA, } #[inline(always)] -pub pure fn flat_map_to_vec,IB:BaseIter>( - self: &IA, op: &fn(&A) -> IB) -> ~[B] { +pub fn flat_map_to_vec,IB:BaseIter>(self: &IA, + op: &fn(&A) -> IB) + -> ~[B] { do vec::build |push| { for self.each |a| { for op(a).each |&b| { @@ -155,9 +150,8 @@ pub pure fn flat_map_to_vec,IB:BaseIter>( } #[inline(always)] -pub pure fn foldl>(self: &IA, b0: B, - blk: &fn(&B, &A) -> B) - -> B { +pub fn foldl>(self: &IA, b0: B, blk: &fn(&B, &A) -> B) + -> B { let mut b = b0; for self.each |a| { b = blk(&b, a); @@ -166,12 +160,12 @@ pub pure fn foldl>(self: &IA, b0: B, } #[inline(always)] -pub pure fn to_vec>(self: &IA) -> ~[A] { +pub fn to_vec>(self: &IA) -> ~[A] { foldl::(self, ~[], |r, a| vec::append(copy (*r), ~[*a])) } #[inline(always)] -pub pure fn contains>(self: &IA, x: &A) -> bool { +pub fn contains>(self: &IA, x: &A) -> bool { for self.each |a| { if *a == *x { return true; } } @@ -179,7 +173,7 @@ pub pure fn contains>(self: &IA, x: &A) -> bool { } #[inline(always)] -pub pure fn count>(self: &IA, x: &A) -> uint { +pub fn count>(self: &IA, x: &A) -> uint { do foldl(self, 0) |count, value| { if *value == *x { *count + 1 @@ -190,9 +184,8 @@ pub pure fn count>(self: &IA, x: &A) -> uint { } #[inline(always)] -pub pure fn position>(self: &IA, f: &fn(&A) -> bool) - -> Option -{ +pub fn position>(self: &IA, f: &fn(&A) -> bool) + -> Option { let mut i = 0; for self.each |a| { if f(a) { return Some(i); } @@ -206,7 +199,7 @@ pub pure fn position>(self: &IA, f: &fn(&A) -> bool) // it would have to be implemented with foldr, which is too inefficient. #[inline(always)] -pub pure fn repeat(times: uint, blk: &fn() -> bool) { +pub fn repeat(times: uint, blk: &fn() -> bool) { let mut i = 0; while i < times { if !blk() { break } @@ -215,7 +208,7 @@ pub pure fn repeat(times: uint, blk: &fn() -> bool) { } #[inline(always)] -pub pure fn min>(self: &IA) -> A { +pub fn min>(self: &IA) -> A { match do foldl::,IA>(self, None) |a, b| { match a { &Some(ref a_) if *a_ < *b => { @@ -230,7 +223,7 @@ pub pure fn min>(self: &IA) -> A { } #[inline(always)] -pub pure fn max>(self: &IA) -> A { +pub fn max>(self: &IA) -> A { match do foldl::,IA>(self, None) |a, b| { match a { &Some(ref a_) if *a_ > *b => { @@ -245,8 +238,8 @@ pub pure fn max>(self: &IA) -> A { } #[inline(always)] -pub pure fn find>(self: &IA, - f: &fn(&A) -> bool) -> Option { +pub fn find>(self: &IA, f: &fn(&A) -> bool) + -> Option { for self.each |i| { if f(i) { return Some(*i) } } @@ -266,8 +259,7 @@ pub pure fn find>(self: &IA, * onto the sequence being constructed. */ #[inline(always)] -pub pure fn build>(builder: &fn(push: &pure fn(A))) - -> B { +pub fn build>(builder: &fn(push: &fn(A))) -> B { Buildable::build_sized(4, builder) } @@ -285,10 +277,8 @@ pub pure fn build>(builder: &fn(push: &pure fn(A))) * onto the sequence being constructed. */ #[inline(always)] -pub pure fn build_sized_opt>( - size: Option, - builder: &fn(push: &pure fn(A))) -> B { - +pub fn build_sized_opt>(size: Option, + builder: &fn(push: &fn(A))) -> B { Buildable::build_sized(size.get_or_default(4), builder) } @@ -312,8 +302,7 @@ pub fn map,U,BU: Buildable>(v: &IT, f: &fn(&T) -> U) * to the value returned by the function `op`. */ #[inline(always)] -pub pure fn from_fn>(n_elts: uint, - op: InitOp) -> BT { +pub fn from_fn>(n_elts: uint, op: InitOp) -> BT { do Buildable::build_sized(n_elts) |push| { let mut i: uint = 0u; while i < n_elts { push(op(i)); i += 1u; } @@ -327,8 +316,7 @@ pub pure fn from_fn>(n_elts: uint, * to the value `t`. */ #[inline(always)] -pub pure fn from_elem>(n_elts: uint, - t: T) -> BT { +pub fn from_elem>(n_elts: uint, t: T) -> BT { do Buildable::build_sized(n_elts) |push| { let mut i: uint = 0; while i < n_elts { push(t); i += 1; } @@ -337,8 +325,8 @@ pub pure fn from_elem>(n_elts: uint, /// Appends two generic sequences. #[inline(always)] -pub pure fn append,BT:Buildable>( - lhs: &IT, rhs: &IT) -> BT { +pub fn append,BT:Buildable>(lhs: &IT, rhs: &IT) + -> BT { let size_opt = lhs.size_hint().chain_ref( |sz1| rhs.size_hint().map(|sz2| *sz1+*sz2)); do build_sized_opt(size_opt) |push| { @@ -350,8 +338,7 @@ pub pure fn append,BT:Buildable>( /// Copies a generic sequence, possibly converting it to a different /// type of sequence. #[inline(always)] -pub pure fn copy_seq,BT:Buildable>( - v: &IT) -> BT { +pub fn copy_seq,BT:Buildable>(v: &IT) -> BT { do build_sized_opt(v.size_hint()) |push| { for v.each |x| { push(*x); } } diff --git a/src/libcore/managed.rs b/src/libcore/managed.rs index b177dced888..30ebeda3f5c 100644 --- a/src/libcore/managed.rs +++ b/src/libcore/managed.rs @@ -37,13 +37,13 @@ pub mod raw { } #[inline(always)] -pub pure fn ptr_eq(a: @T, b: @T) -> bool { +pub fn ptr_eq(a: @T, b: @T) -> bool { //! Determine if two shared boxes point to the same object unsafe { ptr::addr_of(&(*a)) == ptr::addr_of(&(*b)) } } #[inline(always)] -pub pure fn mut_ptr_eq(a: @mut T, b: @mut T) -> bool { +pub fn mut_ptr_eq(a: @mut T, b: @mut T) -> bool { //! Determine if two mutable shared boxes point to the same object unsafe { ptr::addr_of(&(*a)) == ptr::addr_of(&(*b)) } } @@ -51,41 +51,41 @@ pub pure fn mut_ptr_eq(a: @mut T, b: @mut T) -> bool { #[cfg(notest)] impl Eq for @T { #[inline(always)] - pure fn eq(&self, other: &@T) -> bool { *(*self) == *(*other) } + fn eq(&self, other: &@T) -> bool { *(*self) == *(*other) } #[inline(always)] - pure fn ne(&self, other: &@T) -> bool { *(*self) != *(*other) } + fn ne(&self, other: &@T) -> bool { *(*self) != *(*other) } } #[cfg(notest)] impl Eq for @mut T { #[inline(always)] - pure fn eq(&self, other: &@mut T) -> bool { *(*self) == *(*other) } + fn eq(&self, other: &@mut T) -> bool { *(*self) == *(*other) } #[inline(always)] - pure fn ne(&self, other: &@mut T) -> bool { *(*self) != *(*other) } + fn ne(&self, other: &@mut T) -> bool { *(*self) != *(*other) } } #[cfg(notest)] impl Ord for @T { #[inline(always)] - pure fn lt(&self, other: &@T) -> bool { *(*self) < *(*other) } + fn lt(&self, other: &@T) -> bool { *(*self) < *(*other) } #[inline(always)] - pure fn le(&self, other: &@T) -> bool { *(*self) <= *(*other) } + fn le(&self, other: &@T) -> bool { *(*self) <= *(*other) } #[inline(always)] - pure fn ge(&self, other: &@T) -> bool { *(*self) >= *(*other) } + fn ge(&self, other: &@T) -> bool { *(*self) >= *(*other) } #[inline(always)] - pure fn gt(&self, other: &@T) -> bool { *(*self) > *(*other) } + fn gt(&self, other: &@T) -> bool { *(*self) > *(*other) } } #[cfg(notest)] impl Ord for @mut T { #[inline(always)] - pure fn lt(&self, other: &@mut T) -> bool { *(*self) < *(*other) } + fn lt(&self, other: &@mut T) -> bool { *(*self) < *(*other) } #[inline(always)] - pure fn le(&self, other: &@mut T) -> bool { *(*self) <= *(*other) } + fn le(&self, other: &@mut T) -> bool { *(*self) <= *(*other) } #[inline(always)] - pure fn ge(&self, other: &@mut T) -> bool { *(*self) >= *(*other) } + fn ge(&self, other: &@mut T) -> bool { *(*self) >= *(*other) } #[inline(always)] - pure fn gt(&self, other: &@mut T) -> bool { *(*self) > *(*other) } + fn gt(&self, other: &@mut T) -> bool { *(*self) > *(*other) } } #[test] diff --git a/src/libcore/mutable.rs b/src/libcore/mutable.rs index d0aa6e050f5..fc4e52891dd 100644 --- a/src/libcore/mutable.rs +++ b/src/libcore/mutable.rs @@ -55,7 +55,7 @@ pub impl Data { } } - pure fn borrow_const(&self, op: &fn(t: &const T) -> R) -> R { + fn borrow_const(&self, op: &fn(t: &const T) -> R) -> R { op(&const self.value) } diff --git a/src/libcore/nil.rs b/src/libcore/nil.rs index 742e5a047d6..8c52ac9593a 100644 --- a/src/libcore/nil.rs +++ b/src/libcore/nil.rs @@ -20,25 +20,25 @@ use cmp::{Eq, Ord, TotalOrd, Ordering, Equal}; #[cfg(notest)] impl Eq for () { #[inline(always)] - pure fn eq(&self, _other: &()) -> bool { true } + fn eq(&self, _other: &()) -> bool { true } #[inline(always)] - pure fn ne(&self, _other: &()) -> bool { false } + fn ne(&self, _other: &()) -> bool { false } } #[cfg(notest)] impl Ord for () { #[inline(always)] - pure fn lt(&self, _other: &()) -> bool { false } + fn lt(&self, _other: &()) -> bool { false } #[inline(always)] - pure fn le(&self, _other: &()) -> bool { true } + fn le(&self, _other: &()) -> bool { true } #[inline(always)] - pure fn ge(&self, _other: &()) -> bool { true } + fn ge(&self, _other: &()) -> bool { true } #[inline(always)] - pure fn gt(&self, _other: &()) -> bool { false } + fn gt(&self, _other: &()) -> bool { false } } #[cfg(notest)] impl TotalOrd for () { #[inline(always)] - pure fn cmp(&self, _other: &()) -> Ordering { Equal } + fn cmp(&self, _other: &()) -> Ordering { Equal } } diff --git a/src/libcore/num/f32.rs b/src/libcore/num/f32.rs index d7f0b4be621..719e5620d02 100644 --- a/src/libcore/num/f32.rs +++ b/src/libcore/num/f32.rs @@ -33,7 +33,7 @@ macro_rules! delegate( ),* ) -> $rv:ty = $bound_name:path ) => ( - pub pure fn $name($( $arg : $arg_ty ),*) -> $rv { + pub fn $name($( $arg : $arg_ty ),*) -> $rv { unsafe { $bound_name($( $arg ),*) } @@ -109,57 +109,59 @@ pub const infinity: f32 = 1.0_f32/0.0_f32; pub const neg_infinity: f32 = -1.0_f32/0.0_f32; #[inline(always)] -pub pure fn is_NaN(f: f32) -> bool { f != f } +pub fn is_NaN(f: f32) -> bool { f != f } #[inline(always)] -pub pure fn add(x: f32, y: f32) -> f32 { return x + y; } +pub fn add(x: f32, y: f32) -> f32 { return x + y; } #[inline(always)] -pub pure fn sub(x: f32, y: f32) -> f32 { return x - y; } +pub fn sub(x: f32, y: f32) -> f32 { return x - y; } #[inline(always)] -pub pure fn mul(x: f32, y: f32) -> f32 { return x * y; } +pub fn mul(x: f32, y: f32) -> f32 { return x * y; } #[inline(always)] -pub pure fn div(x: f32, y: f32) -> f32 { return x / y; } +pub fn div(x: f32, y: f32) -> f32 { return x / y; } #[inline(always)] -pub pure fn rem(x: f32, y: f32) -> f32 { return x % y; } +pub fn rem(x: f32, y: f32) -> f32 { return x % y; } #[inline(always)] -pub pure fn lt(x: f32, y: f32) -> bool { return x < y; } +pub fn lt(x: f32, y: f32) -> bool { return x < y; } #[inline(always)] -pub pure fn le(x: f32, y: f32) -> bool { return x <= y; } +pub fn le(x: f32, y: f32) -> bool { return x <= y; } #[inline(always)] -pub pure fn eq(x: f32, y: f32) -> bool { return x == y; } +pub fn eq(x: f32, y: f32) -> bool { return x == y; } #[inline(always)] -pub pure fn ne(x: f32, y: f32) -> bool { return x != y; } +pub fn ne(x: f32, y: f32) -> bool { return x != y; } #[inline(always)] -pub pure fn ge(x: f32, y: f32) -> bool { return x >= y; } +pub fn ge(x: f32, y: f32) -> bool { return x >= y; } #[inline(always)] -pub pure fn gt(x: f32, y: f32) -> bool { return x > y; } +pub fn gt(x: f32, y: f32) -> bool { return x > y; } /// Returns `x` rounded down #[inline(always)] -pub pure fn floor(x: f32) -> f32 { unsafe { floorf32(x) } } +pub fn floor(x: f32) -> f32 { unsafe { floorf32(x) } } // 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 #[inline(always)] -pub pure fn is_positive(x: f32) -> bool - { return x > 0.0f32 || (1.0f32/x) == infinity; } +pub fn is_positive(x: f32) -> bool { + x > 0.0f32 || (1.0f32/x) == infinity +} /// Returns true if `x` is a negative number, including -0.0f320 and -Infinity #[inline(always)] -pub pure fn is_negative(x: f32) -> bool - { return x < 0.0f32 || (1.0f32/x) == neg_infinity; } +pub fn is_negative(x: f32) -> bool { + x < 0.0f32 || (1.0f32/x) == neg_infinity +} /** * Returns true if `x` is a negative number, including -0.0f320 and -Infinity @@ -167,7 +169,7 @@ pub pure fn is_negative(x: f32) -> bool * This is the same as `f32::is_negative`. */ #[inline(always)] -pub pure fn is_nonpositive(x: f32) -> bool { +pub fn is_nonpositive(x: f32) -> bool { return x < 0.0f32 || (1.0f32/x) == neg_infinity; } @@ -177,25 +179,25 @@ pub pure fn is_nonpositive(x: f32) -> bool { * This is the same as `f32::is_positive`.) */ #[inline(always)] -pub pure fn is_nonnegative(x: f32) -> bool { +pub fn is_nonnegative(x: f32) -> bool { return x > 0.0f32 || (1.0f32/x) == infinity; } /// Returns true if `x` is a zero number (positive or negative zero) #[inline(always)] -pub pure fn is_zero(x: f32) -> bool { +pub fn is_zero(x: f32) -> bool { return x == 0.0f32 || x == -0.0f32; } /// Returns true if `x`is an infinite number #[inline(always)] -pub pure fn is_infinite(x: f32) -> bool { +pub fn is_infinite(x: f32) -> bool { return x == infinity || x == neg_infinity; } /// Returns true if `x`is a finite number #[inline(always)] -pub pure fn is_finite(x: f32) -> bool { +pub fn is_finite(x: f32) -> bool { return !(is_NaN(x) || is_infinite(x)); } @@ -246,43 +248,43 @@ pub mod consts { } #[inline(always)] -pub pure fn signbit(x: f32) -> int { +pub fn signbit(x: f32) -> int { if is_negative(x) { return 1; } else { return 0; } } #[inline(always)] -pub pure fn logarithm(n: f32, b: f32) -> f32 { +pub fn logarithm(n: f32, b: f32) -> f32 { return log2(n) / log2(b); } #[cfg(notest)] impl cmp::Eq for f32 { #[inline(always)] - pure fn eq(&self, other: &f32) -> bool { (*self) == (*other) } + fn eq(&self, other: &f32) -> bool { (*self) == (*other) } #[inline(always)] - pure fn ne(&self, other: &f32) -> bool { (*self) != (*other) } + fn ne(&self, other: &f32) -> bool { (*self) != (*other) } } #[cfg(notest)] impl cmp::Ord for f32 { #[inline(always)] - pure fn lt(&self, other: &f32) -> bool { (*self) < (*other) } + fn lt(&self, other: &f32) -> bool { (*self) < (*other) } #[inline(always)] - pure fn le(&self, other: &f32) -> bool { (*self) <= (*other) } + fn le(&self, other: &f32) -> bool { (*self) <= (*other) } #[inline(always)] - pure fn ge(&self, other: &f32) -> bool { (*self) >= (*other) } + fn ge(&self, other: &f32) -> bool { (*self) >= (*other) } #[inline(always)] - pure fn gt(&self, other: &f32) -> bool { (*self) > (*other) } + fn gt(&self, other: &f32) -> bool { (*self) > (*other) } } impl num::Zero for f32 { #[inline(always)] - pure fn zero() -> f32 { 0.0 } + fn zero() -> f32 { 0.0 } } impl num::One for f32 { #[inline(always)] - pure fn one() -> f32 { 1.0 } + fn one() -> f32 { 1.0 } } impl NumCast for f32 { @@ -290,53 +292,53 @@ impl NumCast for f32 { * Cast `n` to an `f32` */ #[inline(always)] - pure fn from(n: N) -> f32 { n.to_f32() } + fn from(n: N) -> f32 { n.to_f32() } - #[inline(always)] pure fn to_u8(&self) -> u8 { *self as u8 } - #[inline(always)] pure fn to_u16(&self) -> u16 { *self as u16 } - #[inline(always)] pure fn to_u32(&self) -> u32 { *self as u32 } - #[inline(always)] pure fn to_u64(&self) -> u64 { *self as u64 } - #[inline(always)] pure fn to_uint(&self) -> uint { *self as uint } + #[inline(always)] fn to_u8(&self) -> u8 { *self as u8 } + #[inline(always)] fn to_u16(&self) -> u16 { *self as u16 } + #[inline(always)] fn to_u32(&self) -> u32 { *self as u32 } + #[inline(always)] fn to_u64(&self) -> u64 { *self as u64 } + #[inline(always)] fn to_uint(&self) -> uint { *self as uint } - #[inline(always)] pure fn to_i8(&self) -> i8 { *self as i8 } - #[inline(always)] pure fn to_i16(&self) -> i16 { *self as i16 } - #[inline(always)] pure fn to_i32(&self) -> i32 { *self as i32 } - #[inline(always)] pure fn to_i64(&self) -> i64 { *self as i64 } - #[inline(always)] pure fn to_int(&self) -> int { *self as int } + #[inline(always)] fn to_i8(&self) -> i8 { *self as i8 } + #[inline(always)] fn to_i16(&self) -> i16 { *self as i16 } + #[inline(always)] fn to_i32(&self) -> i32 { *self as i32 } + #[inline(always)] fn to_i64(&self) -> i64 { *self as i64 } + #[inline(always)] fn to_int(&self) -> int { *self as int } - #[inline(always)] pure fn to_f32(&self) -> f32 { *self } - #[inline(always)] pure fn to_f64(&self) -> f64 { *self as f64 } - #[inline(always)] pure fn to_float(&self) -> float { *self as float } + #[inline(always)] fn to_f32(&self) -> f32 { *self } + #[inline(always)] fn to_f64(&self) -> f64 { *self as f64 } + #[inline(always)] fn to_float(&self) -> float { *self as float } } #[cfg(notest)] impl ops::Add for f32 { - pure fn add(&self, other: &f32) -> f32 { *self + *other } + fn add(&self, other: &f32) -> f32 { *self + *other } } #[cfg(notest)] impl ops::Sub for f32 { - pure fn sub(&self, other: &f32) -> f32 { *self - *other } + fn sub(&self, other: &f32) -> f32 { *self - *other } } #[cfg(notest)] impl ops::Mul for f32 { - pure fn mul(&self, other: &f32) -> f32 { *self * *other } + fn mul(&self, other: &f32) -> f32 { *self * *other } } #[cfg(notest)] impl ops::Div for f32 { - pure fn div(&self, other: &f32) -> f32 { *self / *other } + fn div(&self, other: &f32) -> f32 { *self / *other } } #[cfg(notest)] impl ops::Modulo for f32 { - pure fn modulo(&self, other: &f32) -> f32 { *self % *other } + fn modulo(&self, other: &f32) -> f32 { *self % *other } } #[cfg(notest)] impl ops::Neg for f32 { - pure fn neg(&self) -> f32 { -*self } + fn neg(&self) -> f32 { -*self } } impl num::Round for f32 { #[inline(always)] - pure fn round(&self, mode: num::RoundMode) -> f32 { + fn round(&self, mode: num::RoundMode) -> f32 { match mode { num::RoundDown => floor(*self), num::RoundUp => ceil(*self), @@ -348,11 +350,11 @@ impl num::Round for f32 { } #[inline(always)] - pure fn floor(&self) -> f32 { floor(*self) } + fn floor(&self) -> f32 { floor(*self) } #[inline(always)] - pure fn ceil(&self) -> f32 { ceil(*self) } + fn ceil(&self) -> f32 { ceil(*self) } #[inline(always)] - pure fn fract(&self) -> f32 { + fn fract(&self) -> f32 { if is_negative(*self) { (*self) - ceil(*self) } else { @@ -373,7 +375,7 @@ impl num::Round for f32 { * * num - The float value */ #[inline(always)] -pub pure fn to_str(num: f32) -> ~str { +pub fn to_str(num: f32) -> ~str { let (r, _) = strconv::to_str_common( &num, 10u, true, strconv::SignNeg, strconv::DigAll); r @@ -387,7 +389,7 @@ pub pure fn to_str(num: f32) -> ~str { * * num - The float value */ #[inline(always)] -pub pure fn to_str_hex(num: f32) -> ~str { +pub fn to_str_hex(num: f32) -> ~str { let (r, _) = strconv::to_str_common( &num, 16u, true, strconv::SignNeg, strconv::DigAll); r @@ -408,7 +410,7 @@ pub pure fn to_str_hex(num: f32) -> ~str { * are expected, use `to_str_radix_special()` instead. */ #[inline(always)] -pub pure fn to_str_radix(num: f32, rdx: uint) -> ~str { +pub fn to_str_radix(num: f32, rdx: uint) -> ~str { let (r, special) = strconv::to_str_common( &num, rdx, true, strconv::SignNeg, strconv::DigAll); if special { fail!(~"number has a special value, \ @@ -426,7 +428,7 @@ pub pure fn to_str_radix(num: f32, rdx: uint) -> ~str { * * radix - The base to use */ #[inline(always)] -pub pure fn to_str_radix_special(num: f32, rdx: uint) -> (~str, bool) { +pub fn to_str_radix_special(num: f32, rdx: uint) -> (~str, bool) { strconv::to_str_common(&num, rdx, true, strconv::SignNeg, strconv::DigAll) } @@ -441,7 +443,7 @@ pub pure fn to_str_radix_special(num: f32, rdx: uint) -> (~str, bool) { * * digits - The number of significant digits */ #[inline(always)] -pub pure fn to_str_exact(num: f32, dig: uint) -> ~str { +pub fn to_str_exact(num: f32, dig: uint) -> ~str { let (r, _) = strconv::to_str_common( &num, 10u, true, strconv::SignNeg, strconv::DigExact(dig)); r @@ -457,7 +459,7 @@ pub pure fn to_str_exact(num: f32, dig: uint) -> ~str { * * digits - The number of significant digits */ #[inline(always)] -pub pure fn to_str_digits(num: f32, dig: uint) -> ~str { +pub fn to_str_digits(num: f32, dig: uint) -> ~str { let (r, _) = strconv::to_str_common( &num, 10u, true, strconv::SignNeg, strconv::DigMax(dig)); r @@ -465,12 +467,12 @@ pub pure fn to_str_digits(num: f32, dig: uint) -> ~str { impl to_str::ToStr for f32 { #[inline(always)] - pure fn to_str(&self) -> ~str { to_str_digits(*self, 8) } + fn to_str(&self) -> ~str { to_str_digits(*self, 8) } } impl num::ToStrRadix for f32 { #[inline(always)] - pure fn to_str_radix(&self, rdx: uint) -> ~str { + fn to_str_radix(&self, rdx: uint) -> ~str { to_str_radix(*self, rdx) } } @@ -503,7 +505,7 @@ impl num::ToStrRadix for f32 { * `Some(n)` where `n` is the floating-point number represented by `num`. */ #[inline(always)] -pub pure fn from_str(num: &str) -> Option { +pub fn from_str(num: &str) -> Option { strconv::from_str_common(num, 10u, true, true, true, strconv::ExpDec, false) } @@ -536,7 +538,7 @@ pub pure fn from_str(num: &str) -> Option { * `Some(n)` where `n` is the floating-point number represented by `[num]`. */ #[inline(always)] -pub pure fn from_str_hex(num: &str) -> Option { +pub fn from_str_hex(num: &str) -> Option { strconv::from_str_common(num, 16u, true, true, true, strconv::ExpBin, false) } @@ -561,19 +563,19 @@ pub pure fn from_str_hex(num: &str) -> Option { * `Some(n)` where `n` is the floating-point number represented by `num`. */ #[inline(always)] -pub pure fn from_str_radix(num: &str, rdx: uint) -> Option { +pub fn from_str_radix(num: &str, rdx: uint) -> Option { strconv::from_str_common(num, rdx, true, true, false, strconv::ExpNone, false) } impl from_str::FromStr for f32 { #[inline(always)] - pure fn from_str(val: &str) -> Option { from_str(val) } + fn from_str(val: &str) -> Option { from_str(val) } } impl num::FromStrRadix for f32 { #[inline(always)] - pure fn from_str_radix(val: &str, rdx: uint) -> Option { + fn from_str_radix(val: &str, rdx: uint) -> Option { from_str_radix(val, rdx) } } diff --git a/src/libcore/num/f64.rs b/src/libcore/num/f64.rs index 7acb7ac462e..6a581ddfa94 100644 --- a/src/libcore/num/f64.rs +++ b/src/libcore/num/f64.rs @@ -34,7 +34,7 @@ macro_rules! delegate( ),* ) -> $rv:ty = $bound_name:path ) => ( - pub pure fn $name($( $arg : $arg_ty ),*) -> $rv { + pub fn $name($( $arg : $arg_ty ),*) -> $rv { unsafe { $bound_name($( $arg ),*) } @@ -136,49 +136,49 @@ pub const infinity: f64 = 1.0_f64/0.0_f64; pub const neg_infinity: f64 = -1.0_f64/0.0_f64; #[inline(always)] -pub pure fn is_NaN(f: f64) -> bool { f != f } +pub fn is_NaN(f: f64) -> bool { f != f } #[inline(always)] -pub pure fn add(x: f64, y: f64) -> f64 { return x + y; } +pub fn add(x: f64, y: f64) -> f64 { return x + y; } #[inline(always)] -pub pure fn sub(x: f64, y: f64) -> f64 { return x - y; } +pub fn sub(x: f64, y: f64) -> f64 { return x - y; } #[inline(always)] -pub pure fn mul(x: f64, y: f64) -> f64 { return x * y; } +pub fn mul(x: f64, y: f64) -> f64 { return x * y; } #[inline(always)] -pub pure fn div(x: f64, y: f64) -> f64 { return x / y; } +pub fn div(x: f64, y: f64) -> f64 { return x / y; } #[inline(always)] -pub pure fn rem(x: f64, y: f64) -> f64 { return x % y; } +pub fn rem(x: f64, y: f64) -> f64 { return x % y; } #[inline(always)] -pub pure fn lt(x: f64, y: f64) -> bool { return x < y; } +pub fn lt(x: f64, y: f64) -> bool { return x < y; } #[inline(always)] -pub pure fn le(x: f64, y: f64) -> bool { return x <= y; } +pub fn le(x: f64, y: f64) -> bool { return x <= y; } #[inline(always)] -pub pure fn eq(x: f64, y: f64) -> bool { return x == y; } +pub fn eq(x: f64, y: f64) -> bool { return x == y; } #[inline(always)] -pub pure fn ne(x: f64, y: f64) -> bool { return x != y; } +pub fn ne(x: f64, y: f64) -> bool { return x != y; } #[inline(always)] -pub pure fn ge(x: f64, y: f64) -> bool { return x >= y; } +pub fn ge(x: f64, y: f64) -> bool { return x >= y; } #[inline(always)] -pub pure fn gt(x: f64, y: f64) -> bool { return x > y; } +pub fn gt(x: f64, y: f64) -> bool { return x > y; } /// Returns true if `x` is a positive number, including +0.0f640 and +Infinity #[inline(always)] -pub pure fn is_positive(x: f64) -> bool +pub fn is_positive(x: f64) -> bool { return x > 0.0f64 || (1.0f64/x) == infinity; } /// Returns true if `x` is a negative number, including -0.0f640 and -Infinity #[inline(always)] -pub pure fn is_negative(x: f64) -> bool +pub fn is_negative(x: f64) -> bool { return x < 0.0f64 || (1.0f64/x) == neg_infinity; } /** @@ -187,7 +187,7 @@ pub pure fn is_negative(x: f64) -> bool * This is the same as `f64::is_negative`. */ #[inline(always)] -pub pure fn is_nonpositive(x: f64) -> bool { +pub fn is_nonpositive(x: f64) -> bool { return x < 0.0f64 || (1.0f64/x) == neg_infinity; } @@ -197,31 +197,31 @@ pub pure fn is_nonpositive(x: f64) -> bool { * This is the same as `f64::positive`. */ #[inline(always)] -pub pure fn is_nonnegative(x: f64) -> bool { +pub fn is_nonnegative(x: f64) -> bool { return x > 0.0f64 || (1.0f64/x) == infinity; } /// Returns true if `x` is a zero number (positive or negative zero) #[inline(always)] -pub pure fn is_zero(x: f64) -> bool { +pub fn is_zero(x: f64) -> bool { return x == 0.0f64 || x == -0.0f64; } /// Returns true if `x`is an infinite number #[inline(always)] -pub pure fn is_infinite(x: f64) -> bool { +pub fn is_infinite(x: f64) -> bool { return x == infinity || x == neg_infinity; } /// Returns true if `x` is a finite number #[inline(always)] -pub pure fn is_finite(x: f64) -> bool { +pub fn is_finite(x: f64) -> bool { return !(is_NaN(x) || is_infinite(x)); } /// Returns `x` rounded down #[inline(always)] -pub pure fn floor(x: f64) -> f64 { unsafe { floorf64(x) } } +pub fn floor(x: f64) -> f64 { unsafe { floorf64(x) } } // FIXME (#1999): add is_normal, is_subnormal, and fpclassify @@ -270,33 +270,33 @@ pub mod consts { } #[inline(always)] -pub pure fn signbit(x: f64) -> int { +pub fn signbit(x: f64) -> int { if is_negative(x) { return 1; } else { return 0; } } #[inline(always)] -pub pure fn logarithm(n: f64, b: f64) -> f64 { +pub fn logarithm(n: f64, b: f64) -> f64 { return log2(n) / log2(b); } #[cfg(notest)] impl cmp::Eq for f64 { #[inline(always)] - pure fn eq(&self, other: &f64) -> bool { (*self) == (*other) } + fn eq(&self, other: &f64) -> bool { (*self) == (*other) } #[inline(always)] - pure fn ne(&self, other: &f64) -> bool { (*self) != (*other) } + fn ne(&self, other: &f64) -> bool { (*self) != (*other) } } #[cfg(notest)] impl cmp::Ord for f64 { #[inline(always)] - pure fn lt(&self, other: &f64) -> bool { (*self) < (*other) } + fn lt(&self, other: &f64) -> bool { (*self) < (*other) } #[inline(always)] - pure fn le(&self, other: &f64) -> bool { (*self) <= (*other) } + fn le(&self, other: &f64) -> bool { (*self) <= (*other) } #[inline(always)] - pure fn ge(&self, other: &f64) -> bool { (*self) >= (*other) } + fn ge(&self, other: &f64) -> bool { (*self) >= (*other) } #[inline(always)] - pure fn gt(&self, other: &f64) -> bool { (*self) > (*other) } + fn gt(&self, other: &f64) -> bool { (*self) > (*other) } } impl NumCast for f64 { @@ -304,63 +304,63 @@ impl NumCast for f64 { * Cast `n` to an `f64` */ #[inline(always)] - pure fn from(n: N) -> f64 { n.to_f64() } + fn from(n: N) -> f64 { n.to_f64() } - #[inline(always)] pure fn to_u8(&self) -> u8 { *self as u8 } - #[inline(always)] pure fn to_u16(&self) -> u16 { *self as u16 } - #[inline(always)] pure fn to_u32(&self) -> u32 { *self as u32 } - #[inline(always)] pure fn to_u64(&self) -> u64 { *self as u64 } - #[inline(always)] pure fn to_uint(&self) -> uint { *self as uint } + #[inline(always)] fn to_u8(&self) -> u8 { *self as u8 } + #[inline(always)] fn to_u16(&self) -> u16 { *self as u16 } + #[inline(always)] fn to_u32(&self) -> u32 { *self as u32 } + #[inline(always)] fn to_u64(&self) -> u64 { *self as u64 } + #[inline(always)] fn to_uint(&self) -> uint { *self as uint } - #[inline(always)] pure fn to_i8(&self) -> i8 { *self as i8 } - #[inline(always)] pure fn to_i16(&self) -> i16 { *self as i16 } - #[inline(always)] pure fn to_i32(&self) -> i32 { *self as i32 } - #[inline(always)] pure fn to_i64(&self) -> i64 { *self as i64 } - #[inline(always)] pure fn to_int(&self) -> int { *self as int } + #[inline(always)] fn to_i8(&self) -> i8 { *self as i8 } + #[inline(always)] fn to_i16(&self) -> i16 { *self as i16 } + #[inline(always)] fn to_i32(&self) -> i32 { *self as i32 } + #[inline(always)] fn to_i64(&self) -> i64 { *self as i64 } + #[inline(always)] fn to_int(&self) -> int { *self as int } - #[inline(always)] pure fn to_f32(&self) -> f32 { *self as f32 } - #[inline(always)] pure fn to_f64(&self) -> f64 { *self } - #[inline(always)] pure fn to_float(&self) -> float { *self as float } + #[inline(always)] fn to_f32(&self) -> f32 { *self as f32 } + #[inline(always)] fn to_f64(&self) -> f64 { *self } + #[inline(always)] fn to_float(&self) -> float { *self as float } } impl num::Zero for f64 { #[inline(always)] - pure fn zero() -> f64 { 0.0 } + fn zero() -> f64 { 0.0 } } impl num::One for f64 { #[inline(always)] - pure fn one() -> f64 { 1.0 } + fn one() -> f64 { 1.0 } } #[cfg(notest)] impl ops::Add for f64 { - pure fn add(&self, other: &f64) -> f64 { *self + *other } + fn add(&self, other: &f64) -> f64 { *self + *other } } #[cfg(notest)] impl ops::Sub for f64 { - pure fn sub(&self, other: &f64) -> f64 { *self - *other } + fn sub(&self, other: &f64) -> f64 { *self - *other } } #[cfg(notest)] impl ops::Mul for f64 { - pure fn mul(&self, other: &f64) -> f64 { *self * *other } + fn mul(&self, other: &f64) -> f64 { *self * *other } } #[cfg(notest)] impl ops::Div for f64 { - pure fn div(&self, other: &f64) -> f64 { *self / *other } + fn div(&self, other: &f64) -> f64 { *self / *other } } #[cfg(notest)] impl ops::Modulo for f64 { - pure fn modulo(&self, other: &f64) -> f64 { *self % *other } + fn modulo(&self, other: &f64) -> f64 { *self % *other } } #[cfg(notest)] impl ops::Neg for f64 { - pure fn neg(&self) -> f64 { -*self } + fn neg(&self) -> f64 { -*self } } impl num::Round for f64 { #[inline(always)] - pure fn round(&self, mode: num::RoundMode) -> f64 { + fn round(&self, mode: num::RoundMode) -> f64 { match mode { num::RoundDown => floor(*self), num::RoundUp => ceil(*self), @@ -372,11 +372,11 @@ impl num::Round for f64 { } #[inline(always)] - pure fn floor(&self) -> f64 { floor(*self) } + fn floor(&self) -> f64 { floor(*self) } #[inline(always)] - pure fn ceil(&self) -> f64 { ceil(*self) } + fn ceil(&self) -> f64 { ceil(*self) } #[inline(always)] - pure fn fract(&self) -> f64 { + fn fract(&self) -> f64 { if is_negative(*self) { (*self) - ceil(*self) } else { @@ -397,7 +397,7 @@ impl num::Round for f64 { * * num - The float value */ #[inline(always)] -pub pure fn to_str(num: f64) -> ~str { +pub fn to_str(num: f64) -> ~str { let (r, _) = strconv::to_str_common( &num, 10u, true, strconv::SignNeg, strconv::DigAll); r @@ -411,7 +411,7 @@ pub pure fn to_str(num: f64) -> ~str { * * num - The float value */ #[inline(always)] -pub pure fn to_str_hex(num: f64) -> ~str { +pub fn to_str_hex(num: f64) -> ~str { let (r, _) = strconv::to_str_common( &num, 16u, true, strconv::SignNeg, strconv::DigAll); r @@ -432,7 +432,7 @@ pub pure fn to_str_hex(num: f64) -> ~str { * are expected, use `to_str_radix_special()` instead. */ #[inline(always)] -pub pure fn to_str_radix(num: f64, rdx: uint) -> ~str { +pub fn to_str_radix(num: f64, rdx: uint) -> ~str { let (r, special) = strconv::to_str_common( &num, rdx, true, strconv::SignNeg, strconv::DigAll); if special { fail!(~"number has a special value, \ @@ -450,7 +450,7 @@ pub pure fn to_str_radix(num: f64, rdx: uint) -> ~str { * * radix - The base to use */ #[inline(always)] -pub pure fn to_str_radix_special(num: f64, rdx: uint) -> (~str, bool) { +pub fn to_str_radix_special(num: f64, rdx: uint) -> (~str, bool) { strconv::to_str_common(&num, rdx, true, strconv::SignNeg, strconv::DigAll) } @@ -465,7 +465,7 @@ pub pure fn to_str_radix_special(num: f64, rdx: uint) -> (~str, bool) { * * digits - The number of significant digits */ #[inline(always)] -pub pure fn to_str_exact(num: f64, dig: uint) -> ~str { +pub fn to_str_exact(num: f64, dig: uint) -> ~str { let (r, _) = strconv::to_str_common( &num, 10u, true, strconv::SignNeg, strconv::DigExact(dig)); r @@ -481,7 +481,7 @@ pub pure fn to_str_exact(num: f64, dig: uint) -> ~str { * * digits - The number of significant digits */ #[inline(always)] -pub pure fn to_str_digits(num: f64, dig: uint) -> ~str { +pub fn to_str_digits(num: f64, dig: uint) -> ~str { let (r, _) = strconv::to_str_common( &num, 10u, true, strconv::SignNeg, strconv::DigMax(dig)); r @@ -489,12 +489,12 @@ pub pure fn to_str_digits(num: f64, dig: uint) -> ~str { impl to_str::ToStr for f64 { #[inline(always)] - pure fn to_str(&self) -> ~str { to_str_digits(*self, 8) } + fn to_str(&self) -> ~str { to_str_digits(*self, 8) } } impl num::ToStrRadix for f64 { #[inline(always)] - pure fn to_str_radix(&self, rdx: uint) -> ~str { + fn to_str_radix(&self, rdx: uint) -> ~str { to_str_radix(*self, rdx) } } @@ -527,7 +527,7 @@ impl num::ToStrRadix for f64 { * `Some(n)` where `n` is the floating-point number represented by `num`. */ #[inline(always)] -pub pure fn from_str(num: &str) -> Option { +pub fn from_str(num: &str) -> Option { strconv::from_str_common(num, 10u, true, true, true, strconv::ExpDec, false) } @@ -560,7 +560,7 @@ pub pure fn from_str(num: &str) -> Option { * `Some(n)` where `n` is the floating-point number represented by `[num]`. */ #[inline(always)] -pub pure fn from_str_hex(num: &str) -> Option { +pub fn from_str_hex(num: &str) -> Option { strconv::from_str_common(num, 16u, true, true, true, strconv::ExpBin, false) } @@ -585,19 +585,19 @@ pub pure fn from_str_hex(num: &str) -> Option { * `Some(n)` where `n` is the floating-point number represented by `num`. */ #[inline(always)] -pub pure fn from_str_radix(num: &str, rdx: uint) -> Option { +pub fn from_str_radix(num: &str, rdx: uint) -> Option { strconv::from_str_common(num, rdx, true, true, false, strconv::ExpNone, false) } impl from_str::FromStr for f64 { #[inline(always)] - pure fn from_str(val: &str) -> Option { from_str(val) } + fn from_str(val: &str) -> Option { from_str(val) } } impl num::FromStrRadix for f64 { #[inline(always)] - pure fn from_str_radix(val: &str, rdx: uint) -> Option { + fn from_str_radix(val: &str, rdx: uint) -> Option { from_str_radix(val, rdx) } } diff --git a/src/libcore/num/float.rs b/src/libcore/num/float.rs index f1026ce6608..4e9a1b62b6e 100644 --- a/src/libcore/num/float.rs +++ b/src/libcore/num/float.rs @@ -103,7 +103,7 @@ pub mod consts { * * num - The float value */ #[inline(always)] -pub pure fn to_str(num: float) -> ~str { +pub fn to_str(num: float) -> ~str { let (r, _) = strconv::to_str_common( &num, 10u, true, strconv::SignNeg, strconv::DigAll); r @@ -117,7 +117,7 @@ pub pure fn to_str(num: float) -> ~str { * * num - The float value */ #[inline(always)] -pub pure fn to_str_hex(num: float) -> ~str { +pub fn to_str_hex(num: float) -> ~str { let (r, _) = strconv::to_str_common( &num, 16u, true, strconv::SignNeg, strconv::DigAll); r @@ -138,7 +138,7 @@ pub pure fn to_str_hex(num: float) -> ~str { * are expected, use `to_str_radix_special()` instead. */ #[inline(always)] -pub pure fn to_str_radix(num: float, radix: uint) -> ~str { +pub fn to_str_radix(num: float, radix: uint) -> ~str { let (r, special) = strconv::to_str_common( &num, radix, true, strconv::SignNeg, strconv::DigAll); if special { fail!(~"number has a special value, \ @@ -156,7 +156,7 @@ pub pure fn to_str_radix(num: float, radix: uint) -> ~str { * * radix - The base to use */ #[inline(always)] -pub pure fn to_str_radix_special(num: float, radix: uint) -> (~str, bool) { +pub fn to_str_radix_special(num: float, radix: uint) -> (~str, bool) { strconv::to_str_common(&num, radix, true, strconv::SignNeg, strconv::DigAll) } @@ -171,7 +171,7 @@ pub pure fn to_str_radix_special(num: float, radix: uint) -> (~str, bool) { * * digits - The number of significant digits */ #[inline(always)] -pub pure fn to_str_exact(num: float, digits: uint) -> ~str { +pub fn to_str_exact(num: float, digits: uint) -> ~str { let (r, _) = strconv::to_str_common( &num, 10u, true, strconv::SignNeg, strconv::DigExact(digits)); r @@ -193,7 +193,7 @@ pub fn test_to_str_exact_do_decimal() { * * digits - The number of significant digits */ #[inline(always)] -pub pure fn to_str_digits(num: float, digits: uint) -> ~str { +pub fn to_str_digits(num: float, digits: uint) -> ~str { let (r, _) = strconv::to_str_common( &num, 10u, true, strconv::SignNeg, strconv::DigMax(digits)); r @@ -201,12 +201,12 @@ pub pure fn to_str_digits(num: float, digits: uint) -> ~str { impl to_str::ToStr for float { #[inline(always)] - pure fn to_str(&self) -> ~str { to_str_digits(*self, 8) } + fn to_str(&self) -> ~str { to_str_digits(*self, 8) } } impl num::ToStrRadix for float { #[inline(always)] - pure fn to_str_radix(&self, radix: uint) -> ~str { + fn to_str_radix(&self, radix: uint) -> ~str { to_str_radix(*self, radix) } } @@ -239,7 +239,7 @@ impl num::ToStrRadix for float { * `Some(n)` where `n` is the floating-point number represented by `num`. */ #[inline(always)] -pub pure fn from_str(num: &str) -> Option { +pub fn from_str(num: &str) -> Option { strconv::from_str_common(num, 10u, true, true, true, strconv::ExpDec, false) } @@ -272,7 +272,7 @@ pub pure fn from_str(num: &str) -> Option { * `Some(n)` where `n` is the floating-point number represented by `[num]`. */ #[inline(always)] -pub pure fn from_str_hex(num: &str) -> Option { +pub fn from_str_hex(num: &str) -> Option { strconv::from_str_common(num, 16u, true, true, true, strconv::ExpBin, false) } @@ -297,19 +297,19 @@ pub pure fn from_str_hex(num: &str) -> Option { * `Some(n)` where `n` is the floating-point number represented by `num`. */ #[inline(always)] -pub pure fn from_str_radix(num: &str, radix: uint) -> Option { +pub fn from_str_radix(num: &str, radix: uint) -> Option { strconv::from_str_common(num, radix, true, true, false, strconv::ExpNone, false) } impl from_str::FromStr for float { #[inline(always)] - pure fn from_str(val: &str) -> Option { from_str(val) } + fn from_str(val: &str) -> Option { from_str(val) } } impl num::FromStrRadix for float { #[inline(always)] - pure fn from_str_radix(val: &str, radix: uint) -> Option { + fn from_str_radix(val: &str, radix: uint) -> Option { from_str_radix(val, radix) } } @@ -330,7 +330,7 @@ impl num::FromStrRadix for float { * * `NaN` if both `x` and `pow` are `0u`, otherwise `x^pow` */ -pub pure fn pow_with_uint(base: uint, pow: uint) -> float { +pub fn pow_with_uint(base: uint, pow: uint) -> float { if base == 0u { if pow == 0u { return NaN as float; @@ -351,69 +351,69 @@ pub pure fn pow_with_uint(base: uint, pow: uint) -> float { } #[inline(always)] -pub pure fn is_positive(x: float) -> bool { f64::is_positive(x as f64) } +pub fn is_positive(x: float) -> bool { f64::is_positive(x as f64) } #[inline(always)] -pub pure fn is_negative(x: float) -> bool { f64::is_negative(x as f64) } +pub fn is_negative(x: float) -> bool { f64::is_negative(x as f64) } #[inline(always)] -pub pure fn is_nonpositive(x: float) -> bool { f64::is_nonpositive(x as f64) } +pub fn is_nonpositive(x: float) -> bool { f64::is_nonpositive(x as f64) } #[inline(always)] -pub pure fn is_nonnegative(x: float) -> bool { f64::is_nonnegative(x as f64) } +pub fn is_nonnegative(x: float) -> bool { f64::is_nonnegative(x as f64) } #[inline(always)] -pub pure fn is_zero(x: float) -> bool { f64::is_zero(x as f64) } +pub fn is_zero(x: float) -> bool { f64::is_zero(x as f64) } #[inline(always)] -pub pure fn is_infinite(x: float) -> bool { f64::is_infinite(x as f64) } +pub fn is_infinite(x: float) -> bool { f64::is_infinite(x as f64) } #[inline(always)] -pub pure fn is_finite(x: float) -> bool { f64::is_finite(x as f64) } +pub fn is_finite(x: float) -> bool { f64::is_finite(x as f64) } #[inline(always)] -pub pure fn is_NaN(x: float) -> bool { f64::is_NaN(x as f64) } +pub fn is_NaN(x: float) -> bool { f64::is_NaN(x as f64) } #[inline(always)] -pub pure fn abs(x: float) -> float { +pub fn abs(x: float) -> float { unsafe { f64::abs(x as f64) as float } } #[inline(always)] -pub pure fn sqrt(x: float) -> float { +pub fn sqrt(x: float) -> float { unsafe { f64::sqrt(x as f64) as float } } #[inline(always)] -pub pure fn atan(x: float) -> float { +pub fn atan(x: float) -> float { unsafe { f64::atan(x as f64) as float } } #[inline(always)] -pub pure fn sin(x: float) -> float { +pub fn sin(x: float) -> float { unsafe { f64::sin(x as f64) as float } } #[inline(always)] -pub pure fn cos(x: float) -> float { +pub fn cos(x: float) -> float { unsafe { f64::cos(x as f64) as float } } #[inline(always)] -pub pure fn tan(x: float) -> float { +pub fn tan(x: float) -> float { unsafe { f64::tan(x as f64) as float } } #[cfg(notest)] impl Eq for float { - pure fn eq(&self, other: &float) -> bool { (*self) == (*other) } - pure fn ne(&self, other: &float) -> bool { (*self) != (*other) } + fn eq(&self, other: &float) -> bool { (*self) == (*other) } + fn ne(&self, other: &float) -> bool { (*self) != (*other) } } #[cfg(notest)] impl Ord for float { - pure fn lt(&self, other: &float) -> bool { (*self) < (*other) } - pure fn le(&self, other: &float) -> bool { (*self) <= (*other) } - pure fn ge(&self, other: &float) -> bool { (*self) >= (*other) } - pure fn gt(&self, other: &float) -> bool { (*self) > (*other) } + fn lt(&self, other: &float) -> bool { (*self) < (*other) } + fn le(&self, other: &float) -> bool { (*self) <= (*other) } + fn ge(&self, other: &float) -> bool { (*self) >= (*other) } + fn gt(&self, other: &float) -> bool { (*self) > (*other) } } impl num::Zero for float { #[inline(always)] - pure fn zero() -> float { 0.0 } + fn zero() -> float { 0.0 } } impl num::One for float { #[inline(always)] - pure fn one() -> float { 1.0 } + fn one() -> float { 1.0 } } impl NumCast for float { @@ -421,28 +421,28 @@ impl NumCast for float { * Cast `n` to a `float` */ #[inline(always)] - pure fn from(n: N) -> float { n.to_float() } + fn from(n: N) -> float { n.to_float() } - #[inline(always)] pure fn to_u8(&self) -> u8 { *self as u8 } - #[inline(always)] pure fn to_u16(&self) -> u16 { *self as u16 } - #[inline(always)] pure fn to_u32(&self) -> u32 { *self as u32 } - #[inline(always)] pure fn to_u64(&self) -> u64 { *self as u64 } - #[inline(always)] pure fn to_uint(&self) -> uint { *self as uint } + #[inline(always)] fn to_u8(&self) -> u8 { *self as u8 } + #[inline(always)] fn to_u16(&self) -> u16 { *self as u16 } + #[inline(always)] fn to_u32(&self) -> u32 { *self as u32 } + #[inline(always)] fn to_u64(&self) -> u64 { *self as u64 } + #[inline(always)] fn to_uint(&self) -> uint { *self as uint } - #[inline(always)] pure fn to_i8(&self) -> i8 { *self as i8 } - #[inline(always)] pure fn to_i16(&self) -> i16 { *self as i16 } - #[inline(always)] pure fn to_i32(&self) -> i32 { *self as i32 } - #[inline(always)] pure fn to_i64(&self) -> i64 { *self as i64 } - #[inline(always)] pure fn to_int(&self) -> int { *self as int } + #[inline(always)] fn to_i8(&self) -> i8 { *self as i8 } + #[inline(always)] fn to_i16(&self) -> i16 { *self as i16 } + #[inline(always)] fn to_i32(&self) -> i32 { *self as i32 } + #[inline(always)] fn to_i64(&self) -> i64 { *self as i64 } + #[inline(always)] fn to_int(&self) -> int { *self as int } - #[inline(always)] pure fn to_f32(&self) -> f32 { *self as f32 } - #[inline(always)] pure fn to_f64(&self) -> f64 { *self as f64 } - #[inline(always)] pure fn to_float(&self) -> float { *self } + #[inline(always)] fn to_f32(&self) -> f32 { *self as f32 } + #[inline(always)] fn to_f64(&self) -> f64 { *self as f64 } + #[inline(always)] fn to_float(&self) -> float { *self } } impl num::Round for float { #[inline(always)] - pure fn round(&self, mode: num::RoundMode) -> float { + fn round(&self, mode: num::RoundMode) -> float { match mode { num::RoundDown => f64::floor(*self as f64) as float, @@ -460,11 +460,11 @@ impl num::Round for float { } #[inline(always)] - pure fn floor(&self) -> float { f64::floor(*self as f64) as float} + fn floor(&self) -> float { f64::floor(*self as f64) as float} #[inline(always)] - pure fn ceil(&self) -> float { f64::ceil(*self as f64) as float} + fn ceil(&self) -> float { f64::ceil(*self as f64) as float} #[inline(always)] - pure fn fract(&self) -> float { + fn fract(&self) -> float { if is_negative(*self) { (*self) - (f64::ceil(*self as f64) as float) } else { @@ -475,27 +475,27 @@ impl num::Round for float { #[cfg(notest)] impl ops::Add for float { - pure fn add(&self, other: &float) -> float { *self + *other } + fn add(&self, other: &float) -> float { *self + *other } } #[cfg(notest)] impl ops::Sub for float { - pure fn sub(&self, other: &float) -> float { *self - *other } + fn sub(&self, other: &float) -> float { *self - *other } } #[cfg(notest)] impl ops::Mul for float { - pure fn mul(&self, other: &float) -> float { *self * *other } + fn mul(&self, other: &float) -> float { *self * *other } } #[cfg(notest)] impl ops::Div for float { - pure fn div(&self, other: &float) -> float { *self / *other } + fn div(&self, other: &float) -> float { *self / *other } } #[cfg(notest)] impl ops::Modulo for float { - pure fn modulo(&self, other: &float) -> float { *self % *other } + fn modulo(&self, other: &float) -> float { *self % *other } } #[cfg(notest)] impl ops::Neg for float { - pure fn neg(&self) -> float { -*self } + fn neg(&self) -> float { -*self } } #[test] diff --git a/src/libcore/num/int-template.rs b/src/libcore/num/int-template.rs index 599bd0f1c68..4d5ac92311e 100644 --- a/src/libcore/num/int-template.rs +++ b/src/libcore/num/int-template.rs @@ -28,13 +28,13 @@ pub const min_value: T = (-1 as T) << (bits - 1); pub const max_value: T = min_value - 1 as T; #[inline(always)] -pub pure fn add(x: T, y: T) -> T { x + y } +pub fn add(x: T, y: T) -> T { x + y } #[inline(always)] -pub pure fn sub(x: T, y: T) -> T { x - y } +pub fn sub(x: T, y: T) -> T { x - y } #[inline(always)] -pub pure fn mul(x: T, y: T) -> T { x * y } +pub fn mul(x: T, y: T) -> T { x * y } #[inline(always)] -pub pure fn div(x: T, y: T) -> T { x / y } +pub fn div(x: T, y: T) -> T { x / y } /** * Returns the remainder of y / x. @@ -57,29 +57,29 @@ pub pure fn div(x: T, y: T) -> T { x / y } * */ #[inline(always)] -pub pure fn rem(x: T, y: T) -> T { x % y } +pub fn rem(x: T, y: T) -> T { x % y } #[inline(always)] -pub pure fn lt(x: T, y: T) -> bool { x < y } +pub fn lt(x: T, y: T) -> bool { x < y } #[inline(always)] -pub pure fn le(x: T, y: T) -> bool { x <= y } +pub fn le(x: T, y: T) -> bool { x <= y } #[inline(always)] -pub pure fn eq(x: T, y: T) -> bool { x == y } +pub fn eq(x: T, y: T) -> bool { x == y } #[inline(always)] -pub pure fn ne(x: T, y: T) -> bool { x != y } +pub fn ne(x: T, y: T) -> bool { x != y } #[inline(always)] -pub pure fn ge(x: T, y: T) -> bool { x >= y } +pub fn ge(x: T, y: T) -> bool { x >= y } #[inline(always)] -pub pure fn gt(x: T, y: T) -> bool { x > y } +pub fn gt(x: T, y: T) -> bool { x > y } #[inline(always)] -pub pure fn is_positive(x: T) -> bool { x > 0 as T } +pub fn is_positive(x: T) -> bool { x > 0 as T } #[inline(always)] -pub pure fn is_negative(x: T) -> bool { x < 0 as T } +pub fn is_negative(x: T) -> bool { x < 0 as T } #[inline(always)] -pub pure fn is_nonpositive(x: T) -> bool { x <= 0 as T } +pub fn is_nonpositive(x: T) -> bool { x <= 0 as T } #[inline(always)] -pub pure fn is_nonnegative(x: T) -> bool { x >= 0 as T } +pub fn is_nonnegative(x: T) -> bool { x >= 0 as T } /** * Iterate over the range [`lo`..`hi`) @@ -100,7 +100,7 @@ pub pure fn is_nonnegative(x: T) -> bool { x >= 0 as T } */ #[inline(always)] /// Iterate over the range [`start`,`start`+`step`..`stop`) -pub pure fn range_step(start: T, stop: T, step: T, it: &fn(T) -> bool) { +pub fn range_step(start: T, stop: T, step: T, it: &fn(T) -> bool) { let mut i = start; if step == 0 { fail!(~"range_step called with step == 0"); @@ -119,116 +119,116 @@ pub pure fn range_step(start: T, stop: T, step: T, it: &fn(T) -> bool) { #[inline(always)] /// Iterate over the range [`lo`..`hi`) -pub pure fn range(lo: T, hi: T, it: &fn(T) -> bool) { +pub fn range(lo: T, hi: T, it: &fn(T) -> bool) { range_step(lo, hi, 1 as T, it); } #[inline(always)] /// Iterate over the range [`hi`..`lo`) -pub pure fn range_rev(hi: T, lo: T, it: &fn(T) -> bool) { +pub fn range_rev(hi: T, lo: T, it: &fn(T) -> bool) { range_step(hi, lo, -1 as T, it); } /// Computes the bitwise complement #[inline(always)] -pub pure fn compl(i: T) -> T { +pub fn compl(i: T) -> T { -1 as T ^ i } /// Computes the absolute value #[inline(always)] -pub pure fn abs(i: T) -> T { +pub fn abs(i: T) -> T { if is_negative(i) { -i } else { i } } #[cfg(notest)] impl Ord for T { #[inline(always)] - pure fn lt(&self, other: &T) -> bool { return (*self) < (*other); } + fn lt(&self, other: &T) -> bool { return (*self) < (*other); } #[inline(always)] - pure fn le(&self, other: &T) -> bool { return (*self) <= (*other); } + fn le(&self, other: &T) -> bool { return (*self) <= (*other); } #[inline(always)] - pure fn ge(&self, other: &T) -> bool { return (*self) >= (*other); } + fn ge(&self, other: &T) -> bool { return (*self) >= (*other); } #[inline(always)] - pure fn gt(&self, other: &T) -> bool { return (*self) > (*other); } + fn gt(&self, other: &T) -> bool { return (*self) > (*other); } } #[cfg(notest)] impl Eq for T { #[inline(always)] - pure fn eq(&self, other: &T) -> bool { return (*self) == (*other); } + fn eq(&self, other: &T) -> bool { return (*self) == (*other); } #[inline(always)] - pure fn ne(&self, other: &T) -> bool { return (*self) != (*other); } + fn ne(&self, other: &T) -> bool { return (*self) != (*other); } } impl num::Zero for T { #[inline(always)] - pure fn zero() -> T { 0 } + fn zero() -> T { 0 } } impl num::One for T { #[inline(always)] - pure fn one() -> T { 1 } + fn one() -> T { 1 } } #[cfg(notest)] impl ops::Add for T { - pure fn add(&self, other: &T) -> T { *self + *other } + fn add(&self, other: &T) -> T { *self + *other } } #[cfg(notest)] impl ops::Sub for T { - pure fn sub(&self, other: &T) -> T { *self - *other } + fn sub(&self, other: &T) -> T { *self - *other } } #[cfg(notest)] impl ops::Mul for T { - pure fn mul(&self, other: &T) -> T { *self * *other } + fn mul(&self, other: &T) -> T { *self * *other } } #[cfg(notest)] impl ops::Div for T { - pure fn div(&self, other: &T) -> T { *self / *other } + fn div(&self, other: &T) -> T { *self / *other } } #[cfg(notest)] impl ops::Modulo for T { - pure fn modulo(&self, other: &T) -> T { *self % *other } + fn modulo(&self, other: &T) -> T { *self % *other } } #[cfg(notest)] impl ops::Neg for T { - pure fn neg(&self) -> T { -*self } + fn neg(&self) -> T { -*self } } // String conversion functions and impl str -> num /// Parse a string as a number in base 10. #[inline(always)] -pub pure fn from_str(s: &str) -> Option { +pub fn from_str(s: &str) -> Option { strconv::from_str_common(s, 10u, true, false, false, strconv::ExpNone, false) } /// Parse a string as a number in the given base. #[inline(always)] -pub pure fn from_str_radix(s: &str, radix: uint) -> Option { +pub fn from_str_radix(s: &str, radix: uint) -> Option { strconv::from_str_common(s, radix, true, false, false, strconv::ExpNone, false) } /// Parse a byte slice as a number in the given base. #[inline(always)] -pub pure fn parse_bytes(buf: &[u8], radix: uint) -> Option { +pub fn parse_bytes(buf: &[u8], radix: uint) -> Option { strconv::from_str_bytes_common(buf, radix, true, false, false, strconv::ExpNone, false) } impl FromStr for T { #[inline(always)] - pure fn from_str(s: &str) -> Option { + fn from_str(s: &str) -> Option { from_str(s) } } impl FromStrRadix for T { #[inline(always)] - pure fn from_str_radix(s: &str, radix: uint) -> Option { + fn from_str_radix(s: &str, radix: uint) -> Option { from_str_radix(s, radix) } } @@ -237,7 +237,7 @@ impl FromStrRadix for T { /// Convert to a string as a byte slice in a given base. #[inline(always)] -pub pure fn to_str_bytes(n: T, radix: uint, f: &fn(v: &[u8]) -> U) -> U { +pub fn to_str_bytes(n: T, radix: uint, f: &fn(v: &[u8]) -> U) -> U { let (buf, _) = strconv::to_str_bytes_common(&n, radix, false, strconv::SignNeg, strconv::DigAll); f(buf) @@ -245,7 +245,7 @@ pub pure fn to_str_bytes(n: T, radix: uint, f: &fn(v: &[u8]) -> U) -> U { /// Convert to a string in base 10. #[inline(always)] -pub pure fn to_str(num: T) -> ~str { +pub fn to_str(num: T) -> ~str { let (buf, _) = strconv::to_str_common(&num, 10u, false, strconv::SignNeg, strconv::DigAll); buf @@ -253,7 +253,7 @@ pub pure fn to_str(num: T) -> ~str { /// Convert to a string in a given base. #[inline(always)] -pub pure fn to_str_radix(num: T, radix: uint) -> ~str { +pub fn to_str_radix(num: T, radix: uint) -> ~str { let (buf, _) = strconv::to_str_common(&num, radix, false, strconv::SignNeg, strconv::DigAll); buf @@ -261,14 +261,14 @@ pub pure fn to_str_radix(num: T, radix: uint) -> ~str { impl ToStr for T { #[inline(always)] - pure fn to_str(&self) -> ~str { + fn to_str(&self) -> ~str { to_str(*self) } } impl ToStrRadix for T { #[inline(always)] - pure fn to_str_radix(&self, radix: uint) -> ~str { + fn to_str_radix(&self, radix: uint) -> ~str { to_str_radix(*self, radix) } } diff --git a/src/libcore/num/int-template/i16.rs b/src/libcore/num/int-template/i16.rs index 04bd205f53d..9914807c98f 100644 --- a/src/libcore/num/int-template/i16.rs +++ b/src/libcore/num/int-template/i16.rs @@ -22,23 +22,23 @@ impl NumCast for i16 { * Cast `n` to a `i16` */ #[inline(always)] - pure fn from(n: N) -> i16 { n.to_i16() } + fn from(n: N) -> i16 { n.to_i16() } - #[inline(always)] pure fn to_u8(&self) -> u8 { *self as u8 } - #[inline(always)] pure fn to_u16(&self) -> u16 { *self as u16 } - #[inline(always)] pure fn to_u32(&self) -> u32 { *self as u32 } - #[inline(always)] pure fn to_u64(&self) -> u64 { *self as u64 } - #[inline(always)] pure fn to_uint(&self) -> uint { *self as uint } + #[inline(always)] fn to_u8(&self) -> u8 { *self as u8 } + #[inline(always)] fn to_u16(&self) -> u16 { *self as u16 } + #[inline(always)] fn to_u32(&self) -> u32 { *self as u32 } + #[inline(always)] fn to_u64(&self) -> u64 { *self as u64 } + #[inline(always)] fn to_uint(&self) -> uint { *self as uint } - #[inline(always)] pure fn to_i8(&self) -> i8 { *self as i8 } - #[inline(always)] pure fn to_i16(&self) -> i16 { *self } - #[inline(always)] pure fn to_i32(&self) -> i32 { *self as i32 } - #[inline(always)] pure fn to_i64(&self) -> i64 { *self as i64 } - #[inline(always)] pure fn to_int(&self) -> int { *self as int } + #[inline(always)] fn to_i8(&self) -> i8 { *self as i8 } + #[inline(always)] fn to_i16(&self) -> i16 { *self } + #[inline(always)] fn to_i32(&self) -> i32 { *self as i32 } + #[inline(always)] fn to_i64(&self) -> i64 { *self as i64 } + #[inline(always)] fn to_int(&self) -> int { *self as int } - #[inline(always)] pure fn to_f32(&self) -> f32 { *self as f32 } - #[inline(always)] pure fn to_f64(&self) -> f64 { *self as f64 } - #[inline(always)] pure fn to_float(&self) -> float { *self as float } + #[inline(always)] fn to_f32(&self) -> f32 { *self as f32 } + #[inline(always)] fn to_f64(&self) -> f64 { *self as f64 } + #[inline(always)] fn to_float(&self) -> float { *self as float } } #[test] diff --git a/src/libcore/num/int-template/i32.rs b/src/libcore/num/int-template/i32.rs index 1cdd93c411e..c02facd47db 100644 --- a/src/libcore/num/int-template/i32.rs +++ b/src/libcore/num/int-template/i32.rs @@ -22,23 +22,23 @@ impl NumCast for i32 { * Cast `n` to a `i32` */ #[inline(always)] - pure fn from(n: N) -> i32 { n.to_i32() } + fn from(n: N) -> i32 { n.to_i32() } - #[inline(always)] pure fn to_u8(&self) -> u8 { *self as u8 } - #[inline(always)] pure fn to_u16(&self) -> u16 { *self as u16 } - #[inline(always)] pure fn to_u32(&self) -> u32 { *self as u32 } - #[inline(always)] pure fn to_u64(&self) -> u64 { *self as u64 } - #[inline(always)] pure fn to_uint(&self) -> uint { *self as uint } + #[inline(always)] fn to_u8(&self) -> u8 { *self as u8 } + #[inline(always)] fn to_u16(&self) -> u16 { *self as u16 } + #[inline(always)] fn to_u32(&self) -> u32 { *self as u32 } + #[inline(always)] fn to_u64(&self) -> u64 { *self as u64 } + #[inline(always)] fn to_uint(&self) -> uint { *self as uint } - #[inline(always)] pure fn to_i8(&self) -> i8 { *self as i8 } - #[inline(always)] pure fn to_i16(&self) -> i16 { *self as i16 } - #[inline(always)] pure fn to_i32(&self) -> i32 { *self } - #[inline(always)] pure fn to_i64(&self) -> i64 { *self as i64 } - #[inline(always)] pure fn to_int(&self) -> int { *self as int } + #[inline(always)] fn to_i8(&self) -> i8 { *self as i8 } + #[inline(always)] fn to_i16(&self) -> i16 { *self as i16 } + #[inline(always)] fn to_i32(&self) -> i32 { *self } + #[inline(always)] fn to_i64(&self) -> i64 { *self as i64 } + #[inline(always)] fn to_int(&self) -> int { *self as int } - #[inline(always)] pure fn to_f32(&self) -> f32 { *self as f32 } - #[inline(always)] pure fn to_f64(&self) -> f64 { *self as f64 } - #[inline(always)] pure fn to_float(&self) -> float { *self as float } + #[inline(always)] fn to_f32(&self) -> f32 { *self as f32 } + #[inline(always)] fn to_f64(&self) -> f64 { *self as f64 } + #[inline(always)] fn to_float(&self) -> float { *self as float } } #[test] diff --git a/src/libcore/num/int-template/i64.rs b/src/libcore/num/int-template/i64.rs index 2a7c155f8b5..c285ba23c27 100644 --- a/src/libcore/num/int-template/i64.rs +++ b/src/libcore/num/int-template/i64.rs @@ -22,23 +22,23 @@ impl NumCast for i64 { * Cast `n` to a `i64` */ #[inline(always)] - pure fn from(n: N) -> i64 { n.to_i64() } + fn from(n: N) -> i64 { n.to_i64() } - #[inline(always)] pure fn to_u8(&self) -> u8 { *self as u8 } - #[inline(always)] pure fn to_u16(&self) -> u16 { *self as u16 } - #[inline(always)] pure fn to_u32(&self) -> u32 { *self as u32 } - #[inline(always)] pure fn to_u64(&self) -> u64 { *self as u64 } - #[inline(always)] pure fn to_uint(&self) -> uint { *self as uint } + #[inline(always)] fn to_u8(&self) -> u8 { *self as u8 } + #[inline(always)] fn to_u16(&self) -> u16 { *self as u16 } + #[inline(always)] fn to_u32(&self) -> u32 { *self as u32 } + #[inline(always)] fn to_u64(&self) -> u64 { *self as u64 } + #[inline(always)] fn to_uint(&self) -> uint { *self as uint } - #[inline(always)] pure fn to_i8(&self) -> i8 { *self as i8 } - #[inline(always)] pure fn to_i16(&self) -> i16 { *self as i16 } - #[inline(always)] pure fn to_i32(&self) -> i32 { *self as i32 } - #[inline(always)] pure fn to_i64(&self) -> i64 { *self } - #[inline(always)] pure fn to_int(&self) -> int { *self as int } + #[inline(always)] fn to_i8(&self) -> i8 { *self as i8 } + #[inline(always)] fn to_i16(&self) -> i16 { *self as i16 } + #[inline(always)] fn to_i32(&self) -> i32 { *self as i32 } + #[inline(always)] fn to_i64(&self) -> i64 { *self } + #[inline(always)] fn to_int(&self) -> int { *self as int } - #[inline(always)] pure fn to_f32(&self) -> f32 { *self as f32 } - #[inline(always)] pure fn to_f64(&self) -> f64 { *self as f64 } - #[inline(always)] pure fn to_float(&self) -> float { *self as float } + #[inline(always)] fn to_f32(&self) -> f32 { *self as f32 } + #[inline(always)] fn to_f64(&self) -> f64 { *self as f64 } + #[inline(always)] fn to_float(&self) -> float { *self as float } } #[test] diff --git a/src/libcore/num/int-template/i8.rs b/src/libcore/num/int-template/i8.rs index ac1dc76c264..2733a064563 100644 --- a/src/libcore/num/int-template/i8.rs +++ b/src/libcore/num/int-template/i8.rs @@ -22,23 +22,23 @@ impl NumCast for i8 { * Cast `n` to a `i8` */ #[inline(always)] - pure fn from(n: N) -> i8 { n.to_i8() } + fn from(n: N) -> i8 { n.to_i8() } - #[inline(always)] pure fn to_u8(&self) -> u8 { *self as u8 } - #[inline(always)] pure fn to_u16(&self) -> u16 { *self as u16 } - #[inline(always)] pure fn to_u32(&self) -> u32 { *self as u32 } - #[inline(always)] pure fn to_u64(&self) -> u64 { *self as u64 } - #[inline(always)] pure fn to_uint(&self) -> uint { *self as uint } + #[inline(always)] fn to_u8(&self) -> u8 { *self as u8 } + #[inline(always)] fn to_u16(&self) -> u16 { *self as u16 } + #[inline(always)] fn to_u32(&self) -> u32 { *self as u32 } + #[inline(always)] fn to_u64(&self) -> u64 { *self as u64 } + #[inline(always)] fn to_uint(&self) -> uint { *self as uint } - #[inline(always)] pure fn to_i8(&self) -> i8 { *self } - #[inline(always)] pure fn to_i16(&self) -> i16 { *self as i16 } - #[inline(always)] pure fn to_i32(&self) -> i32 { *self as i32 } - #[inline(always)] pure fn to_i64(&self) -> i64 { *self as i64 } - #[inline(always)] pure fn to_int(&self) -> int { *self as int } + #[inline(always)] fn to_i8(&self) -> i8 { *self } + #[inline(always)] fn to_i16(&self) -> i16 { *self as i16 } + #[inline(always)] fn to_i32(&self) -> i32 { *self as i32 } + #[inline(always)] fn to_i64(&self) -> i64 { *self as i64 } + #[inline(always)] fn to_int(&self) -> int { *self as int } - #[inline(always)] pure fn to_f32(&self) -> f32 { *self as f32 } - #[inline(always)] pure fn to_f64(&self) -> f64 { *self as f64 } - #[inline(always)] pure fn to_float(&self) -> float { *self as float } + #[inline(always)] fn to_f32(&self) -> f32 { *self as f32 } + #[inline(always)] fn to_f64(&self) -> f64 { *self as f64 } + #[inline(always)] fn to_float(&self) -> float { *self as float } } #[test] diff --git a/src/libcore/num/int-template/int.rs b/src/libcore/num/int-template/int.rs index 0bd52491a63..29e1e52348e 100644 --- a/src/libcore/num/int-template/int.rs +++ b/src/libcore/num/int-template/int.rs @@ -19,7 +19,7 @@ mod inst { pub const bits: uint = ::uint::bits; /// Returns `base` raised to the power of `exponent` - pub pure fn pow(base: int, exponent: uint) -> int { + pub fn pow(base: int, exponent: uint) -> int { if exponent == 0u { //Not mathemtically true if ~[base == 0] return 1; @@ -63,23 +63,23 @@ impl NumCast for int { * Cast `n` to a `int` */ #[inline(always)] - pure fn from(n: N) -> int { n.to_int() } + fn from(n: N) -> int { n.to_int() } - #[inline(always)] pure fn to_u8(&self) -> u8 { *self as u8 } - #[inline(always)] pure fn to_u16(&self) -> u16 { *self as u16 } - #[inline(always)] pure fn to_u32(&self) -> u32 { *self as u32 } - #[inline(always)] pure fn to_u64(&self) -> u64 { *self as u64 } - #[inline(always)] pure fn to_uint(&self) -> uint { *self as uint } + #[inline(always)] fn to_u8(&self) -> u8 { *self as u8 } + #[inline(always)] fn to_u16(&self) -> u16 { *self as u16 } + #[inline(always)] fn to_u32(&self) -> u32 { *self as u32 } + #[inline(always)] fn to_u64(&self) -> u64 { *self as u64 } + #[inline(always)] fn to_uint(&self) -> uint { *self as uint } - #[inline(always)] pure fn to_i8(&self) -> i8 { *self as i8 } - #[inline(always)] pure fn to_i16(&self) -> i16 { *self as i16 } - #[inline(always)] pure fn to_i32(&self) -> i32 { *self as i32 } - #[inline(always)] pure fn to_i64(&self) -> i64 { *self as i64 } - #[inline(always)] pure fn to_int(&self) -> int { *self } + #[inline(always)] fn to_i8(&self) -> i8 { *self as i8 } + #[inline(always)] fn to_i16(&self) -> i16 { *self as i16 } + #[inline(always)] fn to_i32(&self) -> i32 { *self as i32 } + #[inline(always)] fn to_i64(&self) -> i64 { *self as i64 } + #[inline(always)] fn to_int(&self) -> int { *self } - #[inline(always)] pure fn to_f32(&self) -> f32 { *self as f32 } - #[inline(always)] pure fn to_f64(&self) -> f64 { *self as f64 } - #[inline(always)] pure fn to_float(&self) -> float { *self as float } + #[inline(always)] fn to_f32(&self) -> f32 { *self as f32 } + #[inline(always)] fn to_f64(&self) -> f64 { *self as f64 } + #[inline(always)] fn to_float(&self) -> float { *self as float } } #[test] diff --git a/src/libcore/num/num.rs b/src/libcore/num/num.rs index fe829f6193b..32d48aac0b3 100644 --- a/src/libcore/num/num.rs +++ b/src/libcore/num/num.rs @@ -17,28 +17,28 @@ use kinds::Copy; pub mod strconv; pub trait IntConvertible { - pure fn to_int(&self) -> int; - pure fn from_int(n: int) -> Self; + fn to_int(&self) -> int; + fn from_int(n: int) -> Self; } pub trait Zero { - pure fn zero() -> Self; + fn zero() -> Self; } pub trait One { - pure fn one() -> Self; + fn one() -> Self; } -pub pure fn abs>(v: T) -> T { +pub fn abs>(v: T) -> T { if v < Zero::zero() { v.neg() } else { v } } pub trait Round { - pure fn round(&self, mode: RoundMode) -> Self; + fn round(&self, mode: RoundMode) -> Self; - pure fn floor(&self) -> Self; - pure fn ceil(&self) -> Self; - pure fn fract(&self) -> Self; + fn floor(&self) -> Self; + fn ceil(&self) -> Self; + fn fract(&self) -> Self; } pub enum RoundMode { @@ -59,7 +59,7 @@ pub enum RoundMode { * ~~~ */ #[inline(always)] -pub pure fn cast(n: T) -> U { +pub fn cast(n: T) -> U { NumCast::from(n) } @@ -67,31 +67,31 @@ pub pure fn cast(n: T) -> U { * An interface for generic numeric type casts */ pub trait NumCast { - pure fn from(n: T) -> Self; + fn from(n: T) -> Self; - pure fn to_u8(&self) -> u8; - pure fn to_u16(&self) -> u16; - pure fn to_u32(&self) -> u32; - pure fn to_u64(&self) -> u64; - pure fn to_uint(&self) -> uint; + fn to_u8(&self) -> u8; + fn to_u16(&self) -> u16; + fn to_u32(&self) -> u32; + fn to_u64(&self) -> u64; + fn to_uint(&self) -> uint; - pure fn to_i8(&self) -> i8; - pure fn to_i16(&self) -> i16; - pure fn to_i32(&self) -> i32; - pure fn to_i64(&self) -> i64; - pure fn to_int(&self) -> int; + fn to_i8(&self) -> i8; + fn to_i16(&self) -> i16; + fn to_i32(&self) -> i32; + fn to_i64(&self) -> i64; + fn to_int(&self) -> int; - pure fn to_f32(&self) -> f32; - pure fn to_f64(&self) -> f64; - pure fn to_float(&self) -> float; + fn to_f32(&self) -> f32; + fn to_f64(&self) -> f64; + fn to_float(&self) -> float; } pub trait ToStrRadix { - pub pure fn to_str_radix(&self, radix: uint) -> ~str; + pub fn to_str_radix(&self, radix: uint) -> ~str; } pub trait FromStrRadix { - pub pure fn from_str_radix(str: &str, radix: uint) -> Option; + pub fn from_str_radix(str: &str, radix: uint) -> Option; } // Generic math functions: @@ -109,7 +109,7 @@ pub trait FromStrRadix { * - If code written to use this function doesn't care about it, it's * probably assuming that `x^0` always equals `1`. */ -pub pure fn pow_with_uint+Mul>( +pub fn pow_with_uint+Mul>( radix: uint, pow: uint) -> T { let _0: T = Zero::zero(); let _1: T = One::one(); diff --git a/src/libcore/num/strconv.rs b/src/libcore/num/strconv.rs index 0bf20f55b2f..e39d52d86f2 100644 --- a/src/libcore/num/strconv.rs +++ b/src/libcore/num/strconv.rs @@ -37,12 +37,12 @@ pub enum SignFormat { } #[inline(always)] -pure fn is_NaN(num: &T) -> bool { +fn is_NaN(num: &T) -> bool { *num != *num } #[inline(always)] -pure fn is_inf(num: &T) -> bool { +fn is_inf(num: &T) -> bool { match NumStrConv::inf() { None => false, Some(n) => *num == n @@ -50,7 +50,7 @@ pure fn is_inf(num: &T) -> bool { } #[inline(always)] -pure fn is_neg_inf(num: &T) -> bool { +fn is_neg_inf(num: &T) -> bool { match NumStrConv::neg_inf() { None => false, Some(n) => *num == n @@ -58,7 +58,7 @@ pure fn is_neg_inf(num: &T) -> bool { } #[inline(always)] -pure fn is_neg_zero>(num: &T) -> bool { +fn is_neg_zero>(num: &T) -> bool { let _0: T = Zero::zero(); let _1: T = One::one(); @@ -66,35 +66,35 @@ pure fn is_neg_zero>(num: &T) -> bool { } pub trait NumStrConv { - pure fn NaN() -> Option; - pure fn inf() -> Option; - pure fn neg_inf() -> Option; - pure fn neg_zero() -> Option; + fn NaN() -> Option; + fn inf() -> Option; + fn neg_inf() -> Option; + fn neg_zero() -> Option; - pure fn round_to_zero(&self) -> Self; - pure fn fractional_part(&self) -> Self; + fn round_to_zero(&self) -> Self; + fn fractional_part(&self) -> Self; } macro_rules! impl_NumStrConv_Floating (($t:ty) => ( impl NumStrConv for $t { #[inline(always)] - pure fn NaN() -> Option<$t> { Some( 0.0 / 0.0) } + fn NaN() -> Option<$t> { Some( 0.0 / 0.0) } #[inline(always)] - pure fn inf() -> Option<$t> { Some( 1.0 / 0.0) } + fn inf() -> Option<$t> { Some( 1.0 / 0.0) } #[inline(always)] - pure fn neg_inf() -> Option<$t> { Some(-1.0 / 0.0) } + fn neg_inf() -> Option<$t> { Some(-1.0 / 0.0) } #[inline(always)] - pure fn neg_zero() -> Option<$t> { Some(-0.0 ) } + fn neg_zero() -> Option<$t> { Some(-0.0 ) } #[inline(always)] - pure fn round_to_zero(&self) -> $t { + fn round_to_zero(&self) -> $t { ( if *self < 0.0 { f64::ceil(*self as f64) } else { f64::floor(*self as f64) } ) as $t } #[inline(always)] - pure fn fractional_part(&self) -> $t { + fn fractional_part(&self) -> $t { *self - self.round_to_zero() } } @@ -102,13 +102,13 @@ macro_rules! impl_NumStrConv_Floating (($t:ty) => ( macro_rules! impl_NumStrConv_Integer (($t:ty) => ( impl NumStrConv for $t { - #[inline(always)] pure fn NaN() -> Option<$t> { None } - #[inline(always)] pure fn inf() -> Option<$t> { None } - #[inline(always)] pure fn neg_inf() -> Option<$t> { None } - #[inline(always)] pure fn neg_zero() -> Option<$t> { None } + #[inline(always)] fn NaN() -> Option<$t> { None } + #[inline(always)] fn inf() -> Option<$t> { None } + #[inline(always)] fn neg_inf() -> Option<$t> { None } + #[inline(always)] fn neg_zero() -> Option<$t> { None } - #[inline(always)] pure fn round_to_zero(&self) -> $t { *self } - #[inline(always)] pure fn fractional_part(&self) -> $t { 0 } + #[inline(always)] fn round_to_zero(&self) -> $t { *self } + #[inline(always)] fn fractional_part(&self) -> $t { 0 } } )) @@ -161,7 +161,7 @@ impl_NumStrConv_Integer!(u64) * # Failure * - Fails if `radix` < 2 or `radix` > 36. */ -pub pure fn to_str_bytes_common+Neg+Modulo+Mul>( num: &T, radix: uint, negative_zero: bool, sign: SignFormat, digits: SignificantDigits) -> (~[u8], bool) { @@ -383,7 +383,7 @@ pub pure fn to_str_bytes_common+Neg+Modulo+Mul>( num: &T, radix: uint, negative_zero: bool, sign: SignFormat, digits: SignificantDigits) -> (~str, bool) { @@ -439,7 +439,7 @@ priv const DIGIT_E_RADIX: uint = ('e' as uint) - ('a' as uint) + 11u; * - Could accept option to allow ignoring underscores, allowing for numbers * formated like `FF_AE_FF_FF`. */ -pub pure fn from_str_bytes_common+ +pub fn from_str_bytes_common+ Mul+Sub+Neg+Add+ NumStrConv>( buf: &[u8], radix: uint, negative: bool, fractional: bool, @@ -628,7 +628,7 @@ pub pure fn from_str_bytes_common+ * `from_str_bytes_common()`, for details see there. */ #[inline(always)] -pub pure fn from_str_common+Mul+ +pub fn from_str_common+Mul+ Sub+Neg+Add+NumStrConv>( buf: &str, radix: uint, negative: bool, fractional: bool, special: bool, exponent: ExponentFormat, empty_zero: bool diff --git a/src/libcore/num/uint-template.rs b/src/libcore/num/uint-template.rs index 1e56c37bab0..b8e713ff3ab 100644 --- a/src/libcore/num/uint-template.rs +++ b/src/libcore/num/uint-template.rs @@ -30,44 +30,44 @@ pub const min_value: T = 0 as T; pub const max_value: T = 0 as T - 1 as T; #[inline(always)] -pub pure fn add(x: T, y: T) -> T { x + y } +pub fn add(x: T, y: T) -> T { x + y } #[inline(always)] -pub pure fn sub(x: T, y: T) -> T { x - y } +pub fn sub(x: T, y: T) -> T { x - y } #[inline(always)] -pub pure fn mul(x: T, y: T) -> T { x * y } +pub fn mul(x: T, y: T) -> T { x * y } #[inline(always)] -pub pure fn div(x: T, y: T) -> T { x / y } +pub fn div(x: T, y: T) -> T { x / y } #[inline(always)] -pub pure fn rem(x: T, y: T) -> T { x % y } +pub fn rem(x: T, y: T) -> T { x % y } #[inline(always)] -pub pure fn lt(x: T, y: T) -> bool { x < y } +pub fn lt(x: T, y: T) -> bool { x < y } #[inline(always)] -pub pure fn le(x: T, y: T) -> bool { x <= y } +pub fn le(x: T, y: T) -> bool { x <= y } #[inline(always)] -pub pure fn eq(x: T, y: T) -> bool { x == y } +pub fn eq(x: T, y: T) -> bool { x == y } #[inline(always)] -pub pure fn ne(x: T, y: T) -> bool { x != y } +pub fn ne(x: T, y: T) -> bool { x != y } #[inline(always)] -pub pure fn ge(x: T, y: T) -> bool { x >= y } +pub fn ge(x: T, y: T) -> bool { x >= y } #[inline(always)] -pub pure fn gt(x: T, y: T) -> bool { x > y } +pub fn gt(x: T, y: T) -> bool { x > y } #[inline(always)] -pub pure fn is_positive(x: T) -> bool { x > 0 as T } +pub fn is_positive(x: T) -> bool { x > 0 as T } #[inline(always)] -pub pure fn is_negative(x: T) -> bool { x < 0 as T } +pub fn is_negative(x: T) -> bool { x < 0 as T } #[inline(always)] -pub pure fn is_nonpositive(x: T) -> bool { x <= 0 as T } +pub fn is_nonpositive(x: T) -> bool { x <= 0 as T } #[inline(always)] -pub pure fn is_nonnegative(x: T) -> bool { x >= 0 as T } +pub fn is_nonnegative(x: T) -> bool { x >= 0 as T } #[inline(always)] /** * Iterate over the range [`start`,`start`+`step`..`stop`) * */ -pub pure fn range_step(start: T, +pub fn range_step(start: T, stop: T, step: T_SIGNED, it: &fn(T) -> bool) { @@ -91,110 +91,110 @@ pub pure fn range_step(start: T, #[inline(always)] /// Iterate over the range [`lo`..`hi`) -pub pure fn range(lo: T, hi: T, it: &fn(T) -> bool) { +pub fn range(lo: T, hi: T, it: &fn(T) -> bool) { range_step(lo, hi, 1 as T_SIGNED, it); } #[inline(always)] /// Iterate over the range [`hi`..`lo`) -pub pure fn range_rev(hi: T, lo: T, it: &fn(T) -> bool) { +pub fn range_rev(hi: T, lo: T, it: &fn(T) -> bool) { range_step(hi, lo, -1 as T_SIGNED, it); } /// Computes the bitwise complement #[inline(always)] -pub pure fn compl(i: T) -> T { +pub fn compl(i: T) -> T { max_value ^ i } #[cfg(notest)] impl Ord for T { #[inline(always)] - pure fn lt(&self, other: &T) -> bool { (*self) < (*other) } + fn lt(&self, other: &T) -> bool { (*self) < (*other) } #[inline(always)] - pure fn le(&self, other: &T) -> bool { (*self) <= (*other) } + fn le(&self, other: &T) -> bool { (*self) <= (*other) } #[inline(always)] - pure fn ge(&self, other: &T) -> bool { (*self) >= (*other) } + fn ge(&self, other: &T) -> bool { (*self) >= (*other) } #[inline(always)] - pure fn gt(&self, other: &T) -> bool { (*self) > (*other) } + fn gt(&self, other: &T) -> bool { (*self) > (*other) } } #[cfg(notest)] impl Eq for T { #[inline(always)] - pure fn eq(&self, other: &T) -> bool { return (*self) == (*other); } + fn eq(&self, other: &T) -> bool { return (*self) == (*other); } #[inline(always)] - pure fn ne(&self, other: &T) -> bool { return (*self) != (*other); } + fn ne(&self, other: &T) -> bool { return (*self) != (*other); } } impl num::Zero for T { #[inline(always)] - pure fn zero() -> T { 0 } + fn zero() -> T { 0 } } impl num::One for T { #[inline(always)] - pure fn one() -> T { 1 } + fn one() -> T { 1 } } #[cfg(notest)] impl ops::Add for T { - pure fn add(&self, other: &T) -> T { *self + *other } + fn add(&self, other: &T) -> T { *self + *other } } #[cfg(notest)] impl ops::Sub for T { - pure fn sub(&self, other: &T) -> T { *self - *other } + fn sub(&self, other: &T) -> T { *self - *other } } #[cfg(notest)] impl ops::Mul for T { - pure fn mul(&self, other: &T) -> T { *self * *other } + fn mul(&self, other: &T) -> T { *self * *other } } #[cfg(notest)] impl ops::Div for T { - pure fn div(&self, other: &T) -> T { *self / *other } + fn div(&self, other: &T) -> T { *self / *other } } #[cfg(notest)] impl ops::Modulo for T { - pure fn modulo(&self, other: &T) -> T { *self % *other } + fn modulo(&self, other: &T) -> T { *self % *other } } #[cfg(notest)] impl ops::Neg for T { - pure fn neg(&self) -> T { -*self } + fn neg(&self) -> T { -*self } } // String conversion functions and impl str -> num /// Parse a string as a number in base 10. #[inline(always)] -pub pure fn from_str(s: &str) -> Option { +pub fn from_str(s: &str) -> Option { strconv::from_str_common(s, 10u, false, false, false, strconv::ExpNone, false) } /// Parse a string as a number in the given base. #[inline(always)] -pub pure fn from_str_radix(s: &str, radix: uint) -> Option { +pub fn from_str_radix(s: &str, radix: uint) -> Option { strconv::from_str_common(s, radix, false, false, false, strconv::ExpNone, false) } /// Parse a byte slice as a number in the given base. #[inline(always)] -pub pure fn parse_bytes(buf: &[u8], radix: uint) -> Option { +pub fn parse_bytes(buf: &[u8], radix: uint) -> Option { strconv::from_str_bytes_common(buf, radix, false, false, false, strconv::ExpNone, false) } impl FromStr for T { #[inline(always)] - pure fn from_str(s: &str) -> Option { + fn from_str(s: &str) -> Option { from_str(s) } } impl FromStrRadix for T { #[inline(always)] - pure fn from_str_radix(s: &str, radix: uint) -> Option { + fn from_str_radix(s: &str, radix: uint) -> Option { from_str_radix(s, radix) } } @@ -203,7 +203,7 @@ impl FromStrRadix for T { /// Convert to a string as a byte slice in a given base. #[inline(always)] -pub pure fn to_str_bytes(n: T, radix: uint, f: &fn(v: &[u8]) -> U) -> U { +pub fn to_str_bytes(n: T, radix: uint, f: &fn(v: &[u8]) -> U) -> U { let (buf, _) = strconv::to_str_bytes_common(&n, radix, false, strconv::SignNeg, strconv::DigAll); f(buf) @@ -211,7 +211,7 @@ pub pure fn to_str_bytes(n: T, radix: uint, f: &fn(v: &[u8]) -> U) -> U { /// Convert to a string in base 10. #[inline(always)] -pub pure fn to_str(num: T) -> ~str { +pub fn to_str(num: T) -> ~str { let (buf, _) = strconv::to_str_common(&num, 10u, false, strconv::SignNeg, strconv::DigAll); buf @@ -219,7 +219,7 @@ pub pure fn to_str(num: T) -> ~str { /// Convert to a string in a given base. #[inline(always)] -pub pure fn to_str_radix(num: T, radix: uint) -> ~str { +pub fn to_str_radix(num: T, radix: uint) -> ~str { let (buf, _) = strconv::to_str_common(&num, radix, false, strconv::SignNeg, strconv::DigAll); buf @@ -227,14 +227,14 @@ pub pure fn to_str_radix(num: T, radix: uint) -> ~str { impl ToStr for T { #[inline(always)] - pure fn to_str(&self) -> ~str { + fn to_str(&self) -> ~str { to_str(*self) } } impl ToStrRadix for T { #[inline(always)] - pure fn to_str_radix(&self, radix: uint) -> ~str { + fn to_str_radix(&self, radix: uint) -> ~str { to_str_radix(*self, radix) } } diff --git a/src/libcore/num/uint-template/u16.rs b/src/libcore/num/uint-template/u16.rs index 84406d5ed49..bdd95120136 100644 --- a/src/libcore/num/uint-template/u16.rs +++ b/src/libcore/num/uint-template/u16.rs @@ -24,23 +24,23 @@ impl NumCast for u16 { * Cast `n` to a `u16` */ #[inline(always)] - pure fn from(n: N) -> u16 { n.to_u16() } + fn from(n: N) -> u16 { n.to_u16() } - #[inline(always)] pure fn to_u8(&self) -> u8 { *self as u8 } - #[inline(always)] pure fn to_u16(&self) -> u16 { *self } - #[inline(always)] pure fn to_u32(&self) -> u32 { *self as u32 } - #[inline(always)] pure fn to_u64(&self) -> u64 { *self as u64 } - #[inline(always)] pure fn to_uint(&self) -> uint { *self as uint } + #[inline(always)] fn to_u8(&self) -> u8 { *self as u8 } + #[inline(always)] fn to_u16(&self) -> u16 { *self } + #[inline(always)] fn to_u32(&self) -> u32 { *self as u32 } + #[inline(always)] fn to_u64(&self) -> u64 { *self as u64 } + #[inline(always)] fn to_uint(&self) -> uint { *self as uint } - #[inline(always)] pure fn to_i8(&self) -> i8 { *self as i8 } - #[inline(always)] pure fn to_i16(&self) -> i16 { *self as i16 } - #[inline(always)] pure fn to_i32(&self) -> i32 { *self as i32 } - #[inline(always)] pure fn to_i64(&self) -> i64 { *self as i64 } - #[inline(always)] pure fn to_int(&self) -> int { *self as int } + #[inline(always)] fn to_i8(&self) -> i8 { *self as i8 } + #[inline(always)] fn to_i16(&self) -> i16 { *self as i16 } + #[inline(always)] fn to_i32(&self) -> i32 { *self as i32 } + #[inline(always)] fn to_i64(&self) -> i64 { *self as i64 } + #[inline(always)] fn to_int(&self) -> int { *self as int } - #[inline(always)] pure fn to_f32(&self) -> f32 { *self as f32 } - #[inline(always)] pure fn to_f64(&self) -> f64 { *self as f64 } - #[inline(always)] pure fn to_float(&self) -> float { *self as float } + #[inline(always)] fn to_f32(&self) -> f32 { *self as f32 } + #[inline(always)] fn to_f64(&self) -> f64 { *self as f64 } + #[inline(always)] fn to_float(&self) -> float { *self as float } } #[test] diff --git a/src/libcore/num/uint-template/u32.rs b/src/libcore/num/uint-template/u32.rs index 94d2c9b75f1..7bef51489f2 100644 --- a/src/libcore/num/uint-template/u32.rs +++ b/src/libcore/num/uint-template/u32.rs @@ -24,23 +24,23 @@ impl NumCast for u32 { * Cast `n` to a `u32` */ #[inline(always)] - pure fn from(n: N) -> u32 { n.to_u32() } + fn from(n: N) -> u32 { n.to_u32() } - #[inline(always)] pure fn to_u8(&self) -> u8 { *self as u8 } - #[inline(always)] pure fn to_u16(&self) -> u16 { *self as u16 } - #[inline(always)] pure fn to_u32(&self) -> u32 { *self } - #[inline(always)] pure fn to_u64(&self) -> u64 { *self as u64 } - #[inline(always)] pure fn to_uint(&self) -> uint { *self as uint } + #[inline(always)] fn to_u8(&self) -> u8 { *self as u8 } + #[inline(always)] fn to_u16(&self) -> u16 { *self as u16 } + #[inline(always)] fn to_u32(&self) -> u32 { *self } + #[inline(always)] fn to_u64(&self) -> u64 { *self as u64 } + #[inline(always)] fn to_uint(&self) -> uint { *self as uint } - #[inline(always)] pure fn to_i8(&self) -> i8 { *self as i8 } - #[inline(always)] pure fn to_i16(&self) -> i16 { *self as i16 } - #[inline(always)] pure fn to_i32(&self) -> i32 { *self as i32 } - #[inline(always)] pure fn to_i64(&self) -> i64 { *self as i64 } - #[inline(always)] pure fn to_int(&self) -> int { *self as int } + #[inline(always)] fn to_i8(&self) -> i8 { *self as i8 } + #[inline(always)] fn to_i16(&self) -> i16 { *self as i16 } + #[inline(always)] fn to_i32(&self) -> i32 { *self as i32 } + #[inline(always)] fn to_i64(&self) -> i64 { *self as i64 } + #[inline(always)] fn to_int(&self) -> int { *self as int } - #[inline(always)] pure fn to_f32(&self) -> f32 { *self as f32 } - #[inline(always)] pure fn to_f64(&self) -> f64 { *self as f64 } - #[inline(always)] pure fn to_float(&self) -> float { *self as float } + #[inline(always)] fn to_f32(&self) -> f32 { *self as f32 } + #[inline(always)] fn to_f64(&self) -> f64 { *self as f64 } + #[inline(always)] fn to_float(&self) -> float { *self as float } } #[test] diff --git a/src/libcore/num/uint-template/u64.rs b/src/libcore/num/uint-template/u64.rs index 06d2efeeda7..fecafe37f3d 100644 --- a/src/libcore/num/uint-template/u64.rs +++ b/src/libcore/num/uint-template/u64.rs @@ -24,23 +24,23 @@ impl NumCast for u64 { * Cast `n` to a `u64` */ #[inline(always)] - pure fn from(n: N) -> u64 { n.to_u64() } + fn from(n: N) -> u64 { n.to_u64() } - #[inline(always)] pure fn to_u8(&self) -> u8 { *self as u8 } - #[inline(always)] pure fn to_u16(&self) -> u16 { *self as u16 } - #[inline(always)] pure fn to_u32(&self) -> u32 { *self as u32 } - #[inline(always)] pure fn to_u64(&self) -> u64 { *self } - #[inline(always)] pure fn to_uint(&self) -> uint { *self as uint } + #[inline(always)] fn to_u8(&self) -> u8 { *self as u8 } + #[inline(always)] fn to_u16(&self) -> u16 { *self as u16 } + #[inline(always)] fn to_u32(&self) -> u32 { *self as u32 } + #[inline(always)] fn to_u64(&self) -> u64 { *self } + #[inline(always)] fn to_uint(&self) -> uint { *self as uint } - #[inline(always)] pure fn to_i8(&self) -> i8 { *self as i8 } - #[inline(always)] pure fn to_i16(&self) -> i16 { *self as i16 } - #[inline(always)] pure fn to_i32(&self) -> i32 { *self as i32 } - #[inline(always)] pure fn to_i64(&self) -> i64 { *self as i64 } - #[inline(always)] pure fn to_int(&self) -> int { *self as int } + #[inline(always)] fn to_i8(&self) -> i8 { *self as i8 } + #[inline(always)] fn to_i16(&self) -> i16 { *self as i16 } + #[inline(always)] fn to_i32(&self) -> i32 { *self as i32 } + #[inline(always)] fn to_i64(&self) -> i64 { *self as i64 } + #[inline(always)] fn to_int(&self) -> int { *self as int } - #[inline(always)] pure fn to_f32(&self) -> f32 { *self as f32 } - #[inline(always)] pure fn to_f64(&self) -> f64 { *self as f64 } - #[inline(always)] pure fn to_float(&self) -> float { *self as float } + #[inline(always)] fn to_f32(&self) -> f32 { *self as f32 } + #[inline(always)] fn to_f64(&self) -> f64 { *self as f64 } + #[inline(always)] fn to_float(&self) -> float { *self as float } } #[test] diff --git a/src/libcore/num/uint-template/u8.rs b/src/libcore/num/uint-template/u8.rs index 31cb21473a8..0d48de67334 100644 --- a/src/libcore/num/uint-template/u8.rs +++ b/src/libcore/num/uint-template/u8.rs @@ -23,7 +23,7 @@ mod inst { // Type-specific functions here. These must be reexported by the // parent module so that they appear in core::u8 and not core::u8::u8; - pub pure fn is_ascii(x: T) -> bool { return 0 as T == x & 128 as T; } + pub fn is_ascii(x: T) -> bool { return 0 as T == x & 128 as T; } } impl NumCast for u8 { @@ -31,23 +31,23 @@ impl NumCast for u8 { * Cast `n` to a `u8` */ #[inline(always)] - pure fn from(n: N) -> u8 { n.to_u8() } + fn from(n: N) -> u8 { n.to_u8() } - #[inline(always)] pure fn to_u8(&self) -> u8 { *self } - #[inline(always)] pure fn to_u16(&self) -> u16 { *self as u16 } - #[inline(always)] pure fn to_u32(&self) -> u32 { *self as u32 } - #[inline(always)] pure fn to_u64(&self) -> u64 { *self as u64 } - #[inline(always)] pure fn to_uint(&self) -> uint { *self as uint } + #[inline(always)] fn to_u8(&self) -> u8 { *self } + #[inline(always)] fn to_u16(&self) -> u16 { *self as u16 } + #[inline(always)] fn to_u32(&self) -> u32 { *self as u32 } + #[inline(always)] fn to_u64(&self) -> u64 { *self as u64 } + #[inline(always)] fn to_uint(&self) -> uint { *self as uint } - #[inline(always)] pure fn to_i8(&self) -> i8 { *self as i8 } - #[inline(always)] pure fn to_i16(&self) -> i16 { *self as i16 } - #[inline(always)] pure fn to_i32(&self) -> i32 { *self as i32 } - #[inline(always)] pure fn to_i64(&self) -> i64 { *self as i64 } - #[inline(always)] pure fn to_int(&self) -> int { *self as int } + #[inline(always)] fn to_i8(&self) -> i8 { *self as i8 } + #[inline(always)] fn to_i16(&self) -> i16 { *self as i16 } + #[inline(always)] fn to_i32(&self) -> i32 { *self as i32 } + #[inline(always)] fn to_i64(&self) -> i64 { *self as i64 } + #[inline(always)] fn to_int(&self) -> int { *self as int } - #[inline(always)] pure fn to_f32(&self) -> f32 { *self as f32 } - #[inline(always)] pure fn to_f64(&self) -> f64 { *self as f64 } - #[inline(always)] pure fn to_float(&self) -> float { *self as float } + #[inline(always)] fn to_f32(&self) -> f32 { *self as f32 } + #[inline(always)] fn to_f64(&self) -> f64 { *self as f64 } + #[inline(always)] fn to_float(&self) -> float { *self as float } } #[test] diff --git a/src/libcore/num/uint-template/uint.rs b/src/libcore/num/uint-template/uint.rs index 3b17f4f5327..f3f27a4e48a 100644 --- a/src/libcore/num/uint-template/uint.rs +++ b/src/libcore/num/uint-template/uint.rs @@ -45,7 +45,7 @@ pub mod inst { * * The smallest integer `q` such that `x/y <= q`. */ - pub pure fn div_ceil(x: uint, y: uint) -> uint { + pub fn div_ceil(x: uint, y: uint) -> uint { let div = x / y; if x % y == 0u { div } else { div + 1u } @@ -63,7 +63,7 @@ pub mod inst { * * The integer `q` closest to `x/y`. */ - pub pure fn div_round(x: uint, y: uint) -> uint { + pub fn div_round(x: uint, y: uint) -> uint { let div = x / y; if x % y * 2u < y { div } else { div + 1u } @@ -84,7 +84,7 @@ pub mod inst { * The smallest integer `q` such that `x/y <= q`. This * is either `x/y` or `x/y + 1`. */ - pub pure fn div_floor(x: uint, y: uint) -> uint { return x / y; } + pub fn div_floor(x: uint, y: uint) -> uint { return x / y; } /** * Iterate over the range [`lo`..`hi`), or stop when requested @@ -101,7 +101,7 @@ pub mod inst { * `true` If execution proceeded correctly, `false` if it was interrupted, * that is if `it` returned `false` at any point. */ - pub pure fn iterate(lo: uint, hi: uint, it: &fn(uint) -> bool) -> bool { + pub fn iterate(lo: uint, hi: uint, it: &fn(uint) -> bool) -> bool { let mut i = lo; while i < hi { if (!it(i)) { return false; } @@ -122,7 +122,7 @@ pub mod inst { * use with integer literals of inferred integer-type as * the self-value (eg. `for 100.times { ... }`). */ - pure fn times(&self, it: &fn() -> bool) { + fn times(&self, it: &fn() -> bool) { let mut i = *self; while i > 0 { if !it() { break } @@ -133,7 +133,7 @@ pub mod inst { /// Returns the smallest power of 2 greater than or equal to `n` #[inline(always)] - pub pure fn next_power_of_two(n: uint) -> uint { + pub fn next_power_of_two(n: uint) -> uint { let halfbits: uint = sys::size_of::() * 4u; let mut tmp: uint = n - 1u; let mut shift: uint = 1u; @@ -215,23 +215,23 @@ impl NumCast for uint { * Cast `n` to a `uint` */ #[inline(always)] - pure fn from(n: N) -> uint { n.to_uint() } + fn from(n: N) -> uint { n.to_uint() } - #[inline(always)] pure fn to_u8(&self) -> u8 { *self as u8 } - #[inline(always)] pure fn to_u16(&self) -> u16 { *self as u16 } - #[inline(always)] pure fn to_u32(&self) -> u32 { *self as u32 } - #[inline(always)] pure fn to_u64(&self) -> u64 { *self as u64 } - #[inline(always)] pure fn to_uint(&self) -> uint { *self } + #[inline(always)] fn to_u8(&self) -> u8 { *self as u8 } + #[inline(always)] fn to_u16(&self) -> u16 { *self as u16 } + #[inline(always)] fn to_u32(&self) -> u32 { *self as u32 } + #[inline(always)] fn to_u64(&self) -> u64 { *self as u64 } + #[inline(always)] fn to_uint(&self) -> uint { *self } - #[inline(always)] pure fn to_i8(&self) -> i8 { *self as i8 } - #[inline(always)] pure fn to_i16(&self) -> i16 { *self as i16 } - #[inline(always)] pure fn to_i32(&self) -> i32 { *self as i32 } - #[inline(always)] pure fn to_i64(&self) -> i64 { *self as i64 } - #[inline(always)] pure fn to_int(&self) -> int { *self as int } + #[inline(always)] fn to_i8(&self) -> i8 { *self as i8 } + #[inline(always)] fn to_i16(&self) -> i16 { *self as i16 } + #[inline(always)] fn to_i32(&self) -> i32 { *self as i32 } + #[inline(always)] fn to_i64(&self) -> i64 { *self as i64 } + #[inline(always)] fn to_int(&self) -> int { *self as int } - #[inline(always)] pure fn to_f32(&self) -> f32 { *self as f32 } - #[inline(always)] pure fn to_f64(&self) -> f64 { *self as f64 } - #[inline(always)] pure fn to_float(&self) -> float { *self as float } + #[inline(always)] fn to_f32(&self) -> f32 { *self as f32 } + #[inline(always)] fn to_f64(&self) -> f64 { *self as f64 } + #[inline(always)] fn to_float(&self) -> float { *self as float } } #[test] diff --git a/src/libcore/ops.rs b/src/libcore/ops.rs index aaa4ab3fecf..2f7fe1e4aa8 100644 --- a/src/libcore/ops.rs +++ b/src/libcore/ops.rs @@ -17,65 +17,65 @@ pub trait Drop { #[lang="add"] pub trait Add { - pure fn add(&self, rhs: &RHS) -> Result; + fn add(&self, rhs: &RHS) -> Result; } #[lang="sub"] pub trait Sub { - pure fn sub(&self, rhs: &RHS) -> Result; + fn sub(&self, rhs: &RHS) -> Result; } #[lang="mul"] pub trait Mul { - pure fn mul(&self, rhs: &RHS) -> Result; + fn mul(&self, rhs: &RHS) -> Result; } #[lang="div"] pub trait Div { - pure fn div(&self, rhs: &RHS) -> Result; + fn div(&self, rhs: &RHS) -> Result; } #[lang="modulo"] pub trait Modulo { - pure fn modulo(&self, rhs: &RHS) -> Result; + fn modulo(&self, rhs: &RHS) -> Result; } #[lang="neg"] pub trait Neg { - pure fn neg(&self) -> Result; + fn neg(&self) -> Result; } #[lang="not"] pub trait Not { - pure fn not(&self) -> Result; + fn not(&self) -> Result; } #[lang="bitand"] pub trait BitAnd { - pure fn bitand(&self, rhs: &RHS) -> Result; + fn bitand(&self, rhs: &RHS) -> Result; } #[lang="bitor"] pub trait BitOr { - pure fn bitor(&self, rhs: &RHS) -> Result; + fn bitor(&self, rhs: &RHS) -> Result; } #[lang="bitxor"] pub trait BitXor { - pure fn bitxor(&self, rhs: &RHS) -> Result; + fn bitxor(&self, rhs: &RHS) -> Result; } #[lang="shl"] pub trait Shl { - pure fn shl(&self, rhs: &RHS) -> Result; + fn shl(&self, rhs: &RHS) -> Result; } #[lang="shr"] pub trait Shr { - pure fn shr(&self, rhs: &RHS) -> Result; + fn shr(&self, rhs: &RHS) -> Result; } #[lang="index"] pub trait Index { - pure fn index(&self, index: Index) -> Result; + fn index(&self, index: Index) -> Result; } diff --git a/src/libcore/option.rs b/src/libcore/option.rs index c12b78b393f..dd92333b61d 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -59,7 +59,7 @@ pub enum Option { } impl Ord for Option { - pure fn lt(&self, other: &Option) -> bool { + fn lt(&self, other: &Option) -> bool { match (self, other) { (&None, &None) => false, (&None, &Some(_)) => true, @@ -68,7 +68,7 @@ impl Ord for Option { } } - pure fn le(&self, other: &Option) -> bool { + fn le(&self, other: &Option) -> bool { match (self, other) { (&None, &None) => true, (&None, &Some(_)) => true, @@ -77,18 +77,18 @@ impl Ord for Option { } } - pure fn ge(&self, other: &Option) -> bool { + fn ge(&self, other: &Option) -> bool { ! (self < other) } - pure fn gt(&self, other: &Option) -> bool { + fn gt(&self, other: &Option) -> bool { ! (self <= other) } } impl> Add, Option> for Option { #[inline(always)] - pure fn add(&self, other: &Option) -> Option { + fn add(&self, other: &Option) -> Option { match (*self, *other) { (None, None) => None, (_, None) => *self, @@ -99,7 +99,7 @@ impl> Add, Option> for Option { } #[inline(always)] -pub pure fn get(opt: Option) -> T { +pub fn get(opt: Option) -> T { /*! Gets the value out of an option @@ -122,7 +122,7 @@ pub pure fn get(opt: Option) -> T { } #[inline(always)] -pub pure fn get_ref(opt: &'r Option) -> &'r T { +pub fn get_ref(opt: &'r Option) -> &'r T { /*! Gets an immutable reference to the value inside an option. @@ -143,7 +143,7 @@ pub pure fn get_ref(opt: &'r Option) -> &'r T { } } -pub pure fn get_mut_ref(opt: &'r mut Option) -> &'r mut T { +pub fn get_mut_ref(opt: &'r mut Option) -> &'r mut T { /*! Gets a mutable reference to the value inside an option. @@ -165,14 +165,14 @@ pub pure fn get_mut_ref(opt: &'r mut Option) -> &'r mut T { } #[inline(always)] -pub pure fn map(opt: &'r Option, f: &fn(x: &'r T) -> U) -> Option { +pub fn map(opt: &'r Option, f: &fn(x: &'r T) -> U) -> Option { //! Maps a `some` value by reference from one type to another match *opt { Some(ref x) => Some(f(x)), None => None } } #[inline(always)] -pub pure fn map_consume(opt: Option, +pub fn map_consume(opt: Option, f: &fn(v: T) -> U) -> Option { /*! * As `map`, but consumes the option and gives `f` ownership to avoid @@ -182,7 +182,7 @@ pub pure fn map_consume(opt: Option, } #[inline(always)] -pub pure fn chain(opt: Option, +pub fn chain(opt: Option, f: &fn(t: T) -> Option) -> Option { /*! * Update an optional value by optionally running its content through a @@ -196,7 +196,7 @@ pub pure fn chain(opt: Option, } #[inline(always)] -pub pure fn chain_ref(opt: &Option, +pub fn chain_ref(opt: &Option, f: &fn(x: &T) -> Option) -> Option { /*! * Update an optional value by optionally running its content by reference @@ -207,7 +207,7 @@ pub pure fn chain_ref(opt: &Option, } #[inline(always)] -pub pure fn or(opta: Option, optb: Option) -> Option { +pub fn or(opta: Option, optb: Option) -> Option { /*! * Returns the leftmost Some() value, or None if both are None. */ @@ -218,7 +218,7 @@ pub pure fn or(opta: Option, optb: Option) -> Option { } #[inline(always)] -pub pure fn while_some(x: Option, blk: &fn(v: T) -> Option) { +pub fn while_some(x: Option, blk: &fn(v: T) -> Option) { //! Applies a function zero or more times until the result is none. let mut opt = x; @@ -228,35 +228,35 @@ pub pure fn while_some(x: Option, blk: &fn(v: T) -> Option) { } #[inline(always)] -pub pure fn is_none(opt: &const Option) -> bool { +pub fn is_none(opt: &const Option) -> bool { //! Returns true if the option equals `none` match *opt { None => true, Some(_) => false } } #[inline(always)] -pub pure fn is_some(opt: &const Option) -> bool { +pub fn is_some(opt: &const Option) -> bool { //! Returns true if the option contains some value !is_none(opt) } #[inline(always)] -pub pure fn get_or_zero(opt: Option) -> T { +pub fn get_or_zero(opt: Option) -> T { //! Returns the contained value or zero (for this type) match opt { Some(copy x) => x, None => Zero::zero() } } #[inline(always)] -pub pure fn get_or_default(opt: Option, def: T) -> T { +pub fn get_or_default(opt: Option, def: T) -> T { //! Returns the contained value or a default match opt { Some(copy x) => x, None => def } } #[inline(always)] -pub pure fn map_default(opt: &'r Option, def: U, +pub fn map_default(opt: &'r Option, def: U, f: &fn(&'r T) -> U) -> U { //! Applies a function to the contained value or returns a default @@ -264,7 +264,7 @@ pub pure fn map_default(opt: &'r Option, def: U, } #[inline(always)] -pub pure fn unwrap(opt: Option) -> T { +pub fn unwrap(opt: Option) -> T { /*! Moves a value out of an option type and returns it. @@ -302,7 +302,7 @@ pub fn swap_unwrap(opt: &mut Option) -> T { } #[inline(always)] -pub pure fn expect(opt: Option, reason: &str) -> T { +pub fn expect(opt: Option, reason: &str) -> T { //! As unwrap, but with a specified failure message. match opt { Some(val) => val, @@ -313,12 +313,12 @@ pub pure fn expect(opt: Option, reason: &str) -> T { impl BaseIter for Option { /// Performs an operation on the contained value by reference #[inline(always)] - pure fn each(&self, f: &fn(x: &'self T) -> bool) { + fn each(&self, f: &fn(x: &'self T) -> bool) { match *self { None => (), Some(ref t) => { f(t); } } } #[inline(always)] - pure fn size_hint(&self) -> Option { + fn size_hint(&self) -> Option { if self.is_some() { Some(1) } else { Some(0) } } } @@ -333,42 +333,42 @@ impl MutableIter for Option { pub impl Option { /// Returns true if the option equals `none` #[inline(always)] - pure fn is_none(&const self) -> bool { is_none(self) } + fn is_none(&const self) -> bool { is_none(self) } /// Returns true if the option contains some value #[inline(always)] - pure fn is_some(&const self) -> bool { is_some(self) } + fn is_some(&const self) -> bool { is_some(self) } /** * Update an optional value by optionally running its content by reference * through a function that returns an option. */ #[inline(always)] - pure fn chain_ref(&self, f: &fn(x: &T) -> Option) -> Option { + fn chain_ref(&self, f: &fn(x: &T) -> Option) -> Option { chain_ref(self, f) } /// Maps a `some` value from one type to another by reference #[inline(always)] - pure fn map(&self, f: &fn(&'self T) -> U) -> Option { map(self, f) } + fn map(&self, f: &fn(&'self T) -> U) -> Option { map(self, f) } /// As `map`, but consumes the option and gives `f` ownership to avoid /// copying. #[inline(always)] - pure fn map_consume(self, f: &fn(v: T) -> U) -> Option { + fn map_consume(self, f: &fn(v: T) -> U) -> Option { map_consume(self, f) } /// Applies a function to the contained value or returns a default #[inline(always)] - pure fn map_default(&self, def: U, f: &fn(&'self T) -> U) -> U { + fn map_default(&self, def: U, f: &fn(&'self T) -> U) -> U { map_default(self, def, f) } /// As `map_default`, but consumes the option and gives `f` /// ownership to avoid copying. #[inline(always)] - pure fn map_consume_default(self, def: U, f: &fn(v: T) -> U) -> U { + fn map_consume_default(self, def: U, f: &fn(v: T) -> U) -> U { match self { None => def, Some(v) => f(v) } } @@ -403,7 +403,7 @@ pub impl Option { case explicitly. */ #[inline(always)] - pure fn get_ref(&self) -> &'self T { get_ref(self) } + fn get_ref(&self) -> &'self T { get_ref(self) } /** Gets a mutable reference to the value inside an option. @@ -420,7 +420,7 @@ pub impl Option { case explicitly. */ #[inline(always)] - pure fn get_mut_ref(&mut self) -> &'self mut T { get_mut_ref(self) } + fn get_mut_ref(&mut self) -> &'self mut T { get_mut_ref(self) } /** * Gets the value out of an option without copying. @@ -430,7 +430,7 @@ pub impl Option { * Fails if the value equals `none` */ #[inline(always)] - pure fn unwrap(self) -> T { unwrap(self) } + fn unwrap(self) -> T { unwrap(self) } /** * The option dance. Moves a value out of an option type and returns it, @@ -452,7 +452,7 @@ pub impl Option { * Fails if the value equals `none` */ #[inline(always)] - pure fn expect(self, reason: &str) -> T { expect(self, reason) } + fn expect(self, reason: &str) -> T { expect(self, reason) } } pub impl Option { @@ -471,21 +471,21 @@ pub impl Option { case explicitly. */ #[inline(always)] - pure fn get(self) -> T { get(self) } + fn get(self) -> T { get(self) } #[inline(always)] - pure fn get_or_default(self, def: T) -> T { get_or_default(self, def) } + fn get_or_default(self, def: T) -> T { get_or_default(self, def) } /// Applies a function zero or more times until the result is none. #[inline(always)] - pure fn while_some(self, blk: &fn(v: T) -> Option) { + fn while_some(self, blk: &fn(v: T) -> Option) { while_some(self, blk) } } pub impl Option { #[inline(always)] - pure fn get_or_zero(self) -> T { get_or_zero(self) } + fn get_or_zero(self) -> T { get_or_zero(self) } } #[test] diff --git a/src/libcore/owned.rs b/src/libcore/owned.rs index 486ce44147a..c483ec79e21 100644 --- a/src/libcore/owned.rs +++ b/src/libcore/owned.rs @@ -15,20 +15,20 @@ #[cfg(notest)] impl Eq for ~T { #[inline(always)] - pure fn eq(&self, other: &~T) -> bool { *(*self) == *(*other) } + fn eq(&self, other: &~T) -> bool { *(*self) == *(*other) } #[inline(always)] - pure fn ne(&self, other: &~T) -> bool { *(*self) != *(*other) } + fn ne(&self, other: &~T) -> bool { *(*self) != *(*other) } } #[cfg(notest)] impl Ord for ~T { #[inline(always)] - pure fn lt(&self, other: &~T) -> bool { *(*self) < *(*other) } + fn lt(&self, other: &~T) -> bool { *(*self) < *(*other) } #[inline(always)] - pure fn le(&self, other: &~T) -> bool { *(*self) <= *(*other) } + fn le(&self, other: &~T) -> bool { *(*self) <= *(*other) } #[inline(always)] - pure fn ge(&self, other: &~T) -> bool { *(*self) >= *(*other) } + fn ge(&self, other: &~T) -> bool { *(*self) >= *(*other) } #[inline(always)] - pure fn gt(&self, other: &~T) -> bool { *(*self) > *(*other) } + fn gt(&self, other: &~T) -> bool { *(*self) > *(*other) } } diff --git a/src/libcore/path.rs b/src/libcore/path.rs index 7189ecaadda..5181c08bba0 100644 --- a/src/libcore/path.rs +++ b/src/libcore/path.rs @@ -28,7 +28,7 @@ pub struct WindowsPath { components: ~[~str], } -pub pure fn WindowsPath(s: &str) -> WindowsPath { +pub fn WindowsPath(s: &str) -> WindowsPath { GenericPath::from_str(s) } @@ -38,42 +38,42 @@ pub struct PosixPath { components: ~[~str], } -pub pure fn PosixPath(s: &str) -> PosixPath { +pub fn PosixPath(s: &str) -> PosixPath { GenericPath::from_str(s) } pub trait GenericPath { - pure fn from_str(&str) -> Self; + fn from_str(&str) -> Self; - pure fn dirname(&self) -> ~str; - pure fn filename(&self) -> Option<~str>; - pure fn filestem(&self) -> Option<~str>; - pure fn filetype(&self) -> Option<~str>; + fn dirname(&self) -> ~str; + fn filename(&self) -> Option<~str>; + fn filestem(&self) -> Option<~str>; + fn filetype(&self) -> Option<~str>; - pure fn with_dirname(&self, (&str)) -> Self; - pure fn with_filename(&self, (&str)) -> Self; - pure fn with_filestem(&self, (&str)) -> Self; - pure fn with_filetype(&self, (&str)) -> Self; + fn with_dirname(&self, (&str)) -> Self; + fn with_filename(&self, (&str)) -> Self; + fn with_filestem(&self, (&str)) -> Self; + fn with_filetype(&self, (&str)) -> Self; - pure fn dir_path(&self) -> Self; - pure fn file_path(&self) -> Self; + fn dir_path(&self) -> Self; + fn file_path(&self) -> Self; - pure fn push(&self, (&str)) -> Self; - pure fn push_rel(&self, (&Self)) -> Self; - pure fn push_many(&self, (&[~str])) -> Self; - pure fn pop(&self) -> Self; + fn push(&self, (&str)) -> Self; + fn push_rel(&self, (&Self)) -> Self; + fn push_many(&self, (&[~str])) -> Self; + fn pop(&self) -> Self; - pure fn unsafe_join(&self, (&Self)) -> Self; - pure fn is_restricted(&self) -> bool; + fn unsafe_join(&self, (&Self)) -> Self; + fn is_restricted(&self) -> bool; - pure fn normalize(&self) -> Self; + fn normalize(&self) -> Self; } #[cfg(windows)] pub type Path = WindowsPath; #[cfg(windows)] -pub pure fn Path(s: &str) -> Path { +pub fn Path(s: &str) -> Path { WindowsPath(s) } @@ -81,7 +81,7 @@ pub pure fn Path(s: &str) -> Path { pub type Path = PosixPath; #[cfg(unix)] -pub pure fn Path(s: &str) -> Path { +pub fn Path(s: &str) -> Path { PosixPath(s) } @@ -367,7 +367,7 @@ pub impl Path { } impl ToStr for PosixPath { - pure fn to_str(&self) -> ~str { + fn to_str(&self) -> ~str { let mut s = ~""; if self.is_absolute { s += "/"; @@ -380,14 +380,14 @@ impl ToStr for PosixPath { // PosixPath and WindowsPath, most of their methods are common. impl GenericPath for PosixPath { - pure fn from_str(s: &str) -> PosixPath { + fn from_str(s: &str) -> PosixPath { let mut components = str::split_nonempty(s, |c| c == '/'); let is_absolute = (s.len() != 0 && s[0] == '/' as u8); return PosixPath { is_absolute: is_absolute, components: components } } - pure fn dirname(&self) -> ~str { + fn dirname(&self) -> ~str { unsafe { let s = self.dir_path().to_str(); if s.len() == 0 { @@ -398,14 +398,14 @@ impl GenericPath for PosixPath { } } - pure fn filename(&self) -> Option<~str> { + fn filename(&self) -> Option<~str> { match self.components.len() { 0 => None, n => Some(copy self.components[n - 1]) } } - pure fn filestem(&self) -> Option<~str> { + fn filestem(&self) -> Option<~str> { match self.filename() { None => None, Some(ref f) => { @@ -417,7 +417,7 @@ impl GenericPath for PosixPath { } } - pure fn filetype(&self) -> Option<~str> { + fn filetype(&self) -> Option<~str> { match self.filename() { None => None, Some(ref f) => { @@ -429,7 +429,7 @@ impl GenericPath for PosixPath { } } - pure fn with_dirname(&self, d: &str) -> PosixPath { + fn with_dirname(&self, d: &str) -> PosixPath { let dpath = PosixPath(d); match self.filename() { Some(ref f) => dpath.push(*f), @@ -437,21 +437,21 @@ impl GenericPath for PosixPath { } } - pure fn with_filename(&self, f: &str) -> PosixPath { + fn with_filename(&self, f: &str) -> PosixPath { unsafe { fail_unless!(! str::any(f, |c| windows::is_sep(c as u8))); self.dir_path().push(f) } } - pure fn with_filestem(&self, s: &str) -> PosixPath { + fn with_filestem(&self, s: &str) -> PosixPath { match self.filetype() { None => self.with_filename(s), Some(ref t) => self.with_filename(str::from_slice(s) + *t) } } - pure fn with_filetype(&self, t: &str) -> PosixPath { + fn with_filetype(&self, t: &str) -> PosixPath { if t.len() == 0 { match self.filestem() { None => copy *self, @@ -466,7 +466,7 @@ impl GenericPath for PosixPath { } } - pure fn dir_path(&self) -> PosixPath { + fn dir_path(&self) -> PosixPath { if self.components.len() != 0 { self.pop() } else { @@ -474,7 +474,7 @@ impl GenericPath for PosixPath { } } - pure fn file_path(&self) -> PosixPath { + fn file_path(&self) -> PosixPath { let cs = match self.filename() { None => ~[], Some(ref f) => ~[copy *f] @@ -483,12 +483,12 @@ impl GenericPath for PosixPath { components: cs } } - pure fn push_rel(&self, other: &PosixPath) -> PosixPath { + fn push_rel(&self, other: &PosixPath) -> PosixPath { fail_unless!(!other.is_absolute); self.push_many(other.components) } - pure fn unsafe_join(&self, other: &PosixPath) -> PosixPath { + fn unsafe_join(&self, other: &PosixPath) -> PosixPath { if other.is_absolute { PosixPath { is_absolute: true, components: copy other.components } @@ -497,11 +497,11 @@ impl GenericPath for PosixPath { } } - pure fn is_restricted(&self) -> bool { + fn is_restricted(&self) -> bool { false } - pure fn push_many(&self, cs: &[~str]) -> PosixPath { + fn push_many(&self, cs: &[~str]) -> PosixPath { let mut v = copy self.components; for cs.each |e| { let mut ss = str::split_nonempty( @@ -513,14 +513,14 @@ impl GenericPath for PosixPath { components: v } } - pure fn push(&self, s: &str) -> PosixPath { + fn push(&self, s: &str) -> PosixPath { let mut v = copy self.components; let mut ss = str::split_nonempty(s, |c| windows::is_sep(c as u8)); unsafe { v.push_all_move(ss); } PosixPath { components: v, ..copy *self } } - pure fn pop(&self) -> PosixPath { + fn pop(&self) -> PosixPath { let mut cs = copy self.components; if cs.len() != 0 { unsafe { cs.pop(); } @@ -532,7 +532,7 @@ impl GenericPath for PosixPath { //..self } } - pure fn normalize(&self) -> PosixPath { + fn normalize(&self) -> PosixPath { return PosixPath { is_absolute: self.is_absolute, components: normalize(self.components) @@ -543,7 +543,7 @@ impl GenericPath for PosixPath { impl ToStr for WindowsPath { - pure fn to_str(&self) -> ~str { + fn to_str(&self) -> ~str { let mut s = ~""; match self.host { Some(ref h) => { s += "\\\\"; s += *h; } @@ -563,7 +563,7 @@ impl ToStr for WindowsPath { impl GenericPath for WindowsPath { - pure fn from_str(s: &str) -> WindowsPath { + fn from_str(s: &str) -> WindowsPath { let host; let device; let rest; @@ -599,7 +599,7 @@ impl GenericPath for WindowsPath { components: components } } - pure fn dirname(&self) -> ~str { + fn dirname(&self) -> ~str { unsafe { let s = self.dir_path().to_str(); if s.len() == 0 { @@ -610,14 +610,14 @@ impl GenericPath for WindowsPath { } } - pure fn filename(&self) -> Option<~str> { + fn filename(&self) -> Option<~str> { match self.components.len() { 0 => None, n => Some(copy self.components[n - 1]) } } - pure fn filestem(&self) -> Option<~str> { + fn filestem(&self) -> Option<~str> { match self.filename() { None => None, Some(ref f) => { @@ -629,7 +629,7 @@ impl GenericPath for WindowsPath { } } - pure fn filetype(&self) -> Option<~str> { + fn filetype(&self) -> Option<~str> { match self.filename() { None => None, Some(ref f) => { @@ -641,7 +641,7 @@ impl GenericPath for WindowsPath { } } - pure fn with_dirname(&self, d: &str) -> WindowsPath { + fn with_dirname(&self, d: &str) -> WindowsPath { let dpath = WindowsPath(d); match self.filename() { Some(ref f) => dpath.push(*f), @@ -649,19 +649,19 @@ impl GenericPath for WindowsPath { } } - pure fn with_filename(&self, f: &str) -> WindowsPath { + fn with_filename(&self, f: &str) -> WindowsPath { fail_unless!(! str::any(f, |c| windows::is_sep(c as u8))); self.dir_path().push(f) } - pure fn with_filestem(&self, s: &str) -> WindowsPath { + fn with_filestem(&self, s: &str) -> WindowsPath { match self.filetype() { None => self.with_filename(s), Some(ref t) => self.with_filename(str::from_slice(s) + *t) } } - pure fn with_filetype(&self, t: &str) -> WindowsPath { + fn with_filetype(&self, t: &str) -> WindowsPath { if t.len() == 0 { match self.filestem() { None => copy *self, @@ -677,7 +677,7 @@ impl GenericPath for WindowsPath { } } - pure fn dir_path(&self) -> WindowsPath { + fn dir_path(&self) -> WindowsPath { if self.components.len() != 0 { self.pop() } else { @@ -685,7 +685,7 @@ impl GenericPath for WindowsPath { } } - pure fn file_path(&self) -> WindowsPath { + fn file_path(&self) -> WindowsPath { let cs = match self.filename() { None => ~[], Some(ref f) => ~[copy *f] @@ -696,12 +696,12 @@ impl GenericPath for WindowsPath { components: cs } } - pure fn push_rel(&self, other: &WindowsPath) -> WindowsPath { + fn push_rel(&self, other: &WindowsPath) -> WindowsPath { fail_unless!(!other.is_absolute); self.push_many(other.components) } - pure fn unsafe_join(&self, other: &WindowsPath) -> WindowsPath { + fn unsafe_join(&self, other: &WindowsPath) -> WindowsPath { /* rhs not absolute is simple push */ if !other.is_absolute { return self.push_many(other.components); @@ -743,7 +743,7 @@ impl GenericPath for WindowsPath { } } - pure fn is_restricted(&self) -> bool { + fn is_restricted(&self) -> bool { match self.filestem() { Some(stem) => { match stem.to_lower() { @@ -756,7 +756,7 @@ impl GenericPath for WindowsPath { } } - pure fn push_many(&self, cs: &[~str]) -> WindowsPath { + fn push_many(&self, cs: &[~str]) -> WindowsPath { let mut v = copy self.components; for cs.each |e| { let mut ss = str::split_nonempty( @@ -773,14 +773,14 @@ impl GenericPath for WindowsPath { } } - pure fn push(&self, s: &str) -> WindowsPath { + fn push(&self, s: &str) -> WindowsPath { let mut v = copy self.components; let mut ss = str::split_nonempty(s, |c| windows::is_sep(c as u8)); unsafe { v.push_all_move(ss); } return WindowsPath { components: v, ..copy *self } } - pure fn pop(&self) -> WindowsPath { + fn pop(&self) -> WindowsPath { let mut cs = copy self.components; if cs.len() != 0 { unsafe { cs.pop(); } @@ -793,7 +793,7 @@ impl GenericPath for WindowsPath { } } - pure fn normalize(&self) -> WindowsPath { + fn normalize(&self) -> WindowsPath { return WindowsPath { host: copy self.host, device: match self.device { @@ -807,7 +807,7 @@ impl GenericPath for WindowsPath { } -pub pure fn normalize(components: &[~str]) -> ~[~str] { +pub fn normalize(components: &[~str]) -> ~[~str] { let mut cs = ~[]; unsafe { for components.each |c| { @@ -831,11 +831,11 @@ pub mod windows { use option::{None, Option, Some}; #[inline(always)] - pub pure fn is_sep(u: u8) -> bool { + pub fn is_sep(u: u8) -> bool { u == '/' as u8 || u == '\\' as u8 } - pub pure fn extract_unc_prefix(s: &str) -> Option<(~str,~str)> { + pub fn extract_unc_prefix(s: &str) -> Option<(~str,~str)> { if (s.len() > 1 && (s[0] == '\\' as u8 || s[0] == '/' as u8) && s[0] == s[1]) { @@ -852,7 +852,7 @@ pub mod windows { None } - pub pure fn extract_drive_prefix(s: &str) -> Option<(~str,~str)> { + pub fn extract_drive_prefix(s: &str) -> Option<(~str,~str)> { unsafe { if (s.len() > 1 && libc::isalpha(s[0] as libc::c_int) != 0 && diff --git a/src/libcore/pipes.rs b/src/libcore/pipes.rs index a5d1cfa2793..710f2c51ee8 100644 --- a/src/libcore/pipes.rs +++ b/src/libcore/pipes.rs @@ -111,10 +111,10 @@ enum State { } impl Eq for State { - pure fn eq(&self, other: &State) -> bool { + fn eq(&self, other: &State) -> bool { ((*self) as uint) == ((*other) as uint) } - pure fn ne(&self, other: &State) -> bool { !(*self).eq(other) } + fn ne(&self, other: &State) -> bool { !(*self).eq(other) } } pub struct BufferHeader { @@ -551,7 +551,7 @@ pub fn try_recv(p: RecvPacketBuffered) } /// Returns true if messages are available. -pub pure fn peek(p: &RecvPacketBuffered) -> bool { +pub fn peek(p: &RecvPacketBuffered) -> bool { match unsafe {(*p.header()).state} { Empty | Terminated => false, Blocked => fail!(~"peeking on blocked packet"), @@ -723,11 +723,11 @@ pub fn select2( #[doc(hidden)] pub trait Selectable { - pure fn header(&self) -> *PacketHeader; + fn header(&self) -> *PacketHeader; } impl Selectable for *PacketHeader { - pure fn header(&self) -> *PacketHeader { *self } + fn header(&self) -> *PacketHeader { *self } } /// Returns the index of an endpoint that is ready to receive. @@ -812,7 +812,7 @@ pub impl SendPacketBuffered { option::unwrap(p) } - pure fn header(&self) -> *PacketHeader { + fn header(&self) -> *PacketHeader { match self.p { Some(packet) => unsafe { let packet = &*packet; @@ -879,7 +879,7 @@ pub impl RecvPacketBuffered { } impl Selectable for RecvPacketBuffered { - pure fn header(&self) -> *PacketHeader { + fn header(&self) -> *PacketHeader { match self.p { Some(packet) => unsafe { let packet = &*packet; diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs index c1b6b26d86a..fa96467cb0f 100644 --- a/src/libcore/ptr.rs +++ b/src/libcore/ptr.rs @@ -51,11 +51,11 @@ pub mod rusti { /// Get an unsafe pointer to a value #[inline(always)] -pub pure fn addr_of(val: &T) -> *T { unsafe { rusti::addr_of(*val) } } +pub fn addr_of(val: &T) -> *T { unsafe { rusti::addr_of(*val) } } /// Calculate the offset from a pointer #[inline(always)] -pub pure fn offset(ptr: *T, count: uint) -> *T { +pub fn offset(ptr: *T, count: uint) -> *T { unsafe { (ptr as uint + count * sys::size_of::()) as *T } @@ -63,7 +63,7 @@ pub pure fn offset(ptr: *T, count: uint) -> *T { /// Calculate the offset from a const pointer #[inline(always)] -pub pure fn const_offset(ptr: *const T, count: uint) -> *const T { +pub fn const_offset(ptr: *const T, count: uint) -> *const T { unsafe { (ptr as uint + count * sys::size_of::()) as *T } @@ -71,7 +71,7 @@ pub pure fn const_offset(ptr: *const T, count: uint) -> *const T { /// Calculate the offset from a mut pointer #[inline(always)] -pub pure fn mut_offset(ptr: *mut T, count: uint) -> *mut T { +pub fn mut_offset(ptr: *mut T, count: uint) -> *mut T { (ptr as uint + count * sys::size_of::()) as *mut T } @@ -93,19 +93,19 @@ pub unsafe fn position(buf: *T, f: &fn(&T) -> bool) -> uint { /// Create an unsafe null pointer #[inline(always)] -pub pure fn null() -> *T { unsafe { cast::reinterpret_cast(&0u) } } +pub fn null() -> *T { unsafe { cast::reinterpret_cast(&0u) } } /// Create an unsafe mutable null pointer #[inline(always)] -pub pure fn mut_null() -> *mut T { unsafe { cast::reinterpret_cast(&0u) } } +pub fn mut_null() -> *mut T { unsafe { cast::reinterpret_cast(&0u) } } /// Returns true if the pointer is equal to the null pointer. #[inline(always)] -pub pure fn is_null(ptr: *const T) -> bool { ptr == null() } +pub fn is_null(ptr: *const T) -> bool { ptr == null() } /// Returns true if the pointer is not equal to the null pointer. #[inline(always)] -pub pure fn is_not_null(ptr: *const T) -> bool { !is_null(ptr) } +pub fn is_not_null(ptr: *const T) -> bool { !is_null(ptr) } /** * Copies data from one location to another @@ -138,7 +138,7 @@ pub unsafe fn set_memory(dst: *mut T, c: int, count: uint) { reinterpret_cast. */ #[inline(always)] -pub pure fn to_unsafe_ptr(thing: &T) -> *T { +pub fn to_unsafe_ptr(thing: &T) -> *T { unsafe { cast::reinterpret_cast(&thing) } } @@ -148,7 +148,7 @@ pub pure fn to_unsafe_ptr(thing: &T) -> *T { reinterpret_cast. */ #[inline(always)] -pub pure fn to_const_unsafe_ptr(thing: &const T) -> *const T { +pub fn to_const_unsafe_ptr(thing: &const T) -> *const T { unsafe { cast::reinterpret_cast(&thing) } } @@ -158,7 +158,7 @@ pub pure fn to_const_unsafe_ptr(thing: &const T) -> *const T { reinterpret_cast. */ #[inline(always)] -pub pure fn to_mut_unsafe_ptr(thing: &mut T) -> *mut T { +pub fn to_mut_unsafe_ptr(thing: &mut T) -> *mut T { unsafe { cast::reinterpret_cast(&thing) } } @@ -170,7 +170,7 @@ pub pure fn to_mut_unsafe_ptr(thing: &mut T) -> *mut T { (I couldn't think of a cutesy name for this one.) */ #[inline(always)] -pub pure fn to_uint(thing: &T) -> uint { +pub fn to_uint(thing: &T) -> uint { unsafe { cast::reinterpret_cast(&thing) } @@ -178,7 +178,7 @@ pub pure fn to_uint(thing: &T) -> uint { /// Determine if two borrowed pointers point to the same thing. #[inline(always)] -pub pure fn ref_eq(thing: &'a T, other: &'b T) -> bool { +pub fn ref_eq(thing: &'a T, other: &'b T) -> bool { to_uint(thing) == to_uint(other) } @@ -223,46 +223,46 @@ pub unsafe fn array_each(arr: **T, cb: &fn(*T)) { } pub trait Ptr { - pure fn is_null(&const self) -> bool; - pure fn is_not_null(&const self) -> bool; - pure fn offset(&self, count: uint) -> Self; + fn is_null(&const self) -> bool; + fn is_not_null(&const self) -> bool; + fn offset(&self, count: uint) -> Self; } /// Extension methods for immutable pointers impl Ptr for *T { /// Returns true if the pointer is equal to the null pointer. #[inline(always)] - pure fn is_null(&const self) -> bool { is_null(*self) } + fn is_null(&const self) -> bool { is_null(*self) } /// Returns true if the pointer is not equal to the null pointer. #[inline(always)] - pure fn is_not_null(&const self) -> bool { is_not_null(*self) } + fn is_not_null(&const self) -> bool { is_not_null(*self) } /// Calculates the offset from a pointer. #[inline(always)] - pure fn offset(&self, count: uint) -> *T { offset(*self, count) } + fn offset(&self, count: uint) -> *T { offset(*self, count) } } /// Extension methods for mutable pointers impl Ptr for *mut T { /// Returns true if the pointer is equal to the null pointer. #[inline(always)] - pure fn is_null(&const self) -> bool { is_null(*self) } + fn is_null(&const self) -> bool { is_null(*self) } /// Returns true if the pointer is not equal to the null pointer. #[inline(always)] - pure fn is_not_null(&const self) -> bool { is_not_null(*self) } + fn is_not_null(&const self) -> bool { is_not_null(*self) } /// Calculates the offset from a mutable pointer. #[inline(always)] - pure fn offset(&self, count: uint) -> *mut T { mut_offset(*self, count) } + fn offset(&self, count: uint) -> *mut T { mut_offset(*self, count) } } // Equality for pointers #[cfg(notest)] impl Eq for *const T { #[inline(always)] - pure fn eq(&self, other: &*const T) -> bool { + fn eq(&self, other: &*const T) -> bool { unsafe { let a: uint = cast::reinterpret_cast(&(*self)); let b: uint = cast::reinterpret_cast(&(*other)); @@ -270,14 +270,14 @@ impl Eq for *const T { } } #[inline(always)] - pure fn ne(&self, other: &*const T) -> bool { !(*self).eq(other) } + fn ne(&self, other: &*const T) -> bool { !(*self).eq(other) } } // Comparison for pointers #[cfg(notest)] impl Ord for *const T { #[inline(always)] - pure fn lt(&self, other: &*const T) -> bool { + fn lt(&self, other: &*const T) -> bool { unsafe { let a: uint = cast::reinterpret_cast(&(*self)); let b: uint = cast::reinterpret_cast(&(*other)); @@ -285,7 +285,7 @@ impl Ord for *const T { } } #[inline(always)] - pure fn le(&self, other: &*const T) -> bool { + fn le(&self, other: &*const T) -> bool { unsafe { let a: uint = cast::reinterpret_cast(&(*self)); let b: uint = cast::reinterpret_cast(&(*other)); @@ -293,7 +293,7 @@ impl Ord for *const T { } } #[inline(always)] - pure fn ge(&self, other: &*const T) -> bool { + fn ge(&self, other: &*const T) -> bool { unsafe { let a: uint = cast::reinterpret_cast(&(*self)); let b: uint = cast::reinterpret_cast(&(*other)); @@ -301,7 +301,7 @@ impl Ord for *const T { } } #[inline(always)] - pure fn gt(&self, other: &*const T) -> bool { + fn gt(&self, other: &*const T) -> bool { unsafe { let a: uint = cast::reinterpret_cast(&(*self)); let b: uint = cast::reinterpret_cast(&(*other)); @@ -314,11 +314,11 @@ impl Ord for *const T { #[cfg(notest)] impl Eq for &'self const T { #[inline(always)] - pure fn eq(&self, other: & &'self const T) -> bool { + fn eq(&self, other: & &'self const T) -> bool { return *(*self) == *(*other); } #[inline(always)] - pure fn ne(&self, other: & &'self const T) -> bool { + fn ne(&self, other: & &'self const T) -> bool { return *(*self) != *(*other); } } @@ -327,19 +327,19 @@ impl Eq for &'self const T { #[cfg(notest)] impl Ord for &'self const T { #[inline(always)] - pure fn lt(&self, other: & &'self const T) -> bool { + fn lt(&self, other: & &'self const T) -> bool { *(*self) < *(*other) } #[inline(always)] - pure fn le(&self, other: & &'self const T) -> bool { + fn le(&self, other: & &'self const T) -> bool { *(*self) <= *(*other) } #[inline(always)] - pure fn ge(&self, other: & &'self const T) -> bool { + fn ge(&self, other: & &'self const T) -> bool { *(*self) >= *(*other) } #[inline(always)] - pure fn gt(&self, other: & &'self const T) -> bool { + fn gt(&self, other: & &'self const T) -> bool { *(*self) > *(*other) } } diff --git a/src/libcore/rand.rs b/src/libcore/rand.rs index 6902cd4ef69..fbdda02dcdc 100644 --- a/src/libcore/rand.rs +++ b/src/libcore/rand.rs @@ -527,12 +527,12 @@ impl Rng for XorShiftState { } } -pub pure fn xorshift() -> @Rng { +pub fn xorshift() -> @Rng { // constants taken from http://en.wikipedia.org/wiki/Xorshift seeded_xorshift(123456789u32, 362436069u32, 521288629u32, 88675123u32) } -pub pure fn seeded_xorshift(x: u32, y: u32, z: u32, w: u32) -> @Rng { +pub fn seeded_xorshift(x: u32, y: u32, z: u32, w: u32) -> @Rng { @XorShiftState { x: x, y: y, z: z, w: w } as @Rng } diff --git a/src/libcore/result.rs b/src/libcore/result.rs index 18594a73d65..5dd2eaf5533 100644 --- a/src/libcore/result.rs +++ b/src/libcore/result.rs @@ -36,7 +36,7 @@ pub enum Result { * If the result is an error */ #[inline(always)] -pub pure fn get(res: &Result) -> T { +pub fn get(res: &Result) -> T { match *res { Ok(copy t) => t, Err(ref the_err) => unsafe { @@ -53,7 +53,7 @@ pub pure fn get(res: &Result) -> T { * If the result is an error */ #[inline(always)] -pub pure fn get_ref(res: &'a Result) -> &'a T { +pub fn get_ref(res: &'a Result) -> &'a T { match *res { Ok(ref t) => t, Err(ref the_err) => unsafe { @@ -70,7 +70,7 @@ pub pure fn get_ref(res: &'a Result) -> &'a T { * If the result is not an error */ #[inline(always)] -pub pure fn get_err(res: &Result) -> U { +pub fn get_err(res: &Result) -> U { match *res { Err(copy u) => u, Ok(_) => fail!(~"get_err called on ok result") @@ -79,7 +79,7 @@ pub pure fn get_err(res: &Result) -> U { /// Returns true if the result is `ok` #[inline(always)] -pub pure fn is_ok(res: &Result) -> bool { +pub fn is_ok(res: &Result) -> bool { match *res { Ok(_) => true, Err(_) => false @@ -88,7 +88,7 @@ pub pure fn is_ok(res: &Result) -> bool { /// Returns true if the result is `err` #[inline(always)] -pub pure fn is_err(res: &Result) -> bool { +pub fn is_err(res: &Result) -> bool { !is_ok(res) } @@ -99,7 +99,7 @@ pub pure fn is_err(res: &Result) -> bool { * result variants are converted to `either::left`. */ #[inline(always)] -pub pure fn to_either(res: &Result) +pub fn to_either(res: &Result) -> Either { match *res { Ok(copy res) => either::Right(res), @@ -122,7 +122,7 @@ pub pure fn to_either(res: &Result) * } */ #[inline(always)] -pub pure fn chain(res: Result, op: &fn(T) +pub fn chain(res: Result, op: &fn(T) -> Result) -> Result { match res { Ok(t) => op(t), @@ -139,7 +139,7 @@ pub pure fn chain(res: Result, op: &fn(T) * successful result while handling an error. */ #[inline(always)] -pub pure fn chain_err( +pub fn chain_err( res: Result, op: &fn(t: V) -> Result) -> Result { @@ -164,7 +164,7 @@ pub pure fn chain_err( * } */ #[inline(always)] -pub pure fn iter(res: &Result, f: &fn(&T)) { +pub fn iter(res: &Result, f: &fn(&T)) { match *res { Ok(ref t) => f(t), Err(_) => () @@ -180,7 +180,7 @@ pub pure fn iter(res: &Result, f: &fn(&T)) { * handling an error. */ #[inline(always)] -pub pure fn iter_err(res: &Result, f: &fn(&E)) { +pub fn iter_err(res: &Result, f: &fn(&E)) { match *res { Ok(_) => (), Err(ref e) => f(e) @@ -202,7 +202,7 @@ pub pure fn iter_err(res: &Result, f: &fn(&E)) { * } */ #[inline(always)] -pub pure fn map(res: &Result, op: &fn(&T) -> U) +pub fn map(res: &Result, op: &fn(&T) -> U) -> Result { match *res { Ok(ref t) => Ok(op(t)), @@ -219,7 +219,7 @@ pub pure fn map(res: &Result, op: &fn(&T) -> U) * successful result while handling an error. */ #[inline(always)] -pub pure fn map_err(res: &Result, op: &fn(&E) -> F) +pub fn map_err(res: &Result, op: &fn(&E) -> F) -> Result { match *res { Ok(copy t) => Ok(t), @@ -229,53 +229,53 @@ pub pure fn map_err(res: &Result, op: &fn(&E) -> F) pub impl Result { #[inline(always)] - pure fn get_ref(&self) -> &'self T { get_ref(self) } + fn get_ref(&self) -> &'self T { get_ref(self) } #[inline(always)] - pure fn is_ok(&self) -> bool { is_ok(self) } + fn is_ok(&self) -> bool { is_ok(self) } #[inline(always)] - pure fn is_err(&self) -> bool { is_err(self) } + fn is_err(&self) -> bool { is_err(self) } #[inline(always)] - pure fn iter(&self, f: &fn(&T)) { iter(self, f) } + fn iter(&self, f: &fn(&T)) { iter(self, f) } #[inline(always)] - pure fn iter_err(&self, f: &fn(&E)) { iter_err(self, f) } + fn iter_err(&self, f: &fn(&E)) { iter_err(self, f) } #[inline(always)] - pure fn unwrap(self) -> T { unwrap(self) } + fn unwrap(self) -> T { unwrap(self) } #[inline(always)] - pure fn unwrap_err(self) -> E { unwrap_err(self) } + fn unwrap_err(self) -> E { unwrap_err(self) } #[inline(always)] - pure fn chain(self, op: &fn(T) -> Result) -> Result { + fn chain(self, op: &fn(T) -> Result) -> Result { chain(self, op) } #[inline(always)] - pure fn chain_err(self, op: &fn(E) -> Result) -> Result { + fn chain_err(self, op: &fn(E) -> Result) -> Result { chain_err(self, op) } } pub impl Result { #[inline(always)] - pure fn get(&self) -> T { get(self) } + fn get(&self) -> T { get(self) } #[inline(always)] - pure fn map_err(&self, op: &fn(&E) -> F) -> Result { + fn map_err(&self, op: &fn(&E) -> F) -> Result { map_err(self, op) } } pub impl Result { #[inline(always)] - pure fn get_err(&self) -> E { get_err(self) } + fn get_err(&self) -> E { get_err(self) } #[inline(always)] - pure fn map(&self, op: &fn(&T) -> U) -> Result { + fn map(&self, op: &fn(&T) -> U) -> Result { map(self, op) } } @@ -375,7 +375,7 @@ pub fn iter_vec2(ss: &[S], ts: &[T], /// Unwraps a result, assuming it is an `ok(T)` #[inline(always)] -pub pure fn unwrap(res: Result) -> T { +pub fn unwrap(res: Result) -> T { match res { Ok(t) => t, Err(_) => fail!(~"unwrap called on an err result") @@ -384,7 +384,7 @@ pub pure fn unwrap(res: Result) -> T { /// Unwraps a result, assuming it is an `err(U)` #[inline(always)] -pub pure fn unwrap_err(res: Result) -> U { +pub fn unwrap_err(res: Result) -> U { match res { Err(u) => u, Ok(_) => fail!(~"unwrap called on an ok result") diff --git a/src/libcore/rt/context.rs b/src/libcore/rt/context.rs index 8da80f7a4e8..4150366dacf 100644 --- a/src/libcore/rt/context.rs +++ b/src/libcore/rt/context.rs @@ -184,7 +184,7 @@ fn align_down(sp: *mut uint) -> *mut uint { // XXX: ptr::offset is positive ints only #[inline(always)] -pub pure fn mut_offset(ptr: *mut T, count: int) -> *mut T { +pub fn mut_offset(ptr: *mut T, count: int) -> *mut T { use core::sys::size_of; unsafe { (ptr as int + count * (size_of::() as int)) as *mut T diff --git a/src/libcore/rt/uv.rs b/src/libcore/rt/uv.rs index 251f2a4a12b..4d87bdb02e8 100644 --- a/src/libcore/rt/uv.rs +++ b/src/libcore/rt/uv.rs @@ -518,7 +518,7 @@ struct UvError(uvll::uv_err_t); impl UvError { - pure fn name(&self) -> ~str { + fn name(&self) -> ~str { unsafe { let inner = match self { &UvError(ref a) => a }; let name_str = uvll::err_name(inner); @@ -527,7 +527,7 @@ impl UvError { } } - pure fn desc(&self) -> ~str { + fn desc(&self) -> ~str { unsafe { let inner = match self { &UvError(ref a) => a }; let desc_str = uvll::strerror(inner); @@ -538,7 +538,7 @@ impl UvError { } impl ToStr for UvError { - pure fn to_str(&self) -> ~str { + fn to_str(&self) -> ~str { fmt!("%s: %s", self.name(), self.desc()) } } diff --git a/src/libcore/str.rs b/src/libcore/str.rs index 4cfdfabb0e7..d9202f4c61c 100644 --- a/src/libcore/str.rs +++ b/src/libcore/str.rs @@ -44,27 +44,27 @@ Section: Creating a string * * Fails if invalid UTF-8 */ -pub pure fn from_bytes(vv: &[const u8]) -> ~str { +pub fn from_bytes(vv: &[const u8]) -> ~str { fail_unless!(is_utf8(vv)); return unsafe { raw::from_bytes(vv) }; } /// Copy a slice into a new unique str -pub pure fn from_slice(s: &str) -> ~str { +pub fn from_slice(s: &str) -> ~str { unsafe { raw::slice_bytes_unique(s, 0, len(s)) } } impl ToStr for ~str { #[inline(always)] - pure fn to_str(&self) -> ~str { copy *self } + fn to_str(&self) -> ~str { copy *self } } impl ToStr for &'self str { #[inline(always)] - pure fn to_str(&self) -> ~str { ::str::from_slice(*self) } + fn to_str(&self) -> ~str { ::str::from_slice(*self) } } impl ToStr for @str { #[inline(always)] - pure fn to_str(&self) -> ~str { ::str::from_slice(*self) } + fn to_str(&self) -> ~str { ::str::from_slice(*self) } } /** @@ -74,7 +74,7 @@ impl ToStr for @str { * * Fails if invalid UTF-8 */ -pub pure fn from_byte(b: u8) -> ~str { +pub fn from_byte(b: u8) -> ~str { fail_unless!(b < 128u8); unsafe { ::cast::transmute(~[b, 0u8]) } } @@ -151,14 +151,14 @@ pub fn push_char(s: &mut ~str, ch: char) { } /// Convert a char to a string -pub pure fn from_char(ch: char) -> ~str { +pub fn from_char(ch: char) -> ~str { let mut buf = ~""; unsafe { push_char(&mut buf, ch); } buf } /// Convert a vector of chars to a string -pub pure fn from_chars(chs: &[char]) -> ~str { +pub fn from_chars(chs: &[char]) -> ~str { let mut buf = ~""; unsafe { reserve(&mut buf, chs.len()); @@ -206,7 +206,7 @@ pub fn push_str(lhs: &mut ~str, rhs: &str) { /// Concatenate two strings together #[inline(always)] -pub pure fn append(lhs: ~str, rhs: &str) -> ~str { +pub fn append(lhs: ~str, rhs: &str) -> ~str { let mut v = lhs; unsafe { push_str_no_overallocate(&mut v, rhs); @@ -216,7 +216,7 @@ pub pure fn append(lhs: ~str, rhs: &str) -> ~str { /// Concatenate a vector of strings -pub pure fn concat(v: &[~str]) -> ~str { +pub fn concat(v: &[~str]) -> ~str { let mut s: ~str = ~""; for vec::each(v) |ss| { unsafe { push_str(&mut s, *ss) }; @@ -225,7 +225,7 @@ pub pure fn concat(v: &[~str]) -> ~str { } /// Concatenate a vector of strings, placing a given separator between each -pub pure fn connect(v: &[~str], sep: &str) -> ~str { +pub fn connect(v: &[~str], sep: &str) -> ~str { let mut s = ~"", first = true; for vec::each(v) |ss| { if first { first = false; } else { unsafe { push_str(&mut s, sep); } } @@ -235,7 +235,7 @@ pub pure fn connect(v: &[~str], sep: &str) -> ~str { } /// Concatenate a vector of strings, placing a given separator between each -pub pure fn connect_slices(v: &[&str], sep: &str) -> ~str { +pub fn connect_slices(v: &[&str], sep: &str) -> ~str { let mut s = ~"", first = true; for vec::each(v) |ss| { if first { first = false; } else { unsafe { push_str(&mut s, sep); } } @@ -245,7 +245,7 @@ pub pure fn connect_slices(v: &[&str], sep: &str) -> ~str { } /// Given a string, make a new string with repeated copies of it -pub pure fn repeat(ss: &str, nn: uint) -> ~str { +pub fn repeat(ss: &str, nn: uint) -> ~str { let mut acc = ~""; for nn.times { acc += ss; } acc @@ -313,7 +313,7 @@ pub fn unshift_char(s: &mut ~str, ch: char) { * * chars_to_trim - A vector of chars * */ -pub pure fn trim_left_chars(s: &'a str, chars_to_trim: &[char]) -> &'a str { +pub fn trim_left_chars(s: &'a str, chars_to_trim: &[char]) -> &'a str { if chars_to_trim.is_empty() { return s; } match find(s, |c| !chars_to_trim.contains(&c)) { @@ -331,7 +331,7 @@ pub pure fn trim_left_chars(s: &'a str, chars_to_trim: &[char]) -> &'a str { * * chars_to_trim - A vector of chars * */ -pub pure fn trim_right_chars(s: &'a str, chars_to_trim: &[char]) -> &'a str { +pub fn trim_right_chars(s: &'a str, chars_to_trim: &[char]) -> &'a str { if chars_to_trim.is_empty() { return s; } match rfind(s, |c| !chars_to_trim.contains(&c)) { @@ -352,12 +352,12 @@ pub pure fn trim_right_chars(s: &'a str, chars_to_trim: &[char]) -> &'a str { * * chars_to_trim - A vector of chars * */ -pub pure fn trim_chars(s: &'a str, chars_to_trim: &[char]) -> &'a str { +pub fn trim_chars(s: &'a str, chars_to_trim: &[char]) -> &'a str { trim_left_chars(trim_right_chars(s, chars_to_trim), chars_to_trim) } /// Returns a string with leading whitespace removed -pub pure fn trim_left(s: &'a str) -> &'a str { +pub fn trim_left(s: &'a str) -> &'a str { match find(s, |c| !char::is_whitespace(c)) { None => "", Some(first) => unsafe { raw::slice_bytes(s, first, len(s)) } @@ -365,7 +365,7 @@ pub pure fn trim_left(s: &'a str) -> &'a str { } /// Returns a string with trailing whitespace removed -pub pure fn trim_right(s: &'a str) -> &'a str { +pub fn trim_right(s: &'a str) -> &'a str { match rfind(s, |c| !char::is_whitespace(c)) { None => "", Some(last) => { @@ -376,7 +376,7 @@ pub pure fn trim_right(s: &'a str) -> &'a str { } /// Returns a string with leading and trailing whitespace removed -pub pure fn trim(s: &'a str) -> &'a str { trim_left(trim_right(s)) } +pub fn trim(s: &'a str) -> &'a str { trim_left(trim_right(s)) } /* Section: Transforming strings @@ -387,7 +387,7 @@ Section: Transforming strings * * The result vector is not null-terminated. */ -pub pure fn to_bytes(s: &str) -> ~[u8] { +pub fn to_bytes(s: &str) -> ~[u8] { unsafe { let mut v: ~[u8] = ::cast::transmute(from_slice(s)); vec::raw::set_len(&mut v, len(s)); @@ -397,14 +397,14 @@ pub pure fn to_bytes(s: &str) -> ~[u8] { /// Work with the string as a byte slice, not including trailing null. #[inline(always)] -pub pure fn byte_slice(s: &str, f: &fn(v: &[u8]) -> T) -> T { +pub fn byte_slice(s: &str, f: &fn(v: &[u8]) -> T) -> T { do as_buf(s) |p,n| { unsafe { vec::raw::buf_as_slice(p, n-1u, f) } } } /// Convert a string to a vector of characters -pub pure fn chars(s: &str) -> ~[char] { +pub fn chars(s: &str) -> ~[char] { let mut buf = ~[], i = 0; let len = len(s); while i < len { @@ -421,7 +421,7 @@ pub pure fn chars(s: &str) -> ~[char] { * Returns a string containing `n` characters starting at byte offset * `begin`. */ -pub pure fn substr(s: &'a str, begin: uint, n: uint) -> &'a str { +pub fn substr(s: &'a str, begin: uint, n: uint) -> &'a str { slice(s, begin, begin + count_bytes(s, begin, n)) } @@ -431,7 +431,7 @@ pub pure fn substr(s: &'a str, begin: uint, n: uint) -> &'a str { * Fails when `begin` and `end` do not point to valid characters or beyond * the last character of the string */ -pub pure fn slice(s: &'a str, begin: uint, end: uint) -> &'a str { +pub fn slice(s: &'a str, begin: uint, end: uint) -> &'a str { fail_unless!(is_char_boundary(s, begin)); fail_unless!(is_char_boundary(s, end)); unsafe { raw::slice_bytes(s, begin, end) } @@ -439,7 +439,7 @@ pub pure fn slice(s: &'a str, begin: uint, end: uint) -> &'a str { /// Splits a string into substrings at each occurrence of a given /// character. -pub pure fn split_char(s: &str, sep: char) -> ~[~str] { +pub fn split_char(s: &str, sep: char) -> ~[~str] { split_char_inner(s, sep, len(s), true, true) } @@ -449,12 +449,12 @@ pub pure fn split_char(s: &str, sep: char) -> ~[~str] { * * The byte must be a valid UTF-8/ASCII byte */ -pub pure fn splitn_char(s: &str, sep: char, count: uint) -> ~[~str] { +pub fn splitn_char(s: &str, sep: char, count: uint) -> ~[~str] { split_char_inner(s, sep, count, true, true) } /// Like `split_char`, but omits empty strings from the returned vector -pub pure fn split_char_nonempty(s: &str, sep: char) -> ~[~str] { +pub fn split_char_nonempty(s: &str, sep: char) -> ~[~str] { split_char_inner(s, sep, len(s), false, false) } @@ -462,12 +462,12 @@ pub pure fn split_char_nonempty(s: &str, sep: char) -> ~[~str] { * Like `split_char`, but a trailing empty string is omitted * (e.g. `split_char_no_trailing("A B ",' ') == ~[~"A",~"B"]`) */ -pub pure fn split_char_no_trailing(s: &str, sep: char) -> ~[~str] { +pub fn split_char_no_trailing(s: &str, sep: char) -> ~[~str] { split_char_inner(s, sep, len(s), true, false) } -pure fn split_char_inner(s: &str, sep: char, count: uint, allow_empty: bool, - allow_trailing_empty: bool) -> ~[~str] { +fn split_char_inner(s: &str, sep: char, count: uint, allow_empty: bool, + allow_trailing_empty: bool) -> ~[~str] { if sep < 128u as char { let b = sep as u8, l = len(s); let mut result = ~[], done = 0u; @@ -496,7 +496,7 @@ pure fn split_char_inner(s: &str, sep: char, count: uint, allow_empty: bool, /// Splits a string into substrings using a character function -pub pure fn split(s: &str, sepfn: &fn(char) -> bool) -> ~[~str] { +pub fn split(s: &str, sepfn: &fn(char) -> bool) -> ~[~str] { split_inner(s, sepfn, len(s), true, true) } @@ -504,7 +504,7 @@ pub pure fn split(s: &str, sepfn: &fn(char) -> bool) -> ~[~str] { * Splits a string into substrings using a character function, cutting at * most `count` times. */ -pub pure fn splitn(s: &str, +pub fn splitn(s: &str, sepfn: &fn(char) -> bool, count: uint) -> ~[~str] { @@ -512,7 +512,7 @@ pub pure fn splitn(s: &str, } /// Like `split`, but omits empty strings from the returned vector -pub pure fn split_nonempty(s: &str, sepfn: &fn(char) -> bool) -> ~[~str] { +pub fn split_nonempty(s: &str, sepfn: &fn(char) -> bool) -> ~[~str] { split_inner(s, sepfn, len(s), false, false) } @@ -521,7 +521,7 @@ pub pure fn split_nonempty(s: &str, sepfn: &fn(char) -> bool) -> ~[~str] { * Like `split`, but a trailing empty string is omitted * (e.g. `split_no_trailing("A B ",' ') == ~[~"A",~"B"]`) */ -pub pure fn split_no_trailing(s: &str, sepfn: &fn(char) -> bool) -> ~[~str] { +pub fn split_no_trailing(s: &str, sepfn: &fn(char) -> bool) -> ~[~str] { split_inner(s, sepfn, len(s), true, false) } @@ -551,7 +551,7 @@ pure fn split_inner(s: &str, sepfn: &fn(cc: char) -> bool, count: uint, } // See Issue #1932 for why this is a naive search -pure fn iter_matches(s: &'a str, sep: &'b str, f: &fn(uint, uint)) { +fn iter_matches(s: &'a str, sep: &'b str, f: &fn(uint, uint)) { let sep_len = len(sep), l = len(s); fail_unless!(sep_len > 0u); let mut i = 0u, match_start = 0u, match_i = 0u; @@ -578,7 +578,7 @@ pure fn iter_matches(s: &'a str, sep: &'b str, f: &fn(uint, uint)) { } } -pure fn iter_between_matches(s: &'a str, sep: &'b str, f: &fn(uint, uint)) { +fn iter_between_matches(s: &'a str, sep: &'b str, f: &fn(uint, uint)) { let mut last_end = 0u; do iter_matches(s, sep) |from, to| { f(last_end, from); @@ -596,7 +596,7 @@ pure fn iter_between_matches(s: &'a str, sep: &'b str, f: &fn(uint, uint)) { * fail_unless!(["", "XXX", "YYY", ""] == split_str(".XXX.YYY.", ".")) * ~~~ */ -pub pure fn split_str(s: &'a str, sep: &'b str) -> ~[~str] { +pub fn split_str(s: &'a str, sep: &'b str) -> ~[~str] { let mut result = ~[]; do iter_between_matches(s, sep) |from, to| { unsafe { result.push(raw::slice_bytes_unique(s, from, to)); } @@ -604,7 +604,7 @@ pub pure fn split_str(s: &'a str, sep: &'b str) -> ~[~str] { result } -pub pure fn split_str_nonempty(s: &'a str, sep: &'b str) -> ~[~str] { +pub fn split_str_nonempty(s: &'a str, sep: &'b str) -> ~[~str] { let mut result = ~[]; do iter_between_matches(s, sep) |from, to| { if to > from { @@ -651,7 +651,7 @@ pub fn levdistance(s: &str, t: &str) -> uint { /** * Splits a string into a vector of the substrings separated by LF ('\n'). */ -pub pure fn lines(s: &str) -> ~[~str] { +pub fn lines(s: &str) -> ~[~str] { split_char_no_trailing(s, '\n') } @@ -659,7 +659,7 @@ pub pure fn lines(s: &str) -> ~[~str] { * Splits a string into a vector of the substrings separated by LF ('\n') * and/or CR LF ("\r\n") */ -pub pure fn lines_any(s: &str) -> ~[~str] { +pub fn lines_any(s: &str) -> ~[~str] { vec::map(lines(s), |s| { let l = len(*s); let mut cp = copy *s; @@ -671,7 +671,7 @@ pub pure fn lines_any(s: &str) -> ~[~str] { } /// Splits a string into a vector of the substrings separated by whitespace -pub pure fn words(s: &str) -> ~[~str] { +pub fn words(s: &str) -> ~[~str] { split_nonempty(s, char::is_whitespace) } @@ -710,14 +710,14 @@ pub fn split_within(ss: &str, lim: uint) -> ~[~str] { /// Convert a string to lowercase. ASCII only -pub pure fn to_lower(s: &str) -> ~str { +pub fn to_lower(s: &str) -> ~str { map(s, |c| unsafe{(libc::tolower(c as libc::c_char)) as char} ) } /// Convert a string to uppercase. ASCII only -pub pure fn to_upper(s: &str) -> ~str { +pub fn to_upper(s: &str) -> ~str { map(s, |c| unsafe{(libc::toupper(c as libc::c_char)) as char} ) @@ -736,7 +736,7 @@ pub pure fn to_upper(s: &str) -> ~str { * * The original string with all occurances of `from` replaced with `to` */ -pub pure fn replace(s: &str, from: &str, to: &str) -> ~str { +pub fn replace(s: &str, from: &str, to: &str) -> ~str { let mut result = ~"", first = true; do iter_between_matches(s, from) |start, end| { if first { @@ -756,7 +756,7 @@ Section: Comparing strings /// Bytewise slice equality #[cfg(notest)] #[lang="str_eq"] -pub pure fn eq_slice(a: &str, b: &str) -> bool { +pub fn eq_slice(a: &str, b: &str) -> bool { do as_buf(a) |ap, alen| { do as_buf(b) |bp, blen| { if (alen != blen) { false } @@ -772,7 +772,7 @@ pub pure fn eq_slice(a: &str, b: &str) -> bool { } #[cfg(test)] -pub pure fn eq_slice(a: &str, b: &str) -> bool { +pub fn eq_slice(a: &str, b: &str) -> bool { do as_buf(a) |ap, alen| { do as_buf(b) |bp, blen| { if (alen != blen) { false } @@ -790,16 +790,16 @@ pub pure fn eq_slice(a: &str, b: &str) -> bool { /// Bytewise string equality #[cfg(notest)] #[lang="uniq_str_eq"] -pub pure fn eq(a: &~str, b: &~str) -> bool { +pub fn eq(a: &~str, b: &~str) -> bool { eq_slice(*a, *b) } #[cfg(test)] -pub pure fn eq(a: &~str, b: &~str) -> bool { +pub fn eq(a: &~str, b: &~str) -> bool { eq_slice(*a, *b) } -pure fn cmp(a: &str, b: &str) -> Ordering { +fn cmp(a: &str, b: &str) -> Ordering { let low = uint::min(a.len(), b.len()); for uint::range(0, low) |idx| { @@ -815,21 +815,21 @@ pure fn cmp(a: &str, b: &str) -> Ordering { #[cfg(notest)] impl TotalOrd for &'self str { - pure fn cmp(&self, other: & &'self str) -> Ordering { cmp(*self, *other) } + fn cmp(&self, other: & &'self str) -> Ordering { cmp(*self, *other) } } #[cfg(notest)] impl TotalOrd for ~str { - pure fn cmp(&self, other: &~str) -> Ordering { cmp(*self, *other) } + fn cmp(&self, other: &~str) -> Ordering { cmp(*self, *other) } } #[cfg(notest)] impl TotalOrd for @str { - pure fn cmp(&self, other: &@str) -> Ordering { cmp(*self, *other) } + fn cmp(&self, other: &@str) -> Ordering { cmp(*self, *other) } } /// Bytewise slice less than -pure fn lt(a: &str, b: &str) -> bool { +fn lt(a: &str, b: &str) -> bool { let (a_len, b_len) = (a.len(), b.len()); let mut end = uint::min(a_len, b_len); @@ -845,90 +845,90 @@ pure fn lt(a: &str, b: &str) -> bool { } /// Bytewise less than or equal -pub pure fn le(a: &str, b: &str) -> bool { +pub fn le(a: &str, b: &str) -> bool { !lt(b, a) } /// Bytewise greater than or equal -pure fn ge(a: &str, b: &str) -> bool { +fn ge(a: &str, b: &str) -> bool { !lt(a, b) } /// Bytewise greater than -pure fn gt(a: &str, b: &str) -> bool { +fn gt(a: &str, b: &str) -> bool { !le(a, b) } #[cfg(notest)] impl Eq for &'self str { #[inline(always)] - pure fn eq(&self, other: & &'self str) -> bool { + fn eq(&self, other: & &'self str) -> bool { eq_slice((*self), (*other)) } #[inline(always)] - pure fn ne(&self, other: & &'self str) -> bool { !(*self).eq(other) } + fn ne(&self, other: & &'self str) -> bool { !(*self).eq(other) } } #[cfg(notest)] impl Eq for ~str { #[inline(always)] - pure fn eq(&self, other: &~str) -> bool { + fn eq(&self, other: &~str) -> bool { eq_slice((*self), (*other)) } #[inline(always)] - pure fn ne(&self, other: &~str) -> bool { !(*self).eq(other) } + fn ne(&self, other: &~str) -> bool { !(*self).eq(other) } } #[cfg(notest)] impl Eq for @str { #[inline(always)] - pure fn eq(&self, other: &@str) -> bool { + fn eq(&self, other: &@str) -> bool { eq_slice((*self), (*other)) } #[inline(always)] - pure fn ne(&self, other: &@str) -> bool { !(*self).eq(other) } + fn ne(&self, other: &@str) -> bool { !(*self).eq(other) } } #[cfg(notest)] impl Ord for ~str { #[inline(always)] - pure fn lt(&self, other: &~str) -> bool { lt((*self), (*other)) } + fn lt(&self, other: &~str) -> bool { lt((*self), (*other)) } #[inline(always)] - pure fn le(&self, other: &~str) -> bool { le((*self), (*other)) } + fn le(&self, other: &~str) -> bool { le((*self), (*other)) } #[inline(always)] - pure fn ge(&self, other: &~str) -> bool { ge((*self), (*other)) } + fn ge(&self, other: &~str) -> bool { ge((*self), (*other)) } #[inline(always)] - pure fn gt(&self, other: &~str) -> bool { gt((*self), (*other)) } + fn gt(&self, other: &~str) -> bool { gt((*self), (*other)) } } #[cfg(notest)] impl Ord for &'self str { #[inline(always)] - pure fn lt(&self, other: & &'self str) -> bool { lt((*self), (*other)) } + fn lt(&self, other: & &'self str) -> bool { lt((*self), (*other)) } #[inline(always)] - pure fn le(&self, other: & &'self str) -> bool { le((*self), (*other)) } + fn le(&self, other: & &'self str) -> bool { le((*self), (*other)) } #[inline(always)] - pure fn ge(&self, other: & &'self str) -> bool { ge((*self), (*other)) } + fn ge(&self, other: & &'self str) -> bool { ge((*self), (*other)) } #[inline(always)] - pure fn gt(&self, other: & &'self str) -> bool { gt((*self), (*other)) } + fn gt(&self, other: & &'self str) -> bool { gt((*self), (*other)) } } #[cfg(notest)] impl Ord for @str { #[inline(always)] - pure fn lt(&self, other: &@str) -> bool { lt((*self), (*other)) } + fn lt(&self, other: &@str) -> bool { lt((*self), (*other)) } #[inline(always)] - pure fn le(&self, other: &@str) -> bool { le((*self), (*other)) } + fn le(&self, other: &@str) -> bool { le((*self), (*other)) } #[inline(always)] - pure fn ge(&self, other: &@str) -> bool { ge((*self), (*other)) } + fn ge(&self, other: &@str) -> bool { ge((*self), (*other)) } #[inline(always)] - pure fn gt(&self, other: &@str) -> bool { gt((*self), (*other)) } + fn gt(&self, other: &@str) -> bool { gt((*self), (*other)) } } #[cfg(notest)] impl Equiv<~str> for &'self str { #[inline(always)] - pure fn equiv(&self, other: &~str) -> bool { eq_slice(*self, *other) } + fn equiv(&self, other: &~str) -> bool { eq_slice(*self, *other) } } /* @@ -939,7 +939,7 @@ Section: Iterating through strings * Return true if a predicate matches all characters or if the string * contains no characters */ -pub pure fn all(s: &str, it: &fn(char) -> bool) -> bool { +pub fn all(s: &str, it: &fn(char) -> bool) -> bool { all_between(s, 0u, len(s), it) } @@ -947,12 +947,12 @@ pub pure fn all(s: &str, it: &fn(char) -> bool) -> bool { * Return true if a predicate matches any character (and false if it * matches none or there are no characters) */ -pub pure fn any(ss: &str, pred: &fn(char) -> bool) -> bool { +pub fn any(ss: &str, pred: &fn(char) -> bool) -> bool { !all(ss, |cc| !pred(cc)) } /// Apply a function to each character -pub pure fn map(ss: &str, ff: &fn(char) -> char) -> ~str { +pub fn map(ss: &str, ff: &fn(char) -> char) -> ~str { let mut result = ~""; unsafe { reserve(&mut result, len(ss)); @@ -965,13 +965,13 @@ pub pure fn map(ss: &str, ff: &fn(char) -> char) -> ~str { /// Iterate over the bytes in a string #[inline(always)] -pub pure fn each(s: &str, it: &fn(u8) -> bool) { +pub fn each(s: &str, it: &fn(u8) -> bool) { eachi(s, |_i, b| it(b)) } /// Iterate over the bytes in a string, with indices #[inline(always)] -pub pure fn eachi(s: &str, it: &fn(uint, u8) -> bool) { +pub fn eachi(s: &str, it: &fn(uint, u8) -> bool) { let mut pos = 0; let len = s.len(); @@ -983,13 +983,13 @@ pub pure fn eachi(s: &str, it: &fn(uint, u8) -> bool) { /// Iterate over the bytes in a string in reverse #[inline(always)] -pub pure fn each_reverse(s: &str, it: &fn(u8) -> bool) { +pub fn each_reverse(s: &str, it: &fn(u8) -> bool) { eachi_reverse(s, |_i, b| it(b) ) } /// Iterate over the bytes in a string in reverse, with indices #[inline(always)] -pub pure fn eachi_reverse(s: &str, it: &fn(uint, u8) -> bool) { +pub fn eachi_reverse(s: &str, it: &fn(uint, u8) -> bool) { let mut pos = s.len(); while pos > 0 { pos -= 1; @@ -999,13 +999,13 @@ pub pure fn eachi_reverse(s: &str, it: &fn(uint, u8) -> bool) { /// Iterates over the chars in a string #[inline(always)] -pub pure fn each_char(s: &str, it: &fn(char) -> bool) { +pub fn each_char(s: &str, it: &fn(char) -> bool) { each_chari(s, |_i, c| it(c)) } /// Iterates over the chars in a string, with indices #[inline(always)] -pub pure fn each_chari(s: &str, it: &fn(uint, char) -> bool) { +pub fn each_chari(s: &str, it: &fn(uint, char) -> bool) { let mut pos = 0; let mut ch_pos = 0u; let len = s.len(); @@ -1019,7 +1019,7 @@ pub pure fn each_chari(s: &str, it: &fn(uint, char) -> bool) { /// Iterates over the chars in a string in reverse #[inline(always)] -pub pure fn each_char_reverse(s: &str, it: &fn(char) -> bool) { +pub fn each_char_reverse(s: &str, it: &fn(char) -> bool) { let mut pos = 0; let len = s.char_len(); while pos > 0 { @@ -1031,7 +1031,7 @@ pub pure fn each_char_reverse(s: &str, it: &fn(char) -> bool) { // Iterates over the chars in a string in reverse, with indices #[inline(always)] -pub pure fn each_chari_reverse(s: &str, it: &fn(uint, char) -> bool) { +pub fn each_chari_reverse(s: &str, it: &fn(uint, char) -> bool) { let mut ch_pos = s.char_len(); for s.each_char_reverse |ch| { ch_pos -= 1; @@ -1040,7 +1040,7 @@ pub pure fn each_chari_reverse(s: &str, it: &fn(uint, char) -> bool) { } /// Apply a function to each substring after splitting by character -pub pure fn split_char_each(ss: &str, cc: char, ff: &fn(v: &str) -> bool) { +pub fn split_char_each(ss: &str, cc: char, ff: &fn(v: &str) -> bool) { vec::each(split_char(ss, cc), |s| ff(*s)) } @@ -1048,20 +1048,20 @@ pub pure fn split_char_each(ss: &str, cc: char, ff: &fn(v: &str) -> bool) { * Apply a function to each substring after splitting by character, up to * `count` times */ -pub pure fn splitn_char_each(ss: &str, sep: char, count: uint, +pub fn splitn_char_each(ss: &str, sep: char, count: uint, ff: &fn(v: &str) -> bool) { vec::each(splitn_char(ss, sep, count), |s| ff(*s)) } /// Apply a function to each word -pub pure fn words_each(ss: &str, ff: &fn(v: &str) -> bool) { +pub fn words_each(ss: &str, ff: &fn(v: &str) -> bool) { vec::each(words(ss), |s| ff(*s)) } /** * Apply a function to each line (by '\n') */ -pub pure fn lines_each(ss: &str, ff: &fn(v: &str) -> bool) { +pub fn lines_each(ss: &str, ff: &fn(v: &str) -> bool) { vec::each(lines(ss), |s| ff(*s)) } @@ -1082,7 +1082,7 @@ Section: Searching * An `option` containing the byte index of the first matching character * or `none` if there is no match */ -pub pure fn find_char(s: &str, c: char) -> Option { +pub fn find_char(s: &str, c: char) -> Option { find_char_between(s, c, 0u, len(s)) } @@ -1106,7 +1106,7 @@ pub pure fn find_char(s: &str, c: char) -> Option { * `start` must be less than or equal to `len(s)`. `start` must be the * index of a character boundary, as defined by `is_char_boundary`. */ -pub pure fn find_char_from(s: &str, c: char, start: uint) -> Option { +pub fn find_char_from(s: &str, c: char, start: uint) -> Option { find_char_between(s, c, start, len(s)) } @@ -1131,7 +1131,7 @@ pub pure fn find_char_from(s: &str, c: char, start: uint) -> Option { * or equal to `len(s)`. `start` must be the index of a character boundary, * as defined by `is_char_boundary`. */ -pub pure fn find_char_between(s: &str, c: char, start: uint, end: uint) +pub fn find_char_between(s: &str, c: char, start: uint, end: uint) -> Option { if c < 128u as char { fail_unless!(start <= end); @@ -1161,7 +1161,7 @@ pub pure fn find_char_between(s: &str, c: char, start: uint, end: uint) * An `option` containing the byte index of the last matching character * or `none` if there is no match */ -pub pure fn rfind_char(s: &str, c: char) -> Option { +pub fn rfind_char(s: &str, c: char) -> Option { rfind_char_between(s, c, len(s), 0u) } @@ -1185,7 +1185,7 @@ pub pure fn rfind_char(s: &str, c: char) -> Option { * `start` must be less than or equal to `len(s)`. `start` must be * the index of a character boundary, as defined by `is_char_boundary`. */ -pub pure fn rfind_char_from(s: &str, c: char, start: uint) -> Option { +pub fn rfind_char_from(s: &str, c: char, start: uint) -> Option { rfind_char_between(s, c, start, 0u) } @@ -1210,7 +1210,7 @@ pub pure fn rfind_char_from(s: &str, c: char, start: uint) -> Option { * or equal to `len(s)`. `start` must be the index of a character boundary, * as defined by `is_char_boundary`. */ -pub pure fn rfind_char_between(s: &str, c: char, start: uint, end: uint) +pub fn rfind_char_between(s: &str, c: char, start: uint, end: uint) -> Option { if c < 128u as char { fail_unless!(start >= end); @@ -1241,7 +1241,7 @@ pub pure fn rfind_char_between(s: &str, c: char, start: uint, end: uint) * An `option` containing the byte index of the first matching character * or `none` if there is no match */ -pub pure fn find(s: &str, f: &fn(char) -> bool) -> Option { +pub fn find(s: &str, f: &fn(char) -> bool) -> Option { find_between(s, 0u, len(s), f) } @@ -1265,7 +1265,7 @@ pub pure fn find(s: &str, f: &fn(char) -> bool) -> Option { * `start` must be less than or equal to `len(s)`. `start` must be the * index of a character boundary, as defined by `is_char_boundary`. */ -pub pure fn find_from(s: &str, start: uint, f: &fn(char) +pub fn find_from(s: &str, start: uint, f: &fn(char) -> bool) -> Option { find_between(s, start, len(s), f) } @@ -1292,7 +1292,7 @@ pub pure fn find_from(s: &str, start: uint, f: &fn(char) * or equal to `len(s)`. `start` must be the index of a character * boundary, as defined by `is_char_boundary`. */ -pub pure fn find_between(s: &str, +pub fn find_between(s: &str, start: uint, end: uint, f: &fn(char) -> bool) @@ -1323,7 +1323,7 @@ pub pure fn find_between(s: &str, * An option containing the byte index of the last matching character * or `none` if there is no match */ -pub pure fn rfind(s: &str, f: &fn(char) -> bool) -> Option { +pub fn rfind(s: &str, f: &fn(char) -> bool) -> Option { rfind_between(s, len(s), 0u, f) } @@ -1347,7 +1347,7 @@ pub pure fn rfind(s: &str, f: &fn(char) -> bool) -> Option { * `start` must be less than or equal to `len(s)', `start` must be the * index of a character boundary, as defined by `is_char_boundary` */ -pub pure fn rfind_from(s: &str, start: uint, f: &fn(char) -> bool) +pub fn rfind_from(s: &str, start: uint, f: &fn(char) -> bool) -> Option { rfind_between(s, start, 0u, f) } @@ -1374,7 +1374,7 @@ pub pure fn rfind_from(s: &str, start: uint, f: &fn(char) -> bool) * than or equal to `len(s)`. `start` must be the index of a character * boundary, as defined by `is_char_boundary` */ -pub pure fn rfind_between(s: &str, start: uint, end: uint, +pub fn rfind_between(s: &str, start: uint, end: uint, f: &fn(char) -> bool) -> Option { fail_unless!(start >= end); @@ -1390,7 +1390,7 @@ pub pure fn rfind_between(s: &str, start: uint, end: uint, } // Utility used by various searching functions -pure fn match_at(haystack: &'a str, needle: &'b str, at: uint) -> bool { +fn match_at(haystack: &'a str, needle: &'b str, at: uint) -> bool { let mut i = at; for each(needle) |c| { if haystack[i] != c { return false; } i += 1u; } return true; @@ -1409,7 +1409,7 @@ pure fn match_at(haystack: &'a str, needle: &'b str, at: uint) -> bool { * An `option` containing the byte index of the first matching substring * or `none` if there is no match */ -pub pure fn find_str(haystack: &'a str, needle: &'b str) -> Option { +pub fn find_str(haystack: &'a str, needle: &'b str) -> Option { find_str_between(haystack, needle, 0u, len(haystack)) } @@ -1432,7 +1432,7 @@ pub pure fn find_str(haystack: &'a str, needle: &'b str) -> Option { * * `start` must be less than or equal to `len(s)` */ -pub pure fn find_str_from(haystack: &'a str, needle: &'b str, start: uint) +pub fn find_str_from(haystack: &'a str, needle: &'b str, start: uint) -> Option { find_str_between(haystack, needle, start, len(haystack)) } @@ -1457,7 +1457,7 @@ pub pure fn find_str_from(haystack: &'a str, needle: &'b str, start: uint) * `start` must be less than or equal to `end` and `end` must be less than * or equal to `len(s)`. */ -pub pure fn find_str_between(haystack: &'a str, needle: &'b str, start: uint, +pub fn find_str_between(haystack: &'a str, needle: &'b str, start: uint, end:uint) -> Option { // See Issue #1932 for why this is a naive search @@ -1483,7 +1483,7 @@ pub pure fn find_str_between(haystack: &'a str, needle: &'b str, start: uint, * * haystack - The string to look in * * needle - The string to look for */ -pub pure fn contains(haystack: &'a str, needle: &'b str) -> bool { +pub fn contains(haystack: &'a str, needle: &'b str) -> bool { find_str(haystack, needle).is_some() } @@ -1495,7 +1495,7 @@ pub pure fn contains(haystack: &'a str, needle: &'b str) -> bool { * * haystack - The string to look in * * needle - The char to look for */ -pub pure fn contains_char(haystack: &str, needle: char) -> bool { +pub fn contains_char(haystack: &str, needle: char) -> bool { find_char(haystack, needle).is_some() } @@ -1507,7 +1507,7 @@ pub pure fn contains_char(haystack: &str, needle: char) -> bool { * * haystack - The string to look in * * needle - The string to look for */ -pub pure fn starts_with(haystack: &'a str, needle: &'b str) -> bool { +pub fn starts_with(haystack: &'a str, needle: &'b str) -> bool { let haystack_len = len(haystack), needle_len = len(needle); if needle_len == 0u { true } else if needle_len > haystack_len { false } @@ -1522,7 +1522,7 @@ pub pure fn starts_with(haystack: &'a str, needle: &'b str) -> bool { * * haystack - The string to look in * * needle - The string to look for */ -pub pure fn ends_with(haystack: &'a str, needle: &'b str) -> bool { +pub fn ends_with(haystack: &'a str, needle: &'b str) -> bool { let haystack_len = len(haystack), needle_len = len(needle); if needle_len == 0u { true } else if needle_len > haystack_len { false } @@ -1534,21 +1534,21 @@ Section: String properties */ /// Determines if a string contains only ASCII characters -pub pure fn is_ascii(s: &str) -> bool { +pub fn is_ascii(s: &str) -> bool { let mut i: uint = len(s); while i > 0u { i -= 1u; if !u8::is_ascii(s[i]) { return false; } } return true; } /// Returns true if the string has length 0 -pub pure fn is_empty(s: &str) -> bool { len(s) == 0u } +pub fn is_empty(s: &str) -> bool { len(s) == 0u } /** * Returns true if the string contains only whitespace * * Whitespace characters are determined by `char::is_whitespace` */ -pub pure fn is_whitespace(s: &str) -> bool { +pub fn is_whitespace(s: &str) -> bool { return all(s, char::is_whitespace); } @@ -1557,24 +1557,24 @@ pub pure fn is_whitespace(s: &str) -> bool { * * Alphanumeric characters are determined by `char::is_alphanumeric` */ -pure fn is_alphanumeric(s: &str) -> bool { +fn is_alphanumeric(s: &str) -> bool { return all(s, char::is_alphanumeric); } /// Returns the string length/size in bytes not counting the null terminator -pub pure fn len(s: &str) -> uint { +pub fn len(s: &str) -> uint { do as_buf(s) |_p, n| { n - 1u } } /// Returns the number of characters that a string holds -pub pure fn char_len(s: &str) -> uint { count_chars(s, 0u, len(s)) } +pub fn char_len(s: &str) -> uint { count_chars(s, 0u, len(s)) } /* Section: Misc */ /// Determines if a vector of bytes contains valid UTF-8 -pub pure fn is_utf8(v: &[const u8]) -> bool { +pub fn is_utf8(v: &[const u8]) -> bool { let mut i = 0u; let total = vec::len::(v); while i < total { @@ -1592,7 +1592,7 @@ pub pure fn is_utf8(v: &[const u8]) -> bool { } /// Determines if a vector of `u16` contains valid UTF-16 -pub pure fn is_utf16(v: &[u16]) -> bool { +pub fn is_utf16(v: &[u16]) -> bool { let len = vec::len(v); let mut i = 0u; while (i < len) { @@ -1613,7 +1613,7 @@ pub pure fn is_utf16(v: &[u16]) -> bool { } /// Converts to a vector of `u16` encoded as UTF-16 -pub pure fn to_utf16(s: &str) -> ~[u16] { +pub fn to_utf16(s: &str) -> ~[u16] { let mut u = ~[]; for s.each_char |ch| { // Arithmetic with u32 literals is easier on the eyes than chars. @@ -1638,7 +1638,7 @@ pub pure fn to_utf16(s: &str) -> ~[u16] { u } -pub pure fn utf16_chars(v: &[u16], f: &fn(char)) { +pub fn utf16_chars(v: &[u16], f: &fn(char)) { let len = vec::len(v); let mut i = 0u; while (i < len && v[i] != 0u16) { @@ -1663,7 +1663,7 @@ pub pure fn utf16_chars(v: &[u16], f: &fn(char)) { } -pub pure fn from_utf16(v: &[u16]) -> ~str { +pub fn from_utf16(v: &[u16]) -> ~str { let mut buf = ~""; unsafe { reserve(&mut buf, vec::len(v)); @@ -1672,7 +1672,7 @@ pub pure fn from_utf16(v: &[u16]) -> ~str { buf } -pub pure fn with_capacity(capacity: uint) -> ~str { +pub fn with_capacity(capacity: uint) -> ~str { let mut buf = ~""; unsafe { reserve(&mut buf, capacity); } buf @@ -1691,7 +1691,7 @@ pub pure fn with_capacity(capacity: uint) -> ~str { * * The number of Unicode characters in `s` between the given indices. */ -pub pure fn count_chars(s: &str, start: uint, end: uint) -> uint { +pub fn count_chars(s: &str, start: uint, end: uint) -> uint { fail_unless!(is_char_boundary(s, start)); fail_unless!(is_char_boundary(s, end)); let mut i = start, len = 0u; @@ -1704,7 +1704,7 @@ pub pure fn count_chars(s: &str, start: uint, end: uint) -> uint { } /// Counts the number of bytes taken by the `n` in `s` starting from `start`. -pub pure fn count_bytes(s: &'b str, start: uint, n: uint) -> uint { +pub fn count_bytes(s: &'b str, start: uint, n: uint) -> uint { fail_unless!(is_char_boundary(s, start)); let mut end = start, cnt = n; let l = len(s); @@ -1718,7 +1718,7 @@ pub 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 -pub pure fn utf8_char_width(b: u8) -> uint { +pub fn utf8_char_width(b: u8) -> uint { let byte: uint = b as uint; if byte < 128u { return 1u; } // Not a valid start byte @@ -1734,7 +1734,7 @@ pub pure fn utf8_char_width(b: u8) -> uint { * Returns false if the index points into the middle of a multi-byte * character sequence. */ -pub pure fn is_char_boundary(s: &str, index: uint) -> bool { +pub fn is_char_boundary(s: &str, index: uint) -> bool { if index == len(s) { return true; } let b = s[index]; return b < 128u8 || b >= 192u8; @@ -1789,7 +1789,7 @@ pub pure fn is_char_boundary(s: &str, index: uint) -> bool { * If `i` is greater than or equal to the length of the string. * If `i` is not the index of the beginning of a valid UTF-8 character. */ -pub pure fn char_range_at(s: &str, i: uint) -> CharRange { +pub fn char_range_at(s: &str, i: uint) -> CharRange { let b0 = s[i]; let w = utf8_char_width(b0); fail_unless!((w != 0u)); @@ -1812,7 +1812,7 @@ pub pure fn char_range_at(s: &str, i: uint) -> CharRange { } /// Plucks the `n`th character from the beginning of a string -pub pure fn char_at(s: &str, i: uint) -> char { +pub fn char_at(s: &str, i: uint) -> char { return char_range_at(s, i).ch; } @@ -1826,7 +1826,7 @@ pub struct CharRange { * * This function can be used to iterate over a unicode string in reverse. */ -pure fn char_range_at_reverse(ss: &str, start: uint) -> CharRange { +fn char_range_at_reverse(ss: &str, start: uint) -> CharRange { let mut prev = start; // while there is a previous byte == 10...... @@ -1842,7 +1842,7 @@ pure fn char_range_at_reverse(ss: &str, start: uint) -> CharRange { } /// Plucks the `n`th character from the end of a string -pub pure fn char_at_reverse(s: &str, i: uint) -> char { +pub fn char_at_reverse(s: &str, i: uint) -> char { char_range_at_reverse(s, i).ch } @@ -1868,7 +1868,7 @@ pub pure fn char_at_reverse(s: &str, i: uint) -> char { * `true` If execution proceeded correctly, `false` if it was interrupted, * that is if `it` returned `false` at any point. */ -pub pure fn all_between(s: &str, start: uint, end: uint, +pub fn all_between(s: &str, start: uint, end: uint, it: &fn(char) -> bool) -> bool { fail_unless!(is_char_boundary(s, start)); let mut i = start; @@ -1901,7 +1901,7 @@ pub pure fn all_between(s: &str, start: uint, end: uint, * * `true` if `it` returns `true` for any character */ -pub pure fn any_between(s: &str, start: uint, end: uint, +pub fn any_between(s: &str, start: uint, end: uint, it: &fn(char) -> bool) -> bool { !all_between(s, start, end, |c| !it(c)) } @@ -1940,7 +1940,7 @@ pub const nan_buf: [u8*3] = ['N' as u8, 'a' as u8, 'N' as u8]; * let i = str::as_bytes("Hello World") { |bytes| vec::len(bytes) }; * ~~~ */ -pub pure fn as_bytes(s: &const ~str, f: &fn(&~[u8]) -> T) -> T { +pub fn as_bytes(s: &const ~str, f: &fn(&~[u8]) -> T) -> T { unsafe { let v: *~[u8] = cast::transmute(copy s); f(&*v) @@ -1952,7 +1952,7 @@ pub pure fn as_bytes(s: &const ~str, f: &fn(&~[u8]) -> T) -> T { * * The byte slice does not include the null terminator. */ -pub pure fn as_bytes_slice(s: &'a str) -> &'a [u8] { +pub fn as_bytes_slice(s: &'a str) -> &'a [u8] { unsafe { let (ptr, len): (*u8, uint) = ::cast::reinterpret_cast(&s); let outgoing_tuple: (*u8, uint) = (ptr, len - 1); @@ -1975,7 +1975,7 @@ pub pure fn as_bytes_slice(s: &'a str) -> &'a [u8] { * let s = str::as_c_str("PATH", { |path| libc::getenv(path) }); * ~~~ */ -pub pure fn as_c_str(s: &str, f: &fn(*libc::c_char) -> T) -> T { +pub fn as_c_str(s: &str, f: &fn(*libc::c_char) -> T) -> T { do as_buf(s) |buf, len| { // NB: len includes the trailing null. fail_unless!(len > 0); @@ -1997,7 +1997,7 @@ pub pure fn as_c_str(s: &str, f: &fn(*libc::c_char) -> T) -> T { * to full strings, or suffixes of them. */ #[inline(always)] -pub pure fn as_buf(s: &str, f: &fn(*u8, uint) -> T) -> T { +pub fn as_buf(s: &str, f: &fn(*u8, uint) -> T) -> T { unsafe { let v : *(*u8,uint) = ::cast::reinterpret_cast(&ptr::addr_of(&s)); let (buf,len) = *v; @@ -2056,7 +2056,7 @@ pub fn reserve_at_least(s: &mut ~str, n: uint) { * Returns the number of single-byte characters the string can hold without * reallocating */ -pub pure fn capacity(s: &const ~str) -> uint { +pub fn capacity(s: &const ~str) -> uint { do as_bytes(s) |buf| { let vcap = vec::capacity(buf); fail_unless!(vcap > 0u); @@ -2065,7 +2065,7 @@ pub pure fn capacity(s: &const ~str) -> uint { } /// Escape each char in `s` with char::escape_default. -pub pure fn escape_default(s: &str) -> ~str { +pub fn escape_default(s: &str) -> ~str { let mut out: ~str = ~""; unsafe { reserve_at_least(&mut out, str::len(s)); @@ -2077,7 +2077,7 @@ pub pure fn escape_default(s: &str) -> ~str { } /// Escape each char in `s` with char::escape_unicode. -pub pure fn escape_unicode(s: &str) -> ~str { +pub fn escape_unicode(s: &str) -> ~str { let mut out: ~str = ~""; unsafe { reserve_at_least(&mut out, str::len(s)); @@ -2263,7 +2263,7 @@ pub mod traits { impl Add<&'self str,~str> for ~str { #[inline(always)] - pure fn add(&self, rhs: & &'self str) -> ~str { + fn add(&self, rhs: & &'self str) -> ~str { append(copy *self, (*rhs)) } } @@ -2273,44 +2273,44 @@ pub mod traits { pub mod traits {} pub trait StrSlice { - pure fn all(&self, it: &fn(char) -> bool) -> bool; - pure fn any(&self, it: &fn(char) -> bool) -> bool; - pure fn contains(&self, needle: &'a str) -> bool; - pure fn contains_char(&self, needle: char) -> bool; - pure fn each(&self, it: &fn(u8) -> bool); - pure fn eachi(&self, it: &fn(uint, u8) -> bool); - pure fn each_reverse(&self, it: &fn(u8) -> bool); - pure fn eachi_reverse(&self, it: &fn(uint, u8) -> bool); - pure fn each_char(&self, it: &fn(char) -> bool); - pure fn each_chari(&self, it: &fn(uint, char) -> bool); - pure fn each_char_reverse(&self, it: &fn(char) -> bool); - pure fn each_chari_reverse(&self, it: &fn(uint, char) -> bool); - pure fn ends_with(&self, needle: &str) -> bool; - pure fn is_empty(&self) -> bool; - pure fn is_whitespace(&self) -> bool; - pure fn is_alphanumeric(&self) -> bool; - pure fn len(&self) -> uint; - pure fn char_len(&self) -> uint; - pure fn slice(&self, begin: uint, end: uint) -> &'self str; - pure fn split(&self, sepfn: &fn(char) -> bool) -> ~[~str]; - pure fn split_char(&self, sep: char) -> ~[~str]; - pure fn split_str(&self, sep: &'a str) -> ~[~str]; - pure fn starts_with(&self, needle: &'a str) -> bool; - pure fn substr(&self, begin: uint, n: uint) -> &'self str; - pure fn to_lower(&self) -> ~str; - pure fn to_upper(&self) -> ~str; - pure fn escape_default(&self) -> ~str; - pure fn escape_unicode(&self) -> ~str; - pure fn trim(&self) -> &'self str; - pure fn trim_left(&self) -> &'self str; - pure fn trim_right(&self) -> &'self str; - pure fn trim_chars(&self, chars_to_trim: &[char]) -> &'self str; - pure fn trim_left_chars(&self, chars_to_trim: &[char]) -> &'self str; - pure fn trim_right_chars(&self, chars_to_trim: &[char]) -> &'self str; - pure fn to_owned(&self) -> ~str; - pure fn to_managed(&self) -> @str; - pure fn char_at(&self, i: uint) -> char; - pure fn char_at_reverse(&self, i: uint) -> char; + fn all(&self, it: &fn(char) -> bool) -> bool; + fn any(&self, it: &fn(char) -> bool) -> bool; + fn contains(&self, needle: &'a str) -> bool; + fn contains_char(&self, needle: char) -> bool; + fn each(&self, it: &fn(u8) -> bool); + fn eachi(&self, it: &fn(uint, u8) -> bool); + fn each_reverse(&self, it: &fn(u8) -> bool); + fn eachi_reverse(&self, it: &fn(uint, u8) -> bool); + fn each_char(&self, it: &fn(char) -> bool); + fn each_chari(&self, it: &fn(uint, char) -> bool); + fn each_char_reverse(&self, it: &fn(char) -> bool); + fn each_chari_reverse(&self, it: &fn(uint, char) -> bool); + fn ends_with(&self, needle: &str) -> bool; + fn is_empty(&self) -> bool; + fn is_whitespace(&self) -> bool; + fn is_alphanumeric(&self) -> bool; + fn len(&self) -> uint; + fn char_len(&self) -> uint; + fn slice(&self, begin: uint, end: uint) -> &'self str; + fn split(&self, sepfn: &fn(char) -> bool) -> ~[~str]; + fn split_char(&self, sep: char) -> ~[~str]; + fn split_str(&self, sep: &'a str) -> ~[~str]; + fn starts_with(&self, needle: &'a str) -> bool; + fn substr(&self, begin: uint, n: uint) -> &'self str; + fn to_lower(&self) -> ~str; + fn to_upper(&self) -> ~str; + fn escape_default(&self) -> ~str; + fn escape_unicode(&self) -> ~str; + fn trim(&self) -> &'self str; + fn trim_left(&self) -> &'self str; + fn trim_right(&self) -> &'self str; + fn trim_chars(&self, chars_to_trim: &[char]) -> &'self str; + fn trim_left_chars(&self, chars_to_trim: &[char]) -> &'self str; + fn trim_right_chars(&self, chars_to_trim: &[char]) -> &'self str; + fn to_owned(&self) -> ~str; + fn to_managed(&self) -> @str; + fn char_at(&self, i: uint) -> char; + fn char_at_reverse(&self, i: uint) -> char; fn to_bytes(&self) -> ~[u8]; } @@ -2321,86 +2321,86 @@ impl StrSlice for &'self str { * contains no characters */ #[inline] - pure fn all(&self, it: &fn(char) -> bool) -> bool { all(*self, it) } + fn all(&self, it: &fn(char) -> bool) -> bool { all(*self, it) } /** * Return true if a predicate matches any character (and false if it * matches none or there are no characters) */ #[inline] - pure fn any(&self, it: &fn(char) -> bool) -> bool { any(*self, it) } + fn any(&self, it: &fn(char) -> bool) -> bool { any(*self, it) } /// Returns true if one string contains another #[inline] - pure fn contains(&self, needle: &'a str) -> bool { + fn contains(&self, needle: &'a str) -> bool { contains(*self, needle) } /// Returns true if a string contains a char #[inline] - pure fn contains_char(&self, needle: char) -> bool { + fn contains_char(&self, needle: char) -> bool { contains_char(*self, needle) } /// Iterate over the bytes in a string #[inline] - pure fn each(&self, it: &fn(u8) -> bool) { each(*self, it) } + fn each(&self, it: &fn(u8) -> bool) { each(*self, it) } /// Iterate over the bytes in a string, with indices #[inline] - pure fn eachi(&self, it: &fn(uint, u8) -> bool) { eachi(*self, it) } + fn eachi(&self, it: &fn(uint, u8) -> bool) { eachi(*self, it) } /// Iterate over the bytes in a string #[inline] - pure fn each_reverse(&self, it: &fn(u8) -> bool) { + fn each_reverse(&self, it: &fn(u8) -> bool) { each_reverse(*self, it) } /// Iterate over the bytes in a string, with indices #[inline] - pure fn eachi_reverse(&self, it: &fn(uint, u8) -> bool) { + fn eachi_reverse(&self, it: &fn(uint, u8) -> bool) { eachi_reverse(*self, it) } /// Iterate over the chars in a string #[inline] - pure fn each_char(&self, it: &fn(char) -> bool) { each_char(*self, it) } + fn each_char(&self, it: &fn(char) -> bool) { each_char(*self, it) } /// Iterate over the chars in a string, with indices #[inline] - pure fn each_chari(&self, it: &fn(uint, char) -> bool) { + fn each_chari(&self, it: &fn(uint, char) -> bool) { each_chari(*self, it) } /// Iterate over the chars in a string in reverse #[inline] - pure fn each_char_reverse(&self, it: &fn(char) -> bool) { + fn each_char_reverse(&self, it: &fn(char) -> bool) { each_char_reverse(*self, it) } /// Iterate over the chars in a string in reverse, with indices from the /// end #[inline] - pure fn each_chari_reverse(&self, it: &fn(uint, char) -> bool) { + fn each_chari_reverse(&self, it: &fn(uint, char) -> bool) { each_chari_reverse(*self, it) } /// Returns true if one string ends with another #[inline] - pure fn ends_with(&self, needle: &str) -> bool { + fn ends_with(&self, needle: &str) -> bool { ends_with(*self, needle) } /// Returns true if the string has length 0 #[inline] - pure fn is_empty(&self) -> bool { is_empty(*self) } + fn is_empty(&self) -> bool { is_empty(*self) } /** * Returns true if the string contains only whitespace * * Whitespace characters are determined by `char::is_whitespace` */ #[inline] - pure fn is_whitespace(&self) -> bool { is_whitespace(*self) } + fn is_whitespace(&self) -> bool { is_whitespace(*self) } /** * Returns true if the string contains only alphanumerics * * Alphanumeric characters are determined by `char::is_alphanumeric` */ #[inline] - pure fn is_alphanumeric(&self) -> bool { is_alphanumeric(*self) } + fn is_alphanumeric(&self) -> bool { is_alphanumeric(*self) } /// Returns the size in bytes not counting the null terminator #[inline] - pure fn len(&self) -> uint { len(*self) } + fn len(&self) -> uint { len(*self) } /// Returns the number of characters that a string holds #[inline] - pure fn char_len(&self) -> uint { char_len(*self) } + fn char_len(&self) -> uint { char_len(*self) } /** * Returns a slice of the given string from the byte range * [`begin`..`end`) @@ -2409,28 +2409,28 @@ impl StrSlice for &'self str { * beyond the last character of the string */ #[inline] - pure fn slice(&self, begin: uint, end: uint) -> &'self str { + fn slice(&self, begin: uint, end: uint) -> &'self str { slice(*self, begin, end) } /// Splits a string into substrings using a character function #[inline] - pure fn split(&self, sepfn: &fn(char) -> bool) -> ~[~str] { + fn split(&self, sepfn: &fn(char) -> bool) -> ~[~str] { split(*self, sepfn) } /** * Splits a string into substrings at each occurrence of a given character */ #[inline] - pure fn split_char(&self, sep: char) -> ~[~str] { split_char(*self, sep) } + fn split_char(&self, sep: char) -> ~[~str] { split_char(*self, sep) } /** * Splits a string into a vector of the substrings separated by a given * string */ #[inline] - pure fn split_str(&self, sep: &'a str) -> ~[~str] { split_str(*self, sep) } + fn split_str(&self, sep: &'a str) -> ~[~str] { split_str(*self, sep) } /// Returns true if one string starts with another #[inline] - pure fn starts_with(&self, needle: &'a str) -> bool { + fn starts_with(&self, needle: &'a str) -> bool { starts_with(*self, needle) } /** @@ -2440,51 +2440,51 @@ impl StrSlice for &'self str { * `begin`. */ #[inline] - pure fn substr(&self, begin: uint, n: uint) -> &'self str { + fn substr(&self, begin: uint, n: uint) -> &'self str { substr(*self, begin, n) } /// Convert a string to lowercase #[inline] - pure fn to_lower(&self) -> ~str { to_lower(*self) } + fn to_lower(&self) -> ~str { to_lower(*self) } /// Convert a string to uppercase #[inline] - pure fn to_upper(&self) -> ~str { to_upper(*self) } + fn to_upper(&self) -> ~str { to_upper(*self) } /// Escape each char in `s` with char::escape_default. #[inline] - pure fn escape_default(&self) -> ~str { escape_default(*self) } + fn escape_default(&self) -> ~str { escape_default(*self) } /// Escape each char in `s` with char::escape_unicode. #[inline] - pure fn escape_unicode(&self) -> ~str { escape_unicode(*self) } + fn escape_unicode(&self) -> ~str { escape_unicode(*self) } /// Returns a string with leading and trailing whitespace removed #[inline] - pure fn trim(&self) -> &'self str { trim(*self) } + fn trim(&self) -> &'self str { trim(*self) } /// Returns a string with leading whitespace removed #[inline] - pure fn trim_left(&self) -> &'self str { trim_left(*self) } + fn trim_left(&self) -> &'self str { trim_left(*self) } /// Returns a string with trailing whitespace removed #[inline] - pure fn trim_right(&self) -> &'self str { trim_right(*self) } + fn trim_right(&self) -> &'self str { trim_right(*self) } #[inline] - pure fn trim_chars(&self, chars_to_trim: &[char]) -> &'self str { + fn trim_chars(&self, chars_to_trim: &[char]) -> &'self str { trim_chars(*self, chars_to_trim) } #[inline] - pure fn trim_left_chars(&self, chars_to_trim: &[char]) -> &'self str { + fn trim_left_chars(&self, chars_to_trim: &[char]) -> &'self str { trim_left_chars(*self, chars_to_trim) } #[inline] - pure fn trim_right_chars(&self, chars_to_trim: &[char]) -> &'self str { + fn trim_right_chars(&self, chars_to_trim: &[char]) -> &'self str { trim_right_chars(*self, chars_to_trim) } #[inline] - pure fn to_owned(&self) -> ~str { from_slice(*self) } + fn to_owned(&self) -> ~str { from_slice(*self) } #[inline] - pure fn to_managed(&self) -> @str { + fn to_managed(&self) -> @str { let v = at_vec::from_fn(self.len() + 1, |i| { if i == self.len() { 0 } else { self[i] } }); @@ -2492,10 +2492,10 @@ impl StrSlice for &'self str { } #[inline] - pure fn char_at(&self, i: uint) -> char { char_at(*self, i) } + fn char_at(&self, i: uint) -> char { char_at(*self, i) } #[inline] - pure fn char_at_reverse(&self, i: uint) -> char { + fn char_at_reverse(&self, i: uint) -> char { char_at_reverse(*self, i) } diff --git a/src/libcore/sys.rs b/src/libcore/sys.rs index f7eceeebc1e..706cb10dba9 100644 --- a/src/libcore/sys.rs +++ b/src/libcore/sys.rs @@ -60,15 +60,15 @@ pub mod rustrt { /// Compares contents of two pointers using the default method. /// Equivalent to `*x1 == *x2`. Useful for hashtables. -pub pure fn shape_eq(x1: &T, x2: &T) -> bool { +pub fn shape_eq(x1: &T, x2: &T) -> bool { *x1 == *x2 } -pub pure fn shape_lt(x1: &T, x2: &T) -> bool { +pub fn shape_lt(x1: &T, x2: &T) -> bool { *x1 < *x2 } -pub pure fn shape_le(x1: &T, x2: &T) -> bool { +pub fn shape_le(x1: &T, x2: &T) -> bool { *x1 <= *x2 } @@ -79,13 +79,13 @@ pub pure fn shape_le(x1: &T, x2: &T) -> bool { * performing dark magick. */ #[inline(always)] -pub pure fn get_type_desc() -> *TypeDesc { +pub fn get_type_desc() -> *TypeDesc { unsafe { rusti::get_tydesc::() as *TypeDesc } } /// Returns the size of a type #[inline(always)] -pub pure fn size_of() -> uint { +pub fn size_of() -> uint { unsafe { rusti::size_of::() } } @@ -95,7 +95,7 @@ pub pure fn size_of() -> uint { * Useful for building structures containing variable-length arrays. */ #[inline(always)] -pub pure fn nonzero_size_of() -> uint { +pub fn nonzero_size_of() -> uint { let s = size_of::(); if s == 0 { 1 } else { s } } @@ -107,26 +107,26 @@ pub pure fn nonzero_size_of() -> uint { * than the preferred alignment. */ #[inline(always)] -pub pure fn min_align_of() -> uint { +pub fn min_align_of() -> uint { unsafe { rusti::min_align_of::() } } /// Returns the preferred alignment of a type #[inline(always)] -pub pure fn pref_align_of() -> uint { +pub fn pref_align_of() -> uint { unsafe { rusti::pref_align_of::() } } /// Returns the refcount of a shared box (as just before calling this) #[inline(always)] -pub pure fn refcount(t: @T) -> uint { +pub fn refcount(t: @T) -> uint { unsafe { let ref_ptr: *uint = cast::reinterpret_cast(&t); *ref_ptr - 1 } } -pub pure fn log_str(t: &T) -> ~str { +pub fn log_str(t: &T) -> ~str { unsafe { do io::with_str_writer |wr| { repr::write_repr(wr, t) @@ -135,7 +135,7 @@ pub pure fn log_str(t: &T) -> ~str { } /** Initiate task failure */ -pub pure fn begin_unwind(msg: ~str, file: ~str, line: uint) -> ! { +pub fn begin_unwind(msg: ~str, file: ~str, line: uint) -> ! { do str::as_buf(msg) |msg_buf, _msg_len| { do str::as_buf(file) |file_buf, _file_len| { unsafe { @@ -148,7 +148,7 @@ pub pure fn begin_unwind(msg: ~str, file: ~str, line: uint) -> ! { } // FIXME #4427: Temporary until rt::rt_fail_ goes away -pub pure fn begin_unwind_(msg: *c_char, file: *c_char, line: size_t) -> ! { +pub fn begin_unwind_(msg: *c_char, file: *c_char, line: size_t) -> ! { unsafe { gc::cleanup_stack_for_failure(); rustrt::rust_upcall_fail(msg, file, line); @@ -156,7 +156,7 @@ pub pure fn begin_unwind_(msg: *c_char, file: *c_char, line: size_t) -> ! { } } -pub pure fn fail_assert(msg: &str, file: &str, line: uint) -> ! { +pub fn fail_assert(msg: &str, file: &str, line: uint) -> ! { unsafe { let (msg, file) = (msg.to_owned(), file.to_owned()); begin_unwind(~"assertion failed: " + msg, file, line) diff --git a/src/libcore/task/local_data_priv.rs b/src/libcore/task/local_data_priv.rs index 6a933ef515f..59f4942b3a4 100644 --- a/src/libcore/task/local_data_priv.rs +++ b/src/libcore/task/local_data_priv.rs @@ -24,14 +24,14 @@ pub trait LocalData { } impl LocalData for @T { } impl Eq for @LocalData { - pure fn eq(&self, other: &@LocalData) -> bool { + fn eq(&self, other: &@LocalData) -> bool { unsafe { let ptr_a: (uint, uint) = cast::reinterpret_cast(&(*self)); let ptr_b: (uint, uint) = cast::reinterpret_cast(other); return ptr_a == ptr_b; } } - pure fn ne(&self, other: &@LocalData) -> bool { !(*self).eq(other) } + fn ne(&self, other: &@LocalData) -> bool { !(*self).eq(other) } } // If TLS is used heavily in future, this could be made more efficient with a diff --git a/src/libcore/task/mod.rs b/src/libcore/task/mod.rs index 1ef2316ec07..a38b44afb51 100644 --- a/src/libcore/task/mod.rs +++ b/src/libcore/task/mod.rs @@ -78,13 +78,13 @@ pub enum TaskResult { } impl Eq for TaskResult { - pure fn eq(&self, other: &TaskResult) -> bool { + fn eq(&self, other: &TaskResult) -> bool { match ((*self), (*other)) { (Success, Success) | (Failure, Failure) => true, (Success, _) | (Failure, _) => false } } - pure fn ne(&self, other: &TaskResult) -> bool { !(*self).eq(other) } + fn ne(&self, other: &TaskResult) -> bool { !(*self).eq(other) } } /// Scheduler modes diff --git a/src/libcore/task/spawn.rs b/src/libcore/task/spawn.rs index 40a6873ad67..b97a682c4e5 100644 --- a/src/libcore/task/spawn.rs +++ b/src/libcore/task/spawn.rs @@ -126,7 +126,7 @@ type TaskGroupArc = unstable::Exclusive>; type TaskGroupInner = &'self mut Option; // A taskgroup is 'dead' when nothing can cause it to fail; only members can. -pure fn taskgroup_is_dead(tg: &TaskGroupData) -> bool { +fn taskgroup_is_dead(tg: &TaskGroupData) -> bool { (&const tg.members).is_empty() } diff --git a/src/libcore/to_bytes.rs b/src/libcore/to_bytes.rs index e5fbad16717..f379878c8eb 100644 --- a/src/libcore/to_bytes.rs +++ b/src/libcore/to_bytes.rs @@ -43,12 +43,12 @@ pub trait IterBytes { * left-to-right in declaration order, regardless of * underlying memory endianness. */ - pure fn iter_bytes(&self, lsb0: bool, f: Cb); + fn iter_bytes(&self, lsb0: bool, f: Cb); } impl IterBytes for bool { #[inline(always)] - pure fn iter_bytes(&self, _lsb0: bool, f: Cb) { + fn iter_bytes(&self, _lsb0: bool, f: Cb) { f([ *self as u8 ]); @@ -57,7 +57,7 @@ impl IterBytes for bool { impl IterBytes for u8 { #[inline(always)] - pure fn iter_bytes(&self, _lsb0: bool, f: Cb) { + fn iter_bytes(&self, _lsb0: bool, f: Cb) { f([ *self ]); @@ -66,7 +66,7 @@ impl IterBytes for u8 { impl IterBytes for u16 { #[inline(always)] - pure fn iter_bytes(&self, lsb0: bool, f: Cb) { + fn iter_bytes(&self, lsb0: bool, f: Cb) { if lsb0 { f([ *self as u8, @@ -83,7 +83,7 @@ impl IterBytes for u16 { impl IterBytes for u32 { #[inline(always)] - pure fn iter_bytes(&self, lsb0: bool, f: Cb) { + fn iter_bytes(&self, lsb0: bool, f: Cb) { if lsb0 { f([ *self as u8, @@ -104,7 +104,7 @@ impl IterBytes for u32 { impl IterBytes for u64 { #[inline(always)] - pure fn iter_bytes(&self, lsb0: bool, f: Cb) { + fn iter_bytes(&self, lsb0: bool, f: Cb) { if lsb0 { f([ *self as u8, @@ -133,35 +133,35 @@ impl IterBytes for u64 { impl IterBytes for i8 { #[inline(always)] - pure fn iter_bytes(&self, lsb0: bool, f: Cb) { + fn iter_bytes(&self, lsb0: bool, f: Cb) { (*self as u8).iter_bytes(lsb0, f) } } impl IterBytes for i16 { #[inline(always)] - pure fn iter_bytes(&self, lsb0: bool, f: Cb) { + fn iter_bytes(&self, lsb0: bool, f: Cb) { (*self as u16).iter_bytes(lsb0, f) } } impl IterBytes for i32 { #[inline(always)] - pure fn iter_bytes(&self, lsb0: bool, f: Cb) { + fn iter_bytes(&self, lsb0: bool, f: Cb) { (*self as u32).iter_bytes(lsb0, f) } } impl IterBytes for i64 { #[inline(always)] - pure fn iter_bytes(&self, lsb0: bool, f: Cb) { + fn iter_bytes(&self, lsb0: bool, f: Cb) { (*self as u64).iter_bytes(lsb0, f) } } impl IterBytes for char { #[inline(always)] - pure fn iter_bytes(&self, lsb0: bool, f: Cb) { + fn iter_bytes(&self, lsb0: bool, f: Cb) { (*self as u32).iter_bytes(lsb0, f) } } @@ -172,7 +172,7 @@ pub mod x32 { impl IterBytes for uint { #[inline(always)] - pure fn iter_bytes(&self, lsb0: bool, f: Cb) { + fn iter_bytes(&self, lsb0: bool, f: Cb) { (*self as u32).iter_bytes(lsb0, f) } } @@ -184,7 +184,7 @@ pub mod x64 { impl IterBytes for uint { #[inline(always)] - pure fn iter_bytes(&self, lsb0: bool, f: Cb) { + fn iter_bytes(&self, lsb0: bool, f: Cb) { (*self as u64).iter_bytes(lsb0, f) } } @@ -192,14 +192,14 @@ pub mod x64 { impl IterBytes for int { #[inline(always)] - pure fn iter_bytes(&self, lsb0: bool, f: Cb) { + fn iter_bytes(&self, lsb0: bool, f: Cb) { (*self as uint).iter_bytes(lsb0, f) } } impl IterBytes for &'self [A] { #[inline(always)] - pure fn iter_bytes(&self, lsb0: bool, f: Cb) { + fn iter_bytes(&self, lsb0: bool, f: Cb) { for (*self).each |elt| { do elt.iter_bytes(lsb0) |bytes| { f(bytes) @@ -210,7 +210,7 @@ impl IterBytes for &'self [A] { impl IterBytes for (A,B) { #[inline(always)] - pure fn iter_bytes(&self, lsb0: bool, f: Cb) { + fn iter_bytes(&self, lsb0: bool, f: Cb) { match *self { (ref a, ref b) => { iter_bytes_2(a, b, lsb0, f); @@ -221,7 +221,7 @@ impl IterBytes for (A,B) { impl IterBytes for (A,B,C) { #[inline(always)] - pure fn iter_bytes(&self, lsb0: bool, f: Cb) { + fn iter_bytes(&self, lsb0: bool, f: Cb) { match *self { (ref a, ref b, ref c) => { iter_bytes_3(a, b, c, lsb0, f); @@ -231,25 +231,25 @@ impl IterBytes for (A,B,C) { } // Move this to vec, probably. -pure fn borrow(a: &'x [A]) -> &'x [A] { +fn borrow(a: &'x [A]) -> &'x [A] { a } impl IterBytes for ~[A] { #[inline(always)] - pure fn iter_bytes(&self, lsb0: bool, f: Cb) { + fn iter_bytes(&self, lsb0: bool, f: Cb) { borrow(*self).iter_bytes(lsb0, f) } } impl IterBytes for @[A] { #[inline(always)] - pure fn iter_bytes(&self, lsb0: bool, f: Cb) { + fn iter_bytes(&self, lsb0: bool, f: Cb) { borrow(*self).iter_bytes(lsb0, f) } } -pub pure fn iter_bytes_2(a: &A, b: &B, +pub fn iter_bytes_2(a: &A, b: &B, lsb0: bool, z: Cb) { let mut flag = true; a.iter_bytes(lsb0, |bytes| {flag = z(bytes); flag}); @@ -257,7 +257,7 @@ pub pure fn iter_bytes_2(a: &A, b: &B, b.iter_bytes(lsb0, |bytes| {flag = z(bytes); flag}); } -pub pure fn iter_bytes_3(a: &A, b: &B, c: &C, lsb0: bool, z: Cb) { @@ -269,7 +269,7 @@ pub pure fn iter_bytes_3(a: &A, b: &B, c: &C, @@ -285,7 +285,7 @@ pub pure fn iter_bytes_4 IterBytes for Option { #[inline(always)] - pure fn iter_bytes(&self, lsb0: bool, f: Cb) { + fn iter_bytes(&self, lsb0: bool, f: Cb) { match *self { Some(ref a) => iter_bytes_2(&0u8, a, lsb0, f), None => 1u8.iter_bytes(lsb0, f) @@ -391,21 +391,21 @@ impl IterBytes for Option { impl IterBytes for &'self A { #[inline(always)] - pure fn iter_bytes(&self, lsb0: bool, f: Cb) { + fn iter_bytes(&self, lsb0: bool, f: Cb) { (**self).iter_bytes(lsb0, f); } } impl IterBytes for @A { #[inline(always)] - pure fn iter_bytes(&self, lsb0: bool, f: Cb) { + fn iter_bytes(&self, lsb0: bool, f: Cb) { (**self).iter_bytes(lsb0, f); } } impl IterBytes for ~A { #[inline(always)] - pure fn iter_bytes(&self, lsb0: bool, f: Cb) { + fn iter_bytes(&self, lsb0: bool, f: Cb) { (**self).iter_bytes(lsb0, f); } } @@ -414,7 +414,7 @@ impl IterBytes for ~A { // to the target; it just gives you the pointer-bytes. impl IterBytes for *const A { #[inline(always)] - pure fn iter_bytes(&self, lsb0: bool, f: Cb) { + fn iter_bytes(&self, lsb0: bool, f: Cb) { (*self as uint).iter_bytes(lsb0, f); } } diff --git a/src/libcore/to_str.rs b/src/libcore/to_str.rs index b687fde0c37..576f794483d 100644 --- a/src/libcore/to_str.rs +++ b/src/libcore/to_str.rs @@ -17,23 +17,23 @@ The `ToStr` trait for converting to strings use str; pub trait ToStr { - pure fn to_str(&self) -> ~str; + fn to_str(&self) -> ~str; } impl ToStr for bool { #[inline(always)] - pure fn to_str(&self) -> ~str { ::bool::to_str(*self) } + fn to_str(&self) -> ~str { ::bool::to_str(*self) } } impl ToStr for () { #[inline(always)] - pure fn to_str(&self) -> ~str { ~"()" } + fn to_str(&self) -> ~str { ~"()" } } // FIXME #4898: impl for one-tuples impl ToStr for (A, B) { #[inline(always)] - pure fn to_str(&self) -> ~str { + fn to_str(&self) -> ~str { // FIXME(#4760): this causes an llvm assertion //let &(ref a, ref b) = self; match *self { @@ -45,7 +45,7 @@ impl ToStr for (A, B) { } impl ToStr for (A, B, C) { #[inline(always)] - pure fn to_str(&self) -> ~str { + fn to_str(&self) -> ~str { // FIXME(#4760): this causes an llvm assertion //let &(ref a, ref b, ref c) = self; match *self { @@ -62,7 +62,7 @@ impl ToStr for (A, B, C) { impl ToStr for &'self [A] { #[inline(always)] - pure fn to_str(&self) -> ~str { + fn to_str(&self) -> ~str { unsafe { // FIXME #4568 // Bleh -- not really unsafe @@ -83,7 +83,7 @@ impl ToStr for &'self [A] { impl ToStr for ~[A] { #[inline(always)] - pure fn to_str(&self) -> ~str { + fn to_str(&self) -> ~str { unsafe { // FIXME #4568 // Bleh -- not really unsafe @@ -104,7 +104,7 @@ impl ToStr for ~[A] { impl ToStr for @[A] { #[inline(always)] - pure fn to_str(&self) -> ~str { + fn to_str(&self) -> ~str { unsafe { // FIXME #4568 // Bleh -- not really unsafe diff --git a/src/libcore/trie.rs b/src/libcore/trie.rs index 7afe7e0d3d4..258de5c81db 100644 --- a/src/libcore/trie.rs +++ b/src/libcore/trie.rs @@ -32,17 +32,17 @@ pub struct TrieMap { impl BaseIter<(uint, &'self T)> for TrieMap { /// Visit all key-value pairs in order #[inline(always)] - pure fn each(&self, f: &fn(&(uint, &'self T)) -> bool) { + fn each(&self, f: &fn(&(uint, &'self T)) -> bool) { self.root.each(f); } #[inline(always)] - pure fn size_hint(&self) -> Option { Some(self.len()) } + fn size_hint(&self) -> Option { Some(self.len()) } } impl ReverseIter<(uint, &'self T)> for TrieMap { /// Visit all key-value pairs in reverse order #[inline(always)] - pure fn each_reverse(&self, f: &fn(&(uint, &'self T)) -> bool) { + fn each_reverse(&self, f: &fn(&(uint, &'self T)) -> bool) { self.root.each_reverse(f); } } @@ -50,11 +50,11 @@ impl ReverseIter<(uint, &'self T)> for TrieMap { impl Container for TrieMap { /// Return the number of elements in the map #[inline(always)] - pure fn len(&const self) -> uint { self.length } + fn len(&const self) -> uint { self.length } /// Return true if the map contains no elements #[inline(always)] - pure fn is_empty(&const self) -> bool { self.len() == 0 } + fn is_empty(&const self) -> bool { self.len() == 0 } } impl Mutable for TrieMap { @@ -69,19 +69,19 @@ impl Mutable for TrieMap { impl Map for TrieMap { /// Return true if the map contains a value for the specified key #[inline(always)] - pure fn contains_key(&self, key: &uint) -> bool { + fn contains_key(&self, key: &uint) -> bool { self.find(key).is_some() } /// Visit all keys in order #[inline(always)] - pure fn each_key(&self, f: &fn(&uint) -> bool) { + fn each_key(&self, f: &fn(&uint) -> bool) { self.each(|&(k, _)| f(&k)) } /// Visit all values in order #[inline(always)] - pure fn each_value(&self, f: &fn(&T) -> bool) { + fn each_value(&self, f: &fn(&T) -> bool) { self.each(|&(_, v)| f(v)) } @@ -93,7 +93,7 @@ impl Map for TrieMap { /// Return the value corresponding to the key in the map #[inline(hint)] - pure fn find(&self, key: &uint) -> Option<&'self T> { + fn find(&self, key: &uint) -> Option<&'self T> { let mut node: &'self TrieNode = &self.root; let mut idx = 0; loop { @@ -139,19 +139,19 @@ impl Map for TrieMap { pub impl TrieMap { /// Create an empty TrieMap #[inline(always)] - pure fn new() -> TrieMap { + fn new() -> TrieMap { TrieMap{root: TrieNode::new(), length: 0} } /// Visit all keys in reverse order #[inline(always)] - pure fn each_key_reverse(&self, f: &fn(&uint) -> bool) { + fn each_key_reverse(&self, f: &fn(&uint) -> bool) { self.each_reverse(|&(k, _)| f(&k)) } /// Visit all values in reverse order #[inline(always)] - pure fn each_value_reverse(&self, f: &fn(&T) -> bool) { + fn each_value_reverse(&self, f: &fn(&T) -> bool) { self.each_reverse(|&(_, v)| f(v)) } } @@ -162,13 +162,13 @@ pub struct TrieSet { impl BaseIter for TrieSet { /// Visit all values in order - pure fn each(&self, f: &fn(&uint) -> bool) { self.map.each_key(f) } - pure fn size_hint(&self) -> Option { Some(self.len()) } + fn each(&self, f: &fn(&uint) -> bool) { self.map.each_key(f) } + fn size_hint(&self) -> Option { Some(self.len()) } } impl ReverseIter for TrieSet { /// Visit all values in reverse order - pure fn each_reverse(&self, f: &fn(&uint) -> bool) { + fn each_reverse(&self, f: &fn(&uint) -> bool) { self.map.each_key_reverse(f) } } @@ -176,11 +176,11 @@ impl ReverseIter for TrieSet { impl Container for TrieSet { /// Return the number of elements in the set #[inline(always)] - pure fn len(&const self) -> uint { self.map.len() } + fn len(&const self) -> uint { self.map.len() } /// Return true if the set contains no elements #[inline(always)] - pure fn is_empty(&const self) -> bool { self.map.is_empty() } + fn is_empty(&const self) -> bool { self.map.is_empty() } } impl Mutable for TrieSet { @@ -192,13 +192,13 @@ impl Mutable for TrieSet { impl TrieSet { /// Create an empty TrieSet #[inline(always)] - pure fn new() -> TrieSet { + fn new() -> TrieSet { TrieSet{map: TrieMap::new()} } /// Return true if the set contains a value #[inline(always)] - pure fn contains(&self, value: &uint) -> bool { + fn contains(&self, value: &uint) -> bool { self.map.contains_key(value) } @@ -220,7 +220,7 @@ struct TrieNode { impl TrieNode { #[inline(always)] - pure fn new() -> TrieNode { + fn new() -> TrieNode { // FIXME: #5244: [Nothing, ..SIZE] should be possible without Copy TrieNode{count: 0, children: [Nothing, Nothing, Nothing, Nothing, @@ -231,7 +231,7 @@ impl TrieNode { } impl TrieNode { - pure fn each(&self, f: &fn(&(uint, &'self T)) -> bool) -> bool { + fn each(&self, f: &fn(&(uint, &'self T)) -> bool) -> bool { for uint::range(0, self.children.len()) |idx| { match self.children[idx] { Internal(ref x) => if !x.each(f) { return false }, @@ -242,7 +242,7 @@ impl TrieNode { true } - pure fn each_reverse(&self, f: &fn(&(uint, &'self T)) -> bool) -> bool { + fn each_reverse(&self, f: &fn(&(uint, &'self T)) -> bool) -> bool { for uint::range_rev(self.children.len(), 0) |idx| { match self.children[idx - 1] { Internal(ref x) => if !x.each_reverse(f) { return false }, @@ -269,7 +269,7 @@ impl TrieNode { // if this was done via a trait, the key could be generic #[inline(always)] -pure fn chunk(n: uint, idx: uint) -> uint { +fn chunk(n: uint, idx: uint) -> uint { let sh = uint::bits - (SHIFT * (idx + 1)); (n >> sh) & MASK } diff --git a/src/libcore/tuple.rs b/src/libcore/tuple.rs index b4f68466c27..fc7834a7514 100644 --- a/src/libcore/tuple.rs +++ b/src/libcore/tuple.rs @@ -16,30 +16,30 @@ use vec; #[cfg(notest)] use cmp::{Eq, Ord}; pub trait CopyableTuple { - pure fn first(&self) -> T; - pure fn second(&self) -> U; - pure fn swap(&self) -> (U, T); + fn first(&self) -> T; + fn second(&self) -> U; + fn swap(&self) -> (U, T); } impl CopyableTuple for (T, U) { /// Return the first element of self #[inline(always)] - pure fn first(&self) -> T { + fn first(&self) -> T { let (t, _) = *self; return t; } /// Return the second element of self #[inline(always)] - pure fn second(&self) -> U { + fn second(&self) -> U { let (_, u) = *self; return u; } /// Return the results of swapping the two elements of self #[inline(always)] - pure fn swap(&self) -> (U, T) { + fn swap(&self) -> (U, T) { let (t, u) = *self; return (u, t); } @@ -47,19 +47,19 @@ impl CopyableTuple for (T, U) { } pub trait ImmutableTuple { - pure fn first_ref(&self) -> &'self T; - pure fn second_ref(&self) -> &'self U; + fn first_ref(&self) -> &'self T; + fn second_ref(&self) -> &'self U; } impl ImmutableTuple for (T, U) { #[inline(always)] - pure fn first_ref(&self) -> &'self T { + fn first_ref(&self) -> &'self T { match *self { (ref t, _) => t, } } #[inline(always)] - pure fn second_ref(&self) -> &'self U { + fn second_ref(&self) -> &'self U { match *self { (_, ref u) => u, } @@ -117,7 +117,7 @@ impl ExtendedTupleOps for (~[A], ~[B]) { #[cfg(notest)] impl Eq for (A, B) { #[inline(always)] - pure fn eq(&self, other: &(A, B)) -> bool { + fn eq(&self, other: &(A, B)) -> bool { match (*self) { (ref self_a, ref self_b) => match other { &(ref other_a, ref other_b) => { @@ -127,13 +127,13 @@ impl Eq for (A, B) { } } #[inline(always)] - pure fn ne(&self, other: &(A, B)) -> bool { !(*self).eq(other) } + fn ne(&self, other: &(A, B)) -> bool { !(*self).eq(other) } } #[cfg(notest)] impl Ord for (A, B) { #[inline(always)] - pure fn lt(&self, other: &(A, B)) -> bool { + fn lt(&self, other: &(A, B)) -> bool { match (*self) { (ref self_a, ref self_b) => { match (*other) { @@ -148,17 +148,17 @@ impl Ord for (A, B) { } } #[inline(always)] - pure fn le(&self, other: &(A, B)) -> bool { !(*other).lt(&(*self)) } + fn le(&self, other: &(A, B)) -> bool { !(*other).lt(&(*self)) } #[inline(always)] - pure fn ge(&self, other: &(A, B)) -> bool { !(*self).lt(other) } + fn ge(&self, other: &(A, B)) -> bool { !(*self).lt(other) } #[inline(always)] - pure fn gt(&self, other: &(A, B)) -> bool { (*other).lt(&(*self)) } + fn gt(&self, other: &(A, B)) -> bool { (*other).lt(&(*self)) } } #[cfg(notest)] impl Eq for (A, B, C) { #[inline(always)] - pure fn eq(&self, other: &(A, B, C)) -> bool { + fn eq(&self, other: &(A, B, C)) -> bool { match (*self) { (ref self_a, ref self_b, ref self_c) => match other { &(ref other_a, ref other_b, ref other_c) => { @@ -169,13 +169,13 @@ impl Eq for (A, B, C) { } } #[inline(always)] - pure fn ne(&self, other: &(A, B, C)) -> bool { !(*self).eq(other) } + fn ne(&self, other: &(A, B, C)) -> bool { !(*self).eq(other) } } #[cfg(notest)] impl Ord for (A, B, C) { #[inline(always)] - pure fn lt(&self, other: &(A, B, C)) -> bool { + fn lt(&self, other: &(A, B, C)) -> bool { match (*self) { (ref self_a, ref self_b, ref self_c) => { match (*other) { @@ -192,11 +192,11 @@ impl Ord for (A, B, C) { } } #[inline(always)] - pure fn le(&self, other: &(A, B, C)) -> bool { !(*other).lt(&(*self)) } + fn le(&self, other: &(A, B, C)) -> bool { !(*other).lt(&(*self)) } #[inline(always)] - pure fn ge(&self, other: &(A, B, C)) -> bool { !(*self).lt(other) } + fn ge(&self, other: &(A, B, C)) -> bool { !(*self).lt(other) } #[inline(always)] - pure fn gt(&self, other: &(A, B, C)) -> bool { (*other).lt(&(*self)) } + fn gt(&self, other: &(A, B, C)) -> bool { (*other).lt(&(*self)) } } #[test] diff --git a/src/libcore/unicode.rs b/src/libcore/unicode.rs index ff3b908186a..9f2ab66d5c2 100644 --- a/src/libcore/unicode.rs +++ b/src/libcore/unicode.rs @@ -11,7 +11,7 @@ #[doc(hidden)]; // FIXME #3538 pub mod general_category { - pub pure fn Cc(c: char) -> bool { + pub fn Cc(c: char) -> bool { return match c { '\x00' .. '\x1f' | '\x7f' .. '\x9f' => true, @@ -19,7 +19,7 @@ pub mod general_category { }; } - pub pure fn Cf(c: char) -> bool { + pub fn Cf(c: char) -> bool { return match c { '\xad' | '\u0600' .. '\u0603' @@ -38,21 +38,21 @@ pub mod general_category { }; } - pub pure fn Co(c: char) -> bool { + pub fn Co(c: char) -> bool { return match c { '\ue000' .. '\uf8ff' => true, _ => false }; } - pub pure fn Cs(c: char) -> bool { + pub fn Cs(c: char) -> bool { return match c { '\ud800' .. '\udfff' => true, _ => false }; } - pub pure fn Ll(c: char) -> bool { + pub fn Ll(c: char) -> bool { return match c { '\x61' .. '\x7a' | '\xaa' @@ -657,7 +657,7 @@ pub mod general_category { }; } - pub pure fn Lm(c: char) -> bool { + pub fn Lm(c: char) -> bool { return match c { '\u02b0' .. '\u02c1' | '\u02c6' .. '\u02d1' @@ -713,7 +713,7 @@ pub mod general_category { }; } - pub pure fn Lo(c: char) -> bool { + pub fn Lo(c: char) -> bool { return match c { '\u01bb' | '\u01c0' .. '\u01c3' @@ -899,7 +899,7 @@ pub mod general_category { }; } - pub pure fn Lt(c: char) -> bool { + pub fn Lt(c: char) -> bool { return match c { '\u01c5' | '\u01c8' @@ -916,7 +916,7 @@ pub mod general_category { }; } - pub pure fn Lu(c: char) -> bool { + pub fn Lu(c: char) -> bool { return match c { '\x41' .. '\x5a' | '\xc0' .. '\xd6' @@ -1508,7 +1508,7 @@ pub mod general_category { }; } - pub pure fn Mc(c: char) -> bool { + pub fn Mc(c: char) -> bool { return match c { '\u0903' | '\u093b' @@ -1619,7 +1619,7 @@ pub mod general_category { }; } - pub pure fn Me(c: char) -> bool { + pub fn Me(c: char) -> bool { return match c { '\u0488' .. '\u0489' | '\u20dd' .. '\u20e0' @@ -1630,7 +1630,7 @@ pub mod general_category { }; } - pub pure fn Mn(c: char) -> bool { + pub fn Mn(c: char) -> bool { return match c { '\u0300' .. '\u036f' | '\u0483' .. '\u0487' @@ -1823,7 +1823,7 @@ pub mod general_category { }; } - pub pure fn Nd(c: char) -> bool { + pub fn Nd(c: char) -> bool { return match c { '\x30' .. '\x39' | '\u0660' .. '\u0669' @@ -1867,7 +1867,7 @@ pub mod general_category { }; } - pub pure fn Nl(c: char) -> bool { + pub fn Nl(c: char) -> bool { return match c { '\u16ee' .. '\u16f0' | '\u2160' .. '\u2182' @@ -1886,7 +1886,7 @@ pub mod general_category { }; } - pub pure fn No(c: char) -> bool { + pub fn No(c: char) -> bool { return match c { '\xb2' .. '\xb3' | '\xb9' @@ -1934,7 +1934,7 @@ pub mod general_category { }; } - pub pure fn Pc(c: char) -> bool { + pub fn Pc(c: char) -> bool { return match c { '\x5f' | '\u203f' .. '\u2040' @@ -1947,7 +1947,7 @@ pub mod general_category { }; } - pub pure fn Pd(c: char) -> bool { + pub fn Pd(c: char) -> bool { return match c { '\x2d' | '\u058a' @@ -1969,7 +1969,7 @@ pub mod general_category { }; } - pub pure fn Pe(c: char) -> bool { + pub fn Pe(c: char) -> bool { return match c { '\x29' | '\x5d' @@ -2046,7 +2046,7 @@ pub mod general_category { }; } - pub pure fn Pf(c: char) -> bool { + pub fn Pf(c: char) -> bool { return match c { '\xbb' | '\u2019' @@ -2063,7 +2063,7 @@ pub mod general_category { }; } - pub pure fn Pi(c: char) -> bool { + pub fn Pi(c: char) -> bool { return match c { '\xab' | '\u2018' @@ -2081,7 +2081,7 @@ pub mod general_category { }; } - pub pure fn Po(c: char) -> bool { + pub fn Po(c: char) -> bool { return match c { '\x21' .. '\x23' | '\x25' .. '\x27' @@ -2214,7 +2214,7 @@ pub mod general_category { }; } - pub pure fn Ps(c: char) -> bool { + pub fn Ps(c: char) -> bool { return match c { '\x28' | '\x5b' @@ -2293,7 +2293,7 @@ pub mod general_category { }; } - pub pure fn Sc(c: char) -> bool { + pub fn Sc(c: char) -> bool { return match c { '\x24' | '\xa2' .. '\xa5' @@ -2316,7 +2316,7 @@ pub mod general_category { }; } - pub pure fn Sk(c: char) -> bool { + pub fn Sk(c: char) -> bool { return match c { '\x5e' | '\x60' @@ -2350,7 +2350,7 @@ pub mod general_category { }; } - pub pure fn Sm(c: char) -> bool { + pub fn Sm(c: char) -> bool { return match c { '\x2b' | '\x3c' .. '\x3e' @@ -2421,7 +2421,7 @@ pub mod general_category { }; } - pub pure fn So(c: char) -> bool { + pub fn So(c: char) -> bool { return match c { '\xa6' .. '\xa7' | '\xa9' @@ -2540,21 +2540,21 @@ pub mod general_category { }; } - pub pure fn Zl(c: char) -> bool { + pub fn Zl(c: char) -> bool { return match c { '\u2028' => true, _ => false }; } - pub pure fn Zp(c: char) -> bool { + pub fn Zp(c: char) -> bool { return match c { '\u2029' => true, _ => false }; } - pub pure fn Zs(c: char) -> bool { + pub fn Zs(c: char) -> bool { return match c { '\x20' | '\xa0' @@ -2572,7 +2572,7 @@ pub mod general_category { } mod derived_property { /// Check if a character has the alphabetic unicode property - pub pure fn Alphabetic(c: char) -> bool { + pub fn Alphabetic(c: char) -> bool { return match c { '\x41' .. '\x5a' | '\x61' .. '\x7a' @@ -3310,7 +3310,7 @@ mod derived_property { }; } - pub pure fn XID_Continue(c: char) -> bool { + pub fn XID_Continue(c: char) -> bool { return match c { '\x30' .. '\x39' | '\x41' .. '\x5a' @@ -4181,7 +4181,7 @@ mod derived_property { }; } - pub pure fn XID_Start(c: char) -> bool { + pub fn XID_Start(c: char) -> bool { return match c { '\x41' .. '\x5a' | '\x61' .. '\x7a' diff --git a/src/libcore/unstable/extfmt.rs b/src/libcore/unstable/extfmt.rs index 766dd1a37a0..69f2b864369 100644 --- a/src/libcore/unstable/extfmt.rs +++ b/src/libcore/unstable/extfmt.rs @@ -140,7 +140,7 @@ pub mod ct { } pub impl Parsed { - pure fn new(val: T, next: uint) -> Parsed { + fn new(val: T, next: uint) -> Parsed { Parsed {val: val, next: next} } } @@ -496,7 +496,7 @@ pub mod rt { ty: Ty, } - pub pure fn conv_int(cv: Conv, i: int) -> ~str { + pub fn conv_int(cv: Conv, i: int) -> ~str { let radix = 10; let prec = get_int_precision(cv); let mut s : ~str = int_to_str_prec(i, radix, prec); @@ -509,7 +509,7 @@ pub mod rt { } return unsafe { pad(cv, s, PadSigned) }; } - pub pure fn conv_uint(cv: Conv, u: uint) -> ~str { + pub fn conv_uint(cv: Conv, u: uint) -> ~str { let prec = get_int_precision(cv); let mut rs = match cv.ty { @@ -521,17 +521,17 @@ pub mod rt { }; return unsafe { pad(cv, rs, PadUnsigned) }; } - pub pure fn conv_bool(cv: Conv, b: bool) -> ~str { + pub 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. return conv_str(cv, s); } - pub pure fn conv_char(cv: Conv, c: char) -> ~str { + pub fn conv_char(cv: Conv, c: char) -> ~str { let mut s = str::from_char(c); return unsafe { pad(cv, s, PadNozero) }; } - pub pure fn conv_str(cv: Conv, s: &str) -> ~str { + pub fn conv_str(cv: Conv, s: &str) -> ~str { // For strings, precision is the maximum characters // displayed let mut unpadded = match cv.precision { @@ -544,7 +544,7 @@ pub mod rt { }; return unsafe { pad(cv, unpadded, PadNozero) }; } - pub pure fn conv_float(cv: Conv, f: float) -> ~str { + pub fn conv_float(cv: Conv, f: float) -> ~str { let (to_str, digits) = match cv.precision { CountIs(c) => (float::to_str_exact, c as uint), CountImplied => (float::to_str_digits, 6u) @@ -559,14 +559,14 @@ pub mod rt { } return unsafe { pad(cv, s, PadFloat) }; } - pub pure fn conv_poly(cv: Conv, v: &T) -> ~str { + pub fn conv_poly(cv: Conv, v: &T) -> ~str { let s = sys::log_str(v); 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. - pub pure fn int_to_str_prec(num: int, radix: uint, prec: uint) -> ~str { + pub fn int_to_str_prec(num: int, radix: uint, prec: uint) -> ~str { return if num < 0 { ~"-" + uint_to_str_prec(-num as uint, radix, prec) } else { uint_to_str_prec(num as uint, radix, prec) }; @@ -575,7 +575,7 @@ pub mod rt { // Convert a uint to string with a minimum number of digits. If precision // 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. - pub pure fn uint_to_str_prec(num: uint, radix: uint, + pub fn uint_to_str_prec(num: uint, radix: uint, prec: uint) -> ~str { return if prec == 0u && num == 0u { ~"" @@ -589,7 +589,7 @@ pub mod rt { } else { s } }; } - pub pure fn get_int_precision(cv: Conv) -> uint { + pub fn get_int_precision(cv: Conv) -> uint { return match cv.precision { CountIs(c) => c as uint, CountImplied => 1u @@ -619,7 +619,7 @@ pub mod rt { PadFloat => (true, true), PadUnsigned => (true, false) }; - pure fn have_precision(cv: Conv) -> bool { + fn have_precision(cv: Conv) -> bool { return match cv.precision { CountImplied => false, _ => true }; } let zero_padding = { @@ -649,7 +649,7 @@ pub mod rt { } return padstr + s; } - pub pure fn have_flag(flags: u32, f: u32) -> bool { + pub fn have_flag(flags: u32, f: u32) -> bool { flags & f != 0 } } diff --git a/src/libcore/util.rs b/src/libcore/util.rs index 214a9dea8d1..739314bf619 100644 --- a/src/libcore/util.rs +++ b/src/libcore/util.rs @@ -18,11 +18,11 @@ use prelude::*; /// The identity function. #[inline(always)] -pub pure fn id(x: T) -> T { x } +pub fn id(x: T) -> T { x } /// Ignores a value. #[inline(always)] -pub pure fn ignore(_x: T) { } +pub fn ignore(_x: T) { } /// Sets `*ptr` to `new_value`, invokes `op()`, and then restores the /// original value of `*ptr`. diff --git a/src/libcore/vec.rs b/src/libcore/vec.rs index 2e20e859d55..56d547874d8 100644 --- a/src/libcore/vec.rs +++ b/src/libcore/vec.rs @@ -47,12 +47,12 @@ pub mod rustrt { } /// Returns true if a vector contains no elements -pub pure fn is_empty(v: &[const T]) -> bool { +pub fn is_empty(v: &[const T]) -> bool { as_const_buf(v, |_p, len| len == 0u) } /// Returns true if two vectors have the same length -pub pure fn same_length(xs: &[const T], ys: &[const U]) -> bool { +pub fn same_length(xs: &[const T], ys: &[const U]) -> bool { xs.len() == ys.len() } @@ -105,7 +105,7 @@ pub fn reserve_at_least(v: &mut ~[T], n: uint) { /// Returns the number of elements the vector can hold without reallocating #[inline(always)] -pub pure fn capacity(v: &const ~[T]) -> uint { +pub fn capacity(v: &const ~[T]) -> uint { unsafe { let repr: **raw::VecRepr = ::cast::transmute(v); (**repr).unboxed.alloc / sys::nonzero_size_of::() @@ -114,12 +114,12 @@ pub pure fn capacity(v: &const ~[T]) -> uint { /// Returns the length of a vector #[inline(always)] -pub pure fn len(v: &[const T]) -> uint { +pub fn len(v: &[const T]) -> uint { as_const_buf(v, |_p, len| len) } // A botch to tide us over until core and std are fully demuted. -pub pure fn uniq_len(v: &const ~[T]) -> uint { +pub fn uniq_len(v: &const ~[T]) -> uint { unsafe { let v: &~[T] = ::cast::transmute(v); as_const_buf(*v, |_p, len| len) @@ -132,7 +132,7 @@ pub pure fn uniq_len(v: &const ~[T]) -> uint { * Creates an immutable vector of size `n_elts` and initializes the elements * to the value returned by the function `op`. */ -pub pure fn from_fn(n_elts: uint, op: iter::InitOp) -> ~[T] { +pub fn from_fn(n_elts: uint, op: iter::InitOp) -> ~[T] { unsafe { let mut v = with_capacity(n_elts); do as_mut_buf(v) |p, _len| { @@ -154,16 +154,16 @@ pub pure fn from_fn(n_elts: uint, op: iter::InitOp) -> ~[T] { * Creates an immutable vector of size `n_elts` and initializes the elements * to the value `t`. */ -pub pure fn from_elem(n_elts: uint, t: T) -> ~[T] { +pub fn from_elem(n_elts: uint, t: T) -> ~[T] { from_fn(n_elts, |_i| copy t) } /// Creates a new unique vector with the same contents as the slice -pub pure fn from_slice(t: &[T]) -> ~[T] { +pub fn from_slice(t: &[T]) -> ~[T] { from_fn(t.len(), |i| t[i]) } -pub pure fn with_capacity(capacity: uint) -> ~[T] { +pub fn with_capacity(capacity: uint) -> ~[T] { let mut vec = ~[]; unsafe { reserve(&mut vec, capacity); } vec @@ -182,8 +182,7 @@ pub pure fn with_capacity(capacity: uint) -> ~[T] { * onto the vector being constructed. */ #[inline(always)] -pub pure fn build_sized(size: uint, - builder: &fn(push: &pure fn(v: A))) -> ~[A] { +pub fn build_sized(size: uint, builder: &fn(push: &fn(v: A))) -> ~[A] { let mut vec = with_capacity(size); builder(|x| unsafe { vec.push(x) }); vec @@ -200,7 +199,7 @@ pub pure fn build_sized(size: uint, * onto the vector being constructed. */ #[inline(always)] -pub pure fn build(builder: &fn(push: &pure fn(v: A))) -> ~[A] { +pub fn build(builder: &fn(push: &fn(v: A))) -> ~[A] { build_sized(4, builder) } @@ -217,54 +216,55 @@ pub pure fn build(builder: &fn(push: &pure fn(v: A))) -> ~[A] { * onto the vector being constructed. */ #[inline(always)] -pub pure fn build_sized_opt(size: Option, - builder: &fn(push: &pure fn(v: A))) -> ~[A] { +pub fn build_sized_opt(size: Option, + builder: &fn(push: &fn(v: A))) + -> ~[A] { build_sized(size.get_or_default(4), builder) } // Accessors /// Returns the first element of a vector -pub pure fn head(v: &'r [T]) -> &'r T { +pub fn head(v: &'r [T]) -> &'r T { if v.len() == 0 { fail!(~"head: empty vector") } &v[0] } /// Returns `Some(x)` where `x` is the first element of the slice `v`, /// or `None` if the vector is empty. -pub pure fn head_opt(v: &'r [T]) -> Option<&'r T> { +pub fn head_opt(v: &'r [T]) -> Option<&'r T> { if v.len() == 0 { None } else { Some(&v[0]) } } /// Returns a vector containing all but the first element of a slice -pub pure fn tail(v: &'r [T]) -> &'r [T] { slice(v, 1, v.len()) } +pub fn tail(v: &'r [T]) -> &'r [T] { slice(v, 1, v.len()) } /// Returns a vector containing all but the first `n` elements of a slice -pub pure fn tailn(v: &'r [T], n: uint) -> &'r [T] { slice(v, n, v.len()) } +pub fn tailn(v: &'r [T], n: uint) -> &'r [T] { slice(v, n, v.len()) } /// Returns a vector containing all but the last element of a slice -pub pure fn init(v: &'r [T]) -> &'r [T] { slice(v, 0, v.len() - 1) } +pub fn init(v: &'r [T]) -> &'r [T] { slice(v, 0, v.len() - 1) } /// Returns a vector containing all but the last `n' elements of a slice -pub pure fn initn(v: &'r [T], n: uint) -> &'r [T] { +pub fn initn(v: &'r [T], n: uint) -> &'r [T] { slice(v, 0, v.len() - n) } /// Returns the last element of the slice `v`, failing if the slice is empty. -pub pure fn last(v: &'r [T]) -> &'r T { +pub fn last(v: &'r [T]) -> &'r T { if v.len() == 0 { fail!(~"last: empty vector") } &v[v.len() - 1] } /// Returns `Some(x)` where `x` is the last element of the slice `v`, or /// `None` if the vector is empty. -pub pure fn last_opt(v: &'r [T]) -> Option<&'r T> { +pub fn last_opt(v: &'r [T]) -> Option<&'r T> { if v.len() == 0 { None } else { Some(&v[v.len() - 1]) } } /// Return a slice that points into another slice. #[inline(always)] -pub pure fn slice(v: &'r [T], start: uint, end: uint) -> &'r [T] { +pub fn slice(v: &'r [T], start: uint, end: uint) -> &'r [T] { fail_unless!(start <= end); fail_unless!(end <= len(v)); do as_imm_buf(v) |p, _len| { @@ -278,10 +278,7 @@ pub pure fn slice(v: &'r [T], start: uint, end: uint) -> &'r [T] { /// Return a slice that points into another slice. #[inline(always)] -pub pure fn mut_slice(v: &'r mut [T], - start: uint, - end: uint) - -> &'r mut [T] { +pub fn mut_slice(v: &'r mut [T], start: uint, end: uint) -> &'r mut [T] { fail_unless!(start <= end); fail_unless!(end <= v.len()); do as_mut_buf(v) |p, _len| { @@ -295,10 +292,8 @@ pub pure fn mut_slice(v: &'r mut [T], /// Return a slice that points into another slice. #[inline(always)] -pub pure fn const_slice(v: &'r [const T], - start: uint, - end: uint) - -> &'r [const T] { +pub fn const_slice(v: &'r [const T], start: uint, end: uint) + -> &'r [const T] { fail_unless!(start <= end); fail_unless!(end <= len(v)); do as_const_buf(v) |p, _len| { @@ -434,7 +429,7 @@ pub fn partition(v: ~[T], f: &fn(&T) -> bool) -> (~[T], ~[T]) { * Partitions a vector into two new vectors: those that satisfies the * predicate, and those that do not. */ -pub pure fn partitioned(v: &[T], f: &fn(&T) -> bool) -> (~[T], ~[T]) { +pub fn partitioned(v: &[T], f: &fn(&T) -> bool) -> (~[T], ~[T]) { let mut lefts = ~[]; let mut rights = ~[]; @@ -713,7 +708,7 @@ pub fn dedup(v: &mut ~[T]) { // Appending #[inline(always)] -pub pure fn append(lhs: ~[T], rhs: &[const T]) -> ~[T] { +pub fn append(lhs: ~[T], rhs: &[const T]) -> ~[T] { let mut v = lhs; unsafe { v.push_all(rhs); @@ -722,7 +717,7 @@ pub pure fn append(lhs: ~[T], rhs: &[const T]) -> ~[T] { } #[inline(always)] -pub pure fn append_one(lhs: ~[T], x: T) -> ~[T] { +pub fn append_one(lhs: ~[T], x: T) -> ~[T] { let mut v = lhs; unsafe { v.push(x); } v @@ -788,7 +783,7 @@ pub fn grow_set(v: &mut ~[T], index: uint, initval: &T, val: T) { // Functional utilities /// Apply a function to each element of a vector and return the results -pub pure fn map(v: &[T], f: &fn(t: &T) -> U) -> ~[U] { +pub fn map(v: &[T], f: &fn(t: &T) -> U) -> ~[U] { let mut result = with_capacity(len(v)); for each(v) |elem| { unsafe { @@ -807,7 +802,7 @@ pub fn map_consume(v: ~[T], f: &fn(v: T) -> U) -> ~[U] { } /// Apply a function to each element of a vector and return the results -pub pure fn mapi(v: &[T], f: &fn(uint, t: &T) -> U) -> ~[U] { +pub fn mapi(v: &[T], f: &fn(uint, t: &T) -> U) -> ~[U] { let mut i = 0; do map(v) |e| { i += 1; @@ -819,14 +814,14 @@ pub pure fn mapi(v: &[T], f: &fn(uint, t: &T) -> U) -> ~[U] { * Apply a function to each element of a vector and return a concatenation * of each result vector */ -pub pure fn flat_map(v: &[T], f: &fn(t: &T) -> ~[U]) -> ~[U] { +pub fn flat_map(v: &[T], f: &fn(t: &T) -> ~[U]) -> ~[U] { let mut result = ~[]; for each(v) |elem| { unsafe{ result.push_all_move(f(elem)); } } result } /// Apply a function to each pair of elements and return the results -pub pure fn map2(v0: &[T], v1: &[U], +pub fn map2(v0: &[T], v1: &[U], f: &fn(t: &T, v: &U) -> V) -> ~[V] { let v0_len = len(v0); if v0_len != len(v1) { fail!(); } @@ -860,7 +855,7 @@ pub fn filter_map( result } -pub pure fn filter_mapped( +pub fn filter_mapped( v: &[T], f: &fn(t: &T) -> Option) -> ~[U] { @@ -904,7 +899,7 @@ pub fn filter(v: ~[T], f: &fn(t: &T) -> bool) -> ~[T] { * Apply function `f` to each element of `v` and return a vector containing * only those elements for which `f` returned true. */ -pub pure fn filtered(v: &[T], f: &fn(t: &T) -> bool) -> ~[T] { +pub fn filtered(v: &[T], f: &fn(t: &T) -> bool) -> ~[T] { let mut result = ~[]; for each(v) |elem| { if f(elem) { unsafe { result.push(*elem); } } @@ -915,7 +910,7 @@ pub pure fn filtered(v: &[T], f: &fn(t: &T) -> bool) -> ~[T] { /** * Like `filter()`, but in place. Preserves order of `v`. Linear time. */ -pub fn retain(v: &mut ~[T], f: &pure fn(t: &T) -> bool) { +pub fn retain(v: &mut ~[T], f: &fn(t: &T) -> bool) { let len = v.len(); let mut deleted: uint = 0; @@ -937,14 +932,14 @@ pub fn retain(v: &mut ~[T], f: &pure fn(t: &T) -> bool) { * * Flattens a vector of vectors of T into a single vector of T. */ -pub pure fn concat(v: &[~[T]]) -> ~[T] { +pub fn concat(v: &[~[T]]) -> ~[T] { let mut r = ~[]; for each(v) |inner| { unsafe { r.push_all(*inner); } } r } /// Concatenate a vector of vectors, placing a given separator between each -pub pure fn connect(v: &[~[T]], sep: &T) -> ~[T] { +pub fn connect(v: &[~[T]], sep: &T) -> ~[T] { let mut r: ~[T] = ~[]; let mut first = true; for each(v) |inner| { @@ -971,7 +966,7 @@ pub pure fn connect(v: &[~[T]], sep: &T) -> ~[T] { * ~~~ * */ -pub pure fn foldl(z: T, v: &[U], p: &fn(t: T, u: &U) -> T) -> T { +pub fn foldl(z: T, v: &[U], p: &fn(t: T, u: &U) -> T) -> T { let mut accum = z; let mut i = 0; let l = v.len(); @@ -1003,7 +998,7 @@ pub pure fn foldl(z: T, v: &[U], p: &fn(t: T, u: &U) -> T) -> T { * ~~~ * */ -pub pure fn foldr(v: &[T], z: U, p: &fn(t: &T, u: U) -> U) -> U { +pub fn foldr(v: &[T], z: U, p: &fn(t: &T, u: U) -> U) -> U { let mut accum = z; for v.each_reverse |elt| { accum = p(elt, accum); @@ -1016,7 +1011,7 @@ pub pure fn foldr(v: &[T], z: U, p: &fn(t: &T, u: U) -> U) -> U { * * If the vector contains no elements then false is returned. */ -pub pure fn any(v: &[T], f: &fn(t: &T) -> bool) -> bool { +pub fn any(v: &[T], f: &fn(t: &T) -> bool) -> bool { for each(v) |elem| { if f(elem) { return true; } } false } @@ -1026,7 +1021,7 @@ pub pure fn any(v: &[T], f: &fn(t: &T) -> bool) -> bool { * * If the vectors contains no elements then false is returned. */ -pub pure fn any2(v0: &[T], v1: &[U], +pub fn any2(v0: &[T], v1: &[U], f: &fn(a: &T, b: &U) -> bool) -> bool { let v0_len = len(v0); let v1_len = len(v1); @@ -1043,7 +1038,7 @@ pub pure fn any2(v0: &[T], v1: &[U], * * If the vector contains no elements then true is returned. */ -pub pure fn all(v: &[T], f: &fn(t: &T) -> bool) -> bool { +pub fn all(v: &[T], f: &fn(t: &T) -> bool) -> bool { for each(v) |elem| { if !f(elem) { return false; } } true } @@ -1053,7 +1048,7 @@ pub pure fn all(v: &[T], f: &fn(t: &T) -> bool) -> bool { * * If the vector contains no elements then true is returned. */ -pub pure fn alli(v: &[T], f: &fn(uint, t: &T) -> bool) -> bool { +pub fn alli(v: &[T], f: &fn(uint, t: &T) -> bool) -> bool { for eachi(v) |i, elem| { if !f(i, elem) { return false; } } true } @@ -1063,7 +1058,7 @@ pub pure fn alli(v: &[T], f: &fn(uint, t: &T) -> bool) -> bool { * * If the vectors are not the same size then false is returned. */ -pub pure fn all2(v0: &[T], v1: &[U], +pub fn all2(v0: &[T], v1: &[U], f: &fn(t: &T, u: &U) -> bool) -> bool { let v0_len = len(v0); if v0_len != len(v1) { return false; } @@ -1073,13 +1068,13 @@ pub pure fn all2(v0: &[T], v1: &[U], } /// Return true if a vector contains an element with the given value -pub pure fn contains(v: &[T], x: &T) -> bool { +pub fn contains(v: &[T], x: &T) -> bool { for each(v) |elt| { if *x == *elt { return true; } } false } /// Returns the number of elements that are equal to a given value -pub pure fn count(v: &[T], x: &T) -> uint { +pub fn count(v: &[T], x: &T) -> uint { let mut cnt = 0u; for each(v) |elt| { if *x == *elt { cnt += 1u; } } cnt @@ -1092,7 +1087,7 @@ pub pure fn count(v: &[T], x: &T) -> uint { * When function `f` returns true then an option containing the element * is returned. If `f` matches no elements then none is returned. */ -pub pure fn find(v: &[T], f: &fn(t: &T) -> bool) -> Option { +pub fn find(v: &[T], f: &fn(t: &T) -> bool) -> Option { find_between(v, 0u, len(v), f) } @@ -1103,7 +1098,7 @@ pub pure fn find(v: &[T], f: &fn(t: &T) -> bool) -> Option { * [`start`, `end`). When function `f` returns true then an option containing * the element is returned. If `f` matches no elements then none is returned. */ -pub pure fn find_between(v: &[T], start: uint, end: uint, +pub fn find_between(v: &[T], start: uint, end: uint, f: &fn(t: &T) -> bool) -> Option { position_between(v, start, end, f).map(|i| v[*i]) } @@ -1115,7 +1110,7 @@ pub pure fn find_between(v: &[T], start: uint, end: uint, * `f` returns true then an option containing the element is returned. If `f` * matches no elements then none is returned. */ -pub pure fn rfind(v: &[T], f: &fn(t: &T) -> bool) -> Option { +pub fn rfind(v: &[T], f: &fn(t: &T) -> bool) -> Option { rfind_between(v, 0u, len(v), f) } @@ -1126,13 +1121,16 @@ pub pure fn rfind(v: &[T], f: &fn(t: &T) -> bool) -> Option { * [`start`, `end`). When function `f` returns true then an option containing * the element is returned. If `f` matches no elements then none is return. */ -pub pure fn rfind_between(v: &[T], start: uint, end: uint, - f: &fn(t: &T) -> bool) -> Option { +pub fn rfind_between(v: &[T], + start: uint, + end: uint, + f: &fn(t: &T) -> bool) + -> Option { rposition_between(v, start, end, f).map(|i| v[*i]) } /// Find the first index containing a matching value -pub pure fn position_elem(v: &[T], x: &T) -> Option { +pub fn position_elem(v: &[T], x: &T) -> Option { position(v, |y| *x == *y) } @@ -1143,7 +1141,7 @@ pub pure fn position_elem(v: &[T], x: &T) -> Option { * then an option containing the index is returned. If `f` matches no elements * then none is returned. */ -pub pure fn position(v: &[T], f: &fn(t: &T) -> bool) -> Option { +pub fn position(v: &[T], f: &fn(t: &T) -> bool) -> Option { position_between(v, 0u, len(v), f) } @@ -1154,8 +1152,11 @@ pub pure fn position(v: &[T], f: &fn(t: &T) -> bool) -> Option { * [`start`, `end`). When function `f` returns true then an option containing * the index is returned. If `f` matches no elements then none is returned. */ -pub pure fn position_between(v: &[T], start: uint, end: uint, - f: &fn(t: &T) -> bool) -> Option { +pub fn position_between(v: &[T], + start: uint, + end: uint, + f: &fn(t: &T) -> bool) + -> Option { fail_unless!(start <= end); fail_unless!(end <= len(v)); let mut i = start; @@ -1164,7 +1165,7 @@ pub pure fn position_between(v: &[T], start: uint, end: uint, } /// Find the last index containing a matching value -pure fn rposition_elem(v: &[T], x: &T) -> Option { +pub fn rposition_elem(v: &[T], x: &T) -> Option { rposition(v, |y| *x == *y) } @@ -1175,7 +1176,7 @@ pure fn rposition_elem(v: &[T], x: &T) -> Option { * `f` returns true then an option containing the index is returned. If `f` * matches no elements then none is returned. */ -pub pure fn rposition(v: &[T], f: &fn(t: &T) -> bool) -> Option { +pub fn rposition(v: &[T], f: &fn(t: &T) -> bool) -> Option { rposition_between(v, 0u, len(v), f) } @@ -1187,7 +1188,7 @@ pub pure fn rposition(v: &[T], f: &fn(t: &T) -> bool) -> Option { * containing the index is returned. If `f` matches no elements then none is * returned. */ -pub pure fn rposition_between(v: &[T], start: uint, end: uint, +pub fn rposition_between(v: &[T], start: uint, end: uint, f: &fn(t: &T) -> bool) -> Option { fail_unless!(start <= end); fail_unless!(end <= len(v)); @@ -1206,7 +1207,7 @@ pub pure fn rposition_between(v: &[T], start: uint, end: uint, /** * Convert a vector of pairs into a pair of vectors, by reference. As unzip(). */ -pure fn unzip_slice(v: &[(T, U)]) -> (~[T], ~[U]) { +pub fn unzip_slice(v: &[(T, U)]) -> (~[T], ~[U]) { let mut ts = ~[], us = ~[]; for each(v) |p| { let (t, u) = *p; @@ -1226,7 +1227,7 @@ pure fn unzip_slice(v: &[(T, U)]) -> (~[T], ~[U]) { * and the i-th element of the second vector contains the second element * of the i-th tuple of the input vector. */ -pub pure fn unzip(v: ~[(T, U)]) -> (~[T], ~[U]) { +pub fn unzip(v: ~[(T, U)]) -> (~[T], ~[U]) { let mut ts = ~[], us = ~[]; unsafe { do consume(v) |_i, p| { @@ -1241,7 +1242,7 @@ pub pure fn unzip(v: ~[(T, U)]) -> (~[T], ~[U]) { /** * Convert two vectors to a vector of pairs, by reference. As zip(). */ -pub pure fn zip_slice(v: &[const T], u: &[const U]) +pub fn zip_slice(v: &[const T], u: &[const U]) -> ~[(T, U)] { let mut zipped = ~[]; let sz = len(v); @@ -1259,7 +1260,7 @@ pub pure fn zip_slice(v: &[const T], u: &[const U]) * Returns a vector of tuples, where the i-th tuple contains contains the * i-th elements from each of the input vectors. */ -pub pure fn zip(mut v: ~[T], mut u: ~[U]) -> ~[(T, U)] { +pub fn zip(mut v: ~[T], mut u: ~[U]) -> ~[(T, U)] { let mut i = len(v); fail_unless!(i == len(u)); let mut w = with_capacity(i); @@ -1292,7 +1293,7 @@ pub fn reverse(v: &mut [T]) { } /// Returns a vector with the order of elements reversed -pub pure fn reversed(v: &[const T]) -> ~[T] { +pub fn reversed(v: &[const T]) -> ~[T] { let mut rs: ~[T] = ~[]; let mut i = len::(v); if i == 0 { return (rs); } else { i -= 1; } @@ -1342,7 +1343,7 @@ pub pure fn reversed(v: &[const T]) -> ~[T] { * ~~~ */ #[inline(always)] -pub pure fn each(v: &'r [T], f: &fn(&'r T) -> bool) { +pub fn each(v: &'r [T], f: &fn(&'r T) -> bool) { // ^^^^ // NB---this CANNOT be &[const T]! The reason // is that you are passing it to `f()` using @@ -1380,7 +1381,7 @@ pub fn each_mut(v: &'r mut [T], f: &fn(elem: &'r mut T) -> bool) { /// Like `each()`, but for the case where you have a vector that *may or may /// not* have mutable contents. #[inline(always)] -pub pure fn each_const(v: &[const T], f: &fn(elem: &const T) -> bool) { +pub fn each_const(v: &[const T], f: &fn(elem: &const T) -> bool) { let mut i = 0; let n = v.len(); while i < n { @@ -1397,7 +1398,7 @@ pub pure fn each_const(v: &[const T], f: &fn(elem: &const T) -> bool) { * Return true to continue, false to break. */ #[inline(always)] -pub pure fn eachi(v: &'r [T], f: &fn(uint, v: &'r T) -> bool) { +pub fn eachi(v: &'r [T], f: &fn(uint, v: &'r T) -> bool) { let mut i = 0; for each(v) |p| { if !f(i, p) { return; } @@ -1411,7 +1412,7 @@ pub pure fn eachi(v: &'r [T], f: &fn(uint, v: &'r T) -> bool) { * Return true to continue, false to break. */ #[inline(always)] -pub pure fn each_reverse(v: &'r [T], blk: &fn(v: &'r T) -> bool) { +pub fn each_reverse(v: &'r [T], blk: &fn(v: &'r T) -> bool) { eachi_reverse(v, |_i, v| blk(v)) } @@ -1421,7 +1422,7 @@ pub pure fn each_reverse(v: &'r [T], blk: &fn(v: &'r T) -> bool) { * Return true to continue, false to break. */ #[inline(always)] -pub pure fn eachi_reverse(v: &'r [T], blk: &fn(i: uint, v: &'r T) -> bool) { +pub fn eachi_reverse(v: &'r [T], blk: &fn(i: uint, v: &'r T) -> bool) { let mut i = v.len(); while i > 0 { i -= 1; @@ -1439,7 +1440,7 @@ pub pure fn eachi_reverse(v: &'r [T], blk: &fn(i: uint, v: &'r T) -> bool) { * Both vectors must have the same length */ #[inline] -pub pure fn each2(v1: &[U], v2: &[T], f: &fn(u: &U, t: &T) -> bool) { +pub fn each2(v1: &[U], v2: &[T], f: &fn(u: &U, t: &T) -> bool) { fail_unless!(len(v1) == len(v2)); for uint::range(0u, len(v1)) |i| { if !f(&v1[i], &v2[i]) { @@ -1458,7 +1459,7 @@ pub pure fn each2(v1: &[U], v2: &[T], f: &fn(u: &U, t: &T) -> bool) { * The total number of permutations produced is `len(v)!`. If `v` contains * repeated elements, then some permutations are repeated. */ -pub pure fn each_permutation(v: &[T], put: &fn(ts: &[T]) -> bool) { +pub fn each_permutation(v: &[T], put: &fn(ts: &[T]) -> bool) { let ln = len(v); if ln <= 1 { put(v); @@ -1482,7 +1483,7 @@ pub pure fn each_permutation(v: &[T], put: &fn(ts: &[T]) -> bool) { } } -pub pure fn windowed(nn: uint, xx: &[TT]) -> ~[~[TT]] { +pub fn windowed(nn: uint, xx: &[TT]) -> ~[~[TT]] { let mut ww = ~[]; fail_unless!(1u <= nn); for vec::eachi (xx) |ii, _x| { @@ -1503,9 +1504,9 @@ pub pure fn windowed(nn: uint, xx: &[TT]) -> ~[~[TT]] { * foreign interop. */ #[inline(always)] -pub pure fn as_imm_buf(s: &[T], - /* NB---this CANNOT be const, see below */ - f: &fn(*T, uint) -> U) -> U { +pub fn as_imm_buf(s: &[T], + /* NB---this CANNOT be const, see below */ + f: &fn(*T, uint) -> U) -> U { // NB---Do not change the type of s to `&[const T]`. This is // unsound. The reason is that we are going to create immutable pointers @@ -1523,9 +1524,7 @@ pub pure fn as_imm_buf(s: &[T], /// Similar to `as_imm_buf` but passing a `*const T` #[inline(always)] -pub pure fn as_const_buf(s: &[const T], - f: &fn(*const T, uint) -> U) -> U { - +pub fn as_const_buf(s: &[const T], f: &fn(*const T, uint) -> U) -> U { unsafe { let v : *(*const T,uint) = ::cast::reinterpret_cast(&addr_of(&s)); @@ -1536,9 +1535,7 @@ pub pure fn as_const_buf(s: &[const T], /// Similar to `as_imm_buf` but passing a `*mut T` #[inline(always)] -pub pure fn as_mut_buf(s: &mut [T], - f: &fn(*mut T, uint) -> U) -> U { - +pub fn as_mut_buf(s: &mut [T], f: &fn(*mut T, uint) -> U) -> U { unsafe { let v : *(*mut T,uint) = ::cast::reinterpret_cast(&addr_of(&s)); @@ -1549,7 +1546,7 @@ pub pure fn as_mut_buf(s: &mut [T], // Equality -pure fn eq(a: &[T], b: &[T]) -> bool { +fn eq(a: &[T], b: &[T]) -> bool { let (a_len, b_len) = (a.len(), b.len()); if a_len != b_len { return false; } @@ -1565,37 +1562,37 @@ pure fn eq(a: &[T], b: &[T]) -> bool { #[cfg(notest)] impl Eq for &'self [T] { #[inline(always)] - pure fn eq(&self, other: & &'self [T]) -> bool { eq((*self), (*other)) } + fn eq(&self, other: & &'self [T]) -> bool { eq((*self), (*other)) } #[inline(always)] - pure fn ne(&self, other: & &'self [T]) -> bool { !(*self).eq(other) } + fn ne(&self, other: & &'self [T]) -> bool { !(*self).eq(other) } } #[cfg(notest)] impl Eq for ~[T] { #[inline(always)] - pure fn eq(&self, other: &~[T]) -> bool { eq((*self), (*other)) } + fn eq(&self, other: &~[T]) -> bool { eq((*self), (*other)) } #[inline(always)] - pure fn ne(&self, other: &~[T]) -> bool { !(*self).eq(other) } + fn ne(&self, other: &~[T]) -> bool { !(*self).eq(other) } } #[cfg(notest)] impl Eq for @[T] { #[inline(always)] - pure fn eq(&self, other: &@[T]) -> bool { eq((*self), (*other)) } + fn eq(&self, other: &@[T]) -> bool { eq((*self), (*other)) } #[inline(always)] - pure fn ne(&self, other: &@[T]) -> bool { !(*self).eq(other) } + fn ne(&self, other: &@[T]) -> bool { !(*self).eq(other) } } #[cfg(notest)] impl Equiv<~[T]> for &'self [T] { #[inline(always)] - pure fn equiv(&self, other: &~[T]) -> bool { eq(*self, *other) } + fn equiv(&self, other: &~[T]) -> bool { eq(*self, *other) } } // Lexicographical comparison -pure fn cmp(a: &[T], b: &[T]) -> Ordering { +fn cmp(a: &[T], b: &[T]) -> Ordering { let low = uint::min(a.len(), b.len()); for uint::range(0, low) |idx| { @@ -1612,22 +1609,22 @@ pure fn cmp(a: &[T], b: &[T]) -> Ordering { #[cfg(notest)] impl TotalOrd for &'self [T] { #[inline(always)] - pure fn cmp(&self, other: & &'self [T]) -> Ordering { cmp(*self, *other) } + fn cmp(&self, other: & &'self [T]) -> Ordering { cmp(*self, *other) } } #[cfg(notest)] impl TotalOrd for ~[T] { #[inline(always)] - pure fn cmp(&self, other: &~[T]) -> Ordering { cmp(*self, *other) } + fn cmp(&self, other: &~[T]) -> Ordering { cmp(*self, *other) } } #[cfg(notest)] impl TotalOrd for @[T] { #[inline(always)] - pure fn cmp(&self, other: &@[T]) -> Ordering { cmp(*self, *other) } + fn cmp(&self, other: &@[T]) -> Ordering { cmp(*self, *other) } } -pure fn lt(a: &[T], b: &[T]) -> bool { +fn lt(a: &[T], b: &[T]) -> bool { let (a_len, b_len) = (a.len(), b.len()); let mut end = uint::min(a_len, b_len); @@ -1642,44 +1639,44 @@ pure fn lt(a: &[T], b: &[T]) -> bool { a_len < b_len } -pure fn le(a: &[T], b: &[T]) -> bool { !lt(b, a) } -pure fn ge(a: &[T], b: &[T]) -> bool { !lt(a, b) } -pure fn gt(a: &[T], b: &[T]) -> bool { lt(b, a) } +fn le(a: &[T], b: &[T]) -> bool { !lt(b, a) } +fn ge(a: &[T], b: &[T]) -> bool { !lt(a, b) } +fn gt(a: &[T], b: &[T]) -> bool { lt(b, a) } #[cfg(notest)] impl Ord for &'self [T] { #[inline(always)] - pure fn lt(&self, other: & &'self [T]) -> bool { lt((*self), (*other)) } + fn lt(&self, other: & &'self [T]) -> bool { lt((*self), (*other)) } #[inline(always)] - pure fn le(&self, other: & &'self [T]) -> bool { le((*self), (*other)) } + fn le(&self, other: & &'self [T]) -> bool { le((*self), (*other)) } #[inline(always)] - pure fn ge(&self, other: & &'self [T]) -> bool { ge((*self), (*other)) } + fn ge(&self, other: & &'self [T]) -> bool { ge((*self), (*other)) } #[inline(always)] - pure fn gt(&self, other: & &'self [T]) -> bool { gt((*self), (*other)) } + fn gt(&self, other: & &'self [T]) -> bool { gt((*self), (*other)) } } #[cfg(notest)] impl Ord for ~[T] { #[inline(always)] - pure fn lt(&self, other: &~[T]) -> bool { lt((*self), (*other)) } + fn lt(&self, other: &~[T]) -> bool { lt((*self), (*other)) } #[inline(always)] - pure fn le(&self, other: &~[T]) -> bool { le((*self), (*other)) } + fn le(&self, other: &~[T]) -> bool { le((*self), (*other)) } #[inline(always)] - pure fn ge(&self, other: &~[T]) -> bool { ge((*self), (*other)) } + fn ge(&self, other: &~[T]) -> bool { ge((*self), (*other)) } #[inline(always)] - pure fn gt(&self, other: &~[T]) -> bool { gt((*self), (*other)) } + fn gt(&self, other: &~[T]) -> bool { gt((*self), (*other)) } } #[cfg(notest)] impl Ord for @[T] { #[inline(always)] - pure fn lt(&self, other: &@[T]) -> bool { lt((*self), (*other)) } + fn lt(&self, other: &@[T]) -> bool { lt((*self), (*other)) } #[inline(always)] - pure fn le(&self, other: &@[T]) -> bool { le((*self), (*other)) } + fn le(&self, other: &@[T]) -> bool { le((*self), (*other)) } #[inline(always)] - pure fn ge(&self, other: &@[T]) -> bool { ge((*self), (*other)) } + fn ge(&self, other: &@[T]) -> bool { ge((*self), (*other)) } #[inline(always)] - pure fn gt(&self, other: &@[T]) -> bool { gt((*self), (*other)) } + fn gt(&self, other: &@[T]) -> bool { gt((*self), (*other)) } } #[cfg(notest)] @@ -1690,7 +1687,7 @@ pub mod traits { impl Add<&'self [const T],~[T]> for ~[T] { #[inline(always)] - pure fn add(&self, rhs: & &'self [const T]) -> ~[T] { + fn add(&self, rhs: & &'self [const T]) -> ~[T] { append(copy *self, (*rhs)) } } @@ -1699,22 +1696,22 @@ pub mod traits { impl Container for &'self [const T] { /// Returns true if a vector contains no elements #[inline] - pure fn is_empty(&const self) -> bool { is_empty(*self) } + fn is_empty(&const self) -> bool { is_empty(*self) } /// Returns the length of a vector #[inline] - pure fn len(&const self) -> uint { len(*self) } + fn len(&const self) -> uint { len(*self) } } pub trait CopyableVector { - pure fn to_owned(&self) -> ~[T]; + fn to_owned(&self) -> ~[T]; } /// Extension methods for vectors impl CopyableVector for &'self [const T] { /// Returns a copy of `v`. #[inline] - pure fn to_owned(&self) -> ~[T] { + fn to_owned(&self) -> ~[T] { let mut result = ~[]; // FIXME: #4568 unsafe { @@ -1729,93 +1726,93 @@ impl CopyableVector for &'self [const T] { } pub trait ImmutableVector { - pure fn slice(&self, start: uint, end: uint) -> &'self [T]; - pure fn head(&self) -> &'self T; - pure fn head_opt(&self) -> Option<&'self T>; - pure fn tail(&self) -> &'self [T]; - pure fn tailn(&self, n: uint) -> &'self [T]; - pure fn init(&self) -> &'self [T]; - pure fn initn(&self, n: uint) -> &'self [T]; - pure fn last(&self) -> &'self T; - pure fn last_opt(&self) -> Option<&'self T>; - pure fn each_reverse(&self, blk: &fn(&T) -> bool); - pure fn eachi_reverse(&self, blk: &fn(uint, &T) -> bool); - pure fn foldr(&self, z: U, p: &fn(t: &T, u: U) -> U) -> U; - pure fn map(&self, f: &fn(t: &T) -> U) -> ~[U]; - pure fn mapi(&self, f: &fn(uint, t: &T) -> U) -> ~[U]; + fn slice(&self, start: uint, end: uint) -> &'self [T]; + fn head(&self) -> &'self T; + fn head_opt(&self) -> Option<&'self T>; + fn tail(&self) -> &'self [T]; + fn tailn(&self, n: uint) -> &'self [T]; + fn init(&self) -> &'self [T]; + fn initn(&self, n: uint) -> &'self [T]; + fn last(&self) -> &'self T; + fn last_opt(&self) -> Option<&'self T>; + fn each_reverse(&self, blk: &fn(&T) -> bool); + fn eachi_reverse(&self, blk: &fn(uint, &T) -> bool); + fn foldr(&self, z: U, p: &fn(t: &T, u: U) -> U) -> U; + fn map(&self, f: &fn(t: &T) -> U) -> ~[U]; + fn mapi(&self, f: &fn(uint, t: &T) -> U) -> ~[U]; fn map_r(&self, f: &fn(x: &T) -> U) -> ~[U]; - pure fn alli(&self, f: &fn(uint, t: &T) -> bool) -> bool; - pure fn flat_map(&self, f: &fn(t: &T) -> ~[U]) -> ~[U]; - pure fn filter_mapped(&self, f: &fn(t: &T) -> Option) -> ~[U]; + fn alli(&self, f: &fn(uint, t: &T) -> bool) -> bool; + fn flat_map(&self, f: &fn(t: &T) -> ~[U]) -> ~[U]; + fn filter_mapped(&self, f: &fn(t: &T) -> Option) -> ~[U]; } /// Extension methods for vectors impl ImmutableVector for &'self [T] { /// Return a slice that points into another slice. #[inline] - pure fn slice(&self, start: uint, end: uint) -> &'self [T] { + fn slice(&self, start: uint, end: uint) -> &'self [T] { slice(*self, start, end) } /// Returns the first element of a vector, failing if the vector is empty. #[inline] - pure fn head(&self) -> &'self T { head(*self) } + fn head(&self) -> &'self T { head(*self) } /// Returns the first element of a vector #[inline] - pure fn head_opt(&self) -> Option<&'self T> { head_opt(*self) } + fn head_opt(&self) -> Option<&'self T> { head_opt(*self) } /// Returns all but the first element of a vector #[inline] - pure fn tail(&self) -> &'self [T] { tail(*self) } + fn tail(&self) -> &'self [T] { tail(*self) } /// Returns all but the first `n' elements of a vector #[inline] - pure fn tailn(&self, n: uint) -> &'self [T] { tailn(*self, n) } + fn tailn(&self, n: uint) -> &'self [T] { tailn(*self, n) } /// Returns all but the last elemnt of a vector #[inline] - pure fn init(&self) -> &'self [T] { init(*self) } + fn init(&self) -> &'self [T] { init(*self) } /// Returns all but the last `n' elemnts of a vector #[inline] - pure fn initn(&self, n: uint) -> &'self [T] { initn(*self, n) } + fn initn(&self, n: uint) -> &'self [T] { initn(*self, n) } /// Returns the last element of a `v`, failing if the vector is empty. #[inline] - pure fn last(&self) -> &'self T { last(*self) } + fn last(&self) -> &'self T { last(*self) } /// Returns the last element of a `v`, failing if the vector is empty. #[inline] - pure fn last_opt(&self) -> Option<&'self T> { last_opt(*self) } + fn last_opt(&self) -> Option<&'self T> { last_opt(*self) } /// Iterates over a vector's elements in reverse. #[inline] - pure fn each_reverse(&self, blk: &fn(&T) -> bool) { + fn each_reverse(&self, blk: &fn(&T) -> bool) { each_reverse(*self, blk) } /// Iterates over a vector's elements and indices in reverse. #[inline] - pure fn eachi_reverse(&self, blk: &fn(uint, &T) -> bool) { + fn eachi_reverse(&self, blk: &fn(uint, &T) -> bool) { eachi_reverse(*self, blk) } /// Reduce a vector from right to left #[inline] - pure fn foldr(&self, z: U, p: &fn(t: &T, u: U) -> U) -> U { + fn foldr(&self, z: U, p: &fn(t: &T, u: U) -> U) -> U { foldr(*self, z, p) } /// Apply a function to each element of a vector and return the results #[inline] - pure fn map(&self, f: &fn(t: &T) -> U) -> ~[U] { map(*self, f) } + fn map(&self, f: &fn(t: &T) -> U) -> ~[U] { map(*self, f) } /** * Apply a function to the index and value of each element in the vector * and return the results */ - pure fn mapi(&self, f: &fn(uint, t: &T) -> U) -> ~[U] { + fn mapi(&self, f: &fn(uint, t: &T) -> U) -> ~[U] { mapi(*self, f) } @@ -1835,7 +1832,7 @@ impl ImmutableVector for &'self [T] { * * If the vector is empty, true is returned. */ - pure fn alli(&self, f: &fn(uint, t: &T) -> bool) -> bool { + fn alli(&self, f: &fn(uint, t: &T) -> bool) -> bool { alli(*self, f) } /** @@ -1843,7 +1840,7 @@ impl ImmutableVector for &'self [T] { * of each result vector */ #[inline] - pure fn flat_map(&self, f: &fn(t: &T) -> ~[U]) -> ~[U] { + fn flat_map(&self, f: &fn(t: &T) -> ~[U]) -> ~[U] { flat_map(*self, f) } /** @@ -1853,16 +1850,16 @@ impl ImmutableVector for &'self [T] { * the resulting vector. */ #[inline] - pure fn filter_mapped(&self, f: &fn(t: &T) -> Option) -> ~[U] { + fn filter_mapped(&self, f: &fn(t: &T) -> Option) -> ~[U] { filter_mapped(*self, f) } } pub trait ImmutableEqVector { - pure fn position(&self, f: &fn(t: &T) -> bool) -> Option; - pure fn position_elem(&self, t: &T) -> Option; - pure fn rposition(&self, f: &fn(t: &T) -> bool) -> Option; - pure fn rposition_elem(&self, t: &T) -> Option; + fn position(&self, f: &fn(t: &T) -> bool) -> Option; + fn position_elem(&self, t: &T) -> Option; + fn rposition(&self, f: &fn(t: &T) -> bool) -> Option; + fn rposition_elem(&self, t: &T) -> Option; } impl ImmutableEqVector for &'self [T] { @@ -1874,13 +1871,13 @@ impl ImmutableEqVector for &'self [T] { * elements then none is returned. */ #[inline] - pure fn position(&self, f: &fn(t: &T) -> bool) -> Option { + fn position(&self, f: &fn(t: &T) -> bool) -> Option { position(*self, f) } /// Find the first index containing a matching value #[inline] - pure fn position_elem(&self, x: &T) -> Option { + fn position_elem(&self, x: &T) -> Option { position_elem(*self, x) } @@ -1892,21 +1889,21 @@ impl ImmutableEqVector for &'self [T] { * returned. If `f` matches no elements then none is returned. */ #[inline] - pure fn rposition(&self, f: &fn(t: &T) -> bool) -> Option { + fn rposition(&self, f: &fn(t: &T) -> bool) -> Option { rposition(*self, f) } /// Find the last index containing a matching value #[inline] - pure fn rposition_elem(&self, t: &T) -> Option { + fn rposition_elem(&self, t: &T) -> Option { rposition_elem(*self, t) } } pub trait ImmutableCopyableVector { - pure fn filtered(&self, f: &fn(&T) -> bool) -> ~[T]; - pure fn rfind(&self, f: &fn(t: &T) -> bool) -> Option; - pure fn partitioned(&self, f: &fn(&T) -> bool) -> (~[T], ~[T]); + fn filtered(&self, f: &fn(&T) -> bool) -> ~[T]; + fn rfind(&self, f: &fn(t: &T) -> bool) -> Option; + fn partitioned(&self, f: &fn(&T) -> bool) -> (~[T], ~[T]); } /// Extension methods for vectors @@ -1919,7 +1916,7 @@ impl ImmutableCopyableVector for &'self [T] { * containing only those elements for which `f` returned true. */ #[inline] - pure fn filtered(&self, f: &fn(t: &T) -> bool) -> ~[T] { + fn filtered(&self, f: &fn(t: &T) -> bool) -> ~[T] { filtered(*self, f) } @@ -1931,7 +1928,7 @@ impl ImmutableCopyableVector for &'self [T] { * returned. If `f` matches no elements then none is returned. */ #[inline] - pure fn rfind(&self, f: &fn(t: &T) -> bool) -> Option { + fn rfind(&self, f: &fn(t: &T) -> bool) -> Option { rfind(*self, f) } @@ -1940,7 +1937,7 @@ impl ImmutableCopyableVector for &'self [T] { * those that do not. */ #[inline] - pure fn partitioned(&self, f: &fn(&T) -> bool) -> (~[T], ~[T]) { + fn partitioned(&self, f: &fn(&T) -> bool) -> (~[T], ~[T]) { partitioned(*self, f) } } @@ -1955,10 +1952,10 @@ pub trait OwnedVector { fn remove(&mut self, i: uint) -> T; fn swap_remove(&mut self, index: uint) -> T; fn truncate(&mut self, newlen: uint); - fn retain(&mut self, f: &pure fn(t: &T) -> bool); + fn retain(&mut self, f: &fn(t: &T) -> bool); fn consume(self, f: &fn(uint, v: T)); fn filter(self, f: &fn(t: &T) -> bool) -> ~[T]; - fn partition(self, f: &pure fn(&T) -> bool) -> (~[T], ~[T]); + fn partition(self, f: &fn(&T) -> bool) -> (~[T], ~[T]); fn grow_fn(&mut self, n: uint, op: iter::InitOp); } @@ -2009,7 +2006,7 @@ impl OwnedVector for ~[T] { } #[inline] - fn retain(&mut self, f: &pure fn(t: &T) -> bool) { + fn retain(&mut self, f: &fn(t: &T) -> bool) { retain(self, f); } @@ -2258,7 +2255,7 @@ pub mod bytes { use vec; /// Bytewise string comparison - pub pure fn memcmp(a: &~[u8], b: &~[u8]) -> int { + pub fn memcmp(a: &~[u8], b: &~[u8]) -> int { let a_len = a.len(); let b_len = b.len(); let n = uint::min(a_len, b_len) as libc::size_t; @@ -2279,22 +2276,22 @@ pub mod bytes { } /// Bytewise less than or equal - pub pure fn lt(a: &~[u8], b: &~[u8]) -> bool { memcmp(a, b) < 0 } + pub fn lt(a: &~[u8], b: &~[u8]) -> bool { memcmp(a, b) < 0 } /// Bytewise less than or equal - pub pure fn le(a: &~[u8], b: &~[u8]) -> bool { memcmp(a, b) <= 0 } + pub fn le(a: &~[u8], b: &~[u8]) -> bool { memcmp(a, b) <= 0 } /// Bytewise equality - pub pure fn eq(a: &~[u8], b: &~[u8]) -> bool { memcmp(a, b) == 0 } + pub fn eq(a: &~[u8], b: &~[u8]) -> bool { memcmp(a, b) == 0 } /// Bytewise inequality - pub pure fn ne(a: &~[u8], b: &~[u8]) -> bool { memcmp(a, b) != 0 } + pub fn ne(a: &~[u8], b: &~[u8]) -> bool { memcmp(a, b) != 0 } /// Bytewise greater than or equal - pub pure fn ge(a: &~[u8], b: &~[u8]) -> bool { memcmp(a, b) >= 0 } + pub fn ge(a: &~[u8], b: &~[u8]) -> bool { memcmp(a, b) >= 0 } /// Bytewise greater than - pub pure fn gt(a: &~[u8], b: &~[u8]) -> bool { memcmp(a, b) > 0 } + pub fn gt(a: &~[u8], b: &~[u8]) -> bool { memcmp(a, b) > 0 } /** * Copies data from one vector to another. @@ -2314,25 +2311,25 @@ pub mod bytes { impl iter::BaseIter for &'self [A] { #[inline(always)] - pure fn each(&self, blk: &fn(v: &'self A) -> bool) { each(*self, blk) } + fn each(&self, blk: &fn(v: &'self A) -> bool) { each(*self, blk) } #[inline(always)] - pure fn size_hint(&self) -> Option { Some(self.len()) } + fn size_hint(&self) -> Option { Some(self.len()) } } // FIXME(#4148): This should be redundant impl iter::BaseIter for ~[A] { #[inline(always)] - pure fn each(&self, blk: &fn(v: &'self A) -> bool) { each(*self, blk) } + fn each(&self, blk: &fn(v: &'self A) -> bool) { each(*self, blk) } #[inline(always)] - pure fn size_hint(&self) -> Option { Some(self.len()) } + fn size_hint(&self) -> Option { Some(self.len()) } } // FIXME(#4148): This should be redundant impl iter::BaseIter for @[A] { #[inline(always)] - pure fn each(&self, blk: &fn(v: &'self A) -> bool) { each(*self, blk) } + fn each(&self, blk: &fn(v: &'self A) -> bool) { each(*self, blk) } #[inline(always)] - pure fn size_hint(&self) -> Option { Some(self.len()) } + fn size_hint(&self) -> Option { Some(self.len()) } } impl iter::MutableIter for &'self mut [A] { @@ -2359,25 +2356,25 @@ impl iter::MutableIter for @mut [A] { } impl iter::ExtendedIter for &'self [A] { - pub pure fn eachi(&self, blk: &fn(uint, v: &A) -> bool) { + pub fn eachi(&self, blk: &fn(uint, v: &A) -> bool) { iter::eachi(self, blk) } - pub pure fn all(&self, blk: &fn(&A) -> bool) -> bool { + pub fn all(&self, blk: &fn(&A) -> bool) -> bool { iter::all(self, blk) } - pub pure fn any(&self, blk: &fn(&A) -> bool) -> bool { + pub fn any(&self, blk: &fn(&A) -> bool) -> bool { iter::any(self, blk) } - pub pure fn foldl(&self, b0: B, blk: &fn(&B, &A) -> B) -> B { + pub fn foldl(&self, b0: B, blk: &fn(&B, &A) -> B) -> B { iter::foldl(self, b0, blk) } - pub pure fn position(&self, f: &fn(&A) -> bool) -> Option { + pub fn position(&self, f: &fn(&A) -> bool) -> Option { iter::position(self, f) } - pure fn map_to_vec(&self, op: &fn(&A) -> B) -> ~[B] { + fn map_to_vec(&self, op: &fn(&A) -> B) -> ~[B] { iter::map_to_vec(self, op) } - pure fn flat_map_to_vec>(&self, op: &fn(&A) -> IB) + fn flat_map_to_vec>(&self, op: &fn(&A) -> IB) -> ~[B] { iter::flat_map_to_vec(self, op) } @@ -2385,25 +2382,25 @@ impl iter::ExtendedIter for &'self [A] { // FIXME(#4148): This should be redundant impl iter::ExtendedIter for ~[A] { - pub pure fn eachi(&self, blk: &fn(uint, v: &A) -> bool) { + pub fn eachi(&self, blk: &fn(uint, v: &A) -> bool) { iter::eachi(self, blk) } - pub pure fn all(&self, blk: &fn(&A) -> bool) -> bool { + pub fn all(&self, blk: &fn(&A) -> bool) -> bool { iter::all(self, blk) } - pub pure fn any(&self, blk: &fn(&A) -> bool) -> bool { + pub fn any(&self, blk: &fn(&A) -> bool) -> bool { iter::any(self, blk) } - pub pure fn foldl(&self, b0: B, blk: &fn(&B, &A) -> B) -> B { + pub fn foldl(&self, b0: B, blk: &fn(&B, &A) -> B) -> B { iter::foldl(self, b0, blk) } - pub pure fn position(&self, f: &fn(&A) -> bool) -> Option { + pub fn position(&self, f: &fn(&A) -> bool) -> Option { iter::position(self, f) } - pure fn map_to_vec(&self, op: &fn(&A) -> B) -> ~[B] { + fn map_to_vec(&self, op: &fn(&A) -> B) -> ~[B] { iter::map_to_vec(self, op) } - pure fn flat_map_to_vec>(&self, op: &fn(&A) -> IB) + fn flat_map_to_vec>(&self, op: &fn(&A) -> IB) -> ~[B] { iter::flat_map_to_vec(self, op) } @@ -2411,98 +2408,98 @@ impl iter::ExtendedIter for ~[A] { // FIXME(#4148): This should be redundant impl iter::ExtendedIter for @[A] { - pub pure fn eachi(&self, blk: &fn(uint, v: &A) -> bool) { + pub fn eachi(&self, blk: &fn(uint, v: &A) -> bool) { iter::eachi(self, blk) } - pub pure fn all(&self, blk: &fn(&A) -> bool) -> bool { + pub fn all(&self, blk: &fn(&A) -> bool) -> bool { iter::all(self, blk) } - pub pure fn any(&self, blk: &fn(&A) -> bool) -> bool { + pub fn any(&self, blk: &fn(&A) -> bool) -> bool { iter::any(self, blk) } - pub pure fn foldl(&self, b0: B, blk: &fn(&B, &A) -> B) -> B { + pub fn foldl(&self, b0: B, blk: &fn(&B, &A) -> B) -> B { iter::foldl(self, b0, blk) } - pub pure fn position(&self, f: &fn(&A) -> bool) -> Option { + pub fn position(&self, f: &fn(&A) -> bool) -> Option { iter::position(self, f) } - pure fn map_to_vec(&self, op: &fn(&A) -> B) -> ~[B] { + fn map_to_vec(&self, op: &fn(&A) -> B) -> ~[B] { iter::map_to_vec(self, op) } - pure fn flat_map_to_vec>(&self, op: &fn(&A) -> IB) + fn flat_map_to_vec>(&self, op: &fn(&A) -> IB) -> ~[B] { iter::flat_map_to_vec(self, op) } } impl iter::EqIter for &'self [A] { - pub pure fn contains(&self, x: &A) -> bool { iter::contains(self, x) } - pub pure fn count(&self, x: &A) -> uint { iter::count(self, x) } + pub fn contains(&self, x: &A) -> bool { iter::contains(self, x) } + pub fn count(&self, x: &A) -> uint { iter::count(self, x) } } // FIXME(#4148): This should be redundant impl iter::EqIter for ~[A] { - pub pure fn contains(&self, x: &A) -> bool { iter::contains(self, x) } - pub pure fn count(&self, x: &A) -> uint { iter::count(self, x) } + pub fn contains(&self, x: &A) -> bool { iter::contains(self, x) } + pub fn count(&self, x: &A) -> uint { iter::count(self, x) } } // FIXME(#4148): This should be redundant impl iter::EqIter for @[A] { - pub pure fn contains(&self, x: &A) -> bool { iter::contains(self, x) } - pub pure fn count(&self, x: &A) -> uint { iter::count(self, x) } + pub fn contains(&self, x: &A) -> bool { iter::contains(self, x) } + pub fn count(&self, x: &A) -> uint { iter::count(self, x) } } impl iter::CopyableIter for &'self [A] { - pure fn filter_to_vec(&self, pred: &fn(&A) -> bool) -> ~[A] { + fn filter_to_vec(&self, pred: &fn(&A) -> bool) -> ~[A] { iter::filter_to_vec(self, pred) } - pure fn to_vec(&self) -> ~[A] { iter::to_vec(self) } - pub pure fn find(&self, f: &fn(&A) -> bool) -> Option { + fn to_vec(&self) -> ~[A] { iter::to_vec(self) } + pub fn find(&self, f: &fn(&A) -> bool) -> Option { iter::find(self, f) } } // FIXME(#4148): This should be redundant impl iter::CopyableIter for ~[A] { - pure fn filter_to_vec(&self, pred: &fn(&A) -> bool) -> ~[A] { + fn filter_to_vec(&self, pred: &fn(&A) -> bool) -> ~[A] { iter::filter_to_vec(self, pred) } - pure fn to_vec(&self) -> ~[A] { iter::to_vec(self) } - pub pure fn find(&self, f: &fn(&A) -> bool) -> Option { + fn to_vec(&self) -> ~[A] { iter::to_vec(self) } + pub fn find(&self, f: &fn(&A) -> bool) -> Option { iter::find(self, f) } } // FIXME(#4148): This should be redundant impl iter::CopyableIter for @[A] { - pure fn filter_to_vec(&self, pred: &fn(&A) -> bool) -> ~[A] { + fn filter_to_vec(&self, pred: &fn(&A) -> bool) -> ~[A] { iter::filter_to_vec(self, pred) } - pure fn to_vec(&self) -> ~[A] { iter::to_vec(self) } - pub pure fn find(&self, f: &fn(&A) -> bool) -> Option { + fn to_vec(&self) -> ~[A] { iter::to_vec(self) } + pub fn find(&self, f: &fn(&A) -> bool) -> Option { iter::find(self, f) } } impl iter::CopyableOrderedIter for &'self [A] { - pure fn min(&self) -> A { iter::min(self) } - pure fn max(&self) -> A { iter::max(self) } + fn min(&self) -> A { iter::min(self) } + fn max(&self) -> A { iter::max(self) } } // FIXME(#4148): This should be redundant impl iter::CopyableOrderedIter for ~[A] { - pure fn min(&self) -> A { iter::min(self) } - pure fn max(&self) -> A { iter::max(self) } + fn min(&self) -> A { iter::min(self) } + fn max(&self) -> A { iter::max(self) } } // FIXME(#4148): This should be redundant impl iter::CopyableOrderedIter for @[A] { - pure fn min(&self) -> A { iter::min(self) } - pure fn max(&self) -> A { iter::max(self) } + fn min(&self) -> A { iter::min(self) } + fn max(&self) -> A { iter::max(self) } } impl iter::CopyableNonstrictIter for &'self [A] { - pure fn each_val(&const self, f: &fn(A) -> bool) { + fn each_val(&const self, f: &fn(A) -> bool) { let mut i = 0; while i < self.len() { if !f(copy self[i]) { break; } @@ -2513,7 +2510,7 @@ impl iter::CopyableNonstrictIter for &'self [A] { // FIXME(#4148): This should be redundant impl iter::CopyableNonstrictIter for ~[A] { - pure fn each_val(&const self, f: &fn(A) -> bool) { + fn each_val(&const self, f: &fn(A) -> bool) { let mut i = 0; while i < uniq_len(self) { if !f(copy self[i]) { break; } @@ -2524,7 +2521,7 @@ impl iter::CopyableNonstrictIter for ~[A] { // FIXME(#4148): This should be redundant impl iter::CopyableNonstrictIter for @[A] { - pure fn each_val(&const self, f: &fn(A) -> bool) { + fn each_val(&const self, f: &fn(A) -> bool) { let mut i = 0; while i < self.len() { if !f(copy self[i]) { break; } @@ -2559,11 +2556,11 @@ mod tests { fn square_ref(n: &uint) -> uint { square(*n) } - pure fn is_three(n: &uint) -> bool { *n == 3u } + fn is_three(n: &uint) -> bool { *n == 3u } - pure fn is_odd(n: &uint) -> bool { *n % 2u == 1u } + fn is_odd(n: &uint) -> bool { *n % 2u == 1u } - pure fn is_equal(x: &uint, y:&uint) -> bool { *x == *y } + fn is_equal(x: &uint, y:&uint) -> bool { *x == *y } fn square_if_odd_r(n: &uint) -> Option { if *n % 2u == 1u { Some(*n * *n) } else { None }