auto merge of #5488 : pcwalton/rust/depure, r=pcwalton

This commit is contained in:
bors 2013-03-22 13:00:56 -07:00
commit e9b077c0e9
212 changed files with 2514 additions and 2550 deletions

View File

@ -38,7 +38,7 @@ pub mod rustrt {
/// Returns the number of elements the vector can hold without reallocating
#[inline(always)]
pub pure fn capacity<T>(v: @[const T]) -> uint {
pub fn capacity<T>(v: @[const T]) -> uint {
unsafe {
let repr: **raw::VecRepr =
::cast::reinterpret_cast(&addr_of(&v));
@ -59,8 +59,7 @@ pub pure fn capacity<T>(v: @[const T]) -> uint {
* onto the vector being constructed.
*/
#[inline(always)]
pub pure fn build_sized<A>(size: uint,
builder: &fn(push: &pure fn(v: A))) -> @[A] {
pub fn build_sized<A>(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<A>(size: uint,
* onto the vector being constructed.
*/
#[inline(always)]
pub pure fn build<A>(builder: &fn(push: &pure fn(v: A))) -> @[A] {
pub fn build<A>(builder: &fn(push: &fn(v: A))) -> @[A] {
build_sized(4, builder)
}
@ -95,14 +94,15 @@ pub pure fn build<A>(builder: &fn(push: &pure fn(v: A))) -> @[A] {
* onto the vector being constructed.
*/
#[inline(always)]
pub pure fn build_sized_opt<A>(size: Option<uint>,
builder: &fn(push: &pure fn(v: A))) -> @[A] {
pub fn build_sized_opt<A>(size: Option<uint>,
builder: &fn(push: &fn(v: A)))
-> @[A] {
build_sized(size.get_or_default(4), builder)
}
// Appending
#[inline(always)]
pub pure fn append<T:Copy>(lhs: @[T], rhs: &[const T]) -> @[T] {
pub fn append<T:Copy>(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<T:Copy>(lhs: @[T], rhs: &[const T]) -> @[T] {
/// Apply a function to each element of a vector and return the results
pub pure fn map<T, U>(v: &[T], f: &fn(x: &T) -> U) -> @[U] {
pub fn map<T, U>(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<T, U>(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<T>(n_elts: uint, op: iter::InitOp<T>) -> @[T] {
pub fn from_fn<T>(n_elts: uint, op: iter::InitOp<T>) -> @[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<T>(n_elts: uint, op: iter::InitOp<T>) -> @[T] {
* Creates an immutable vector of size `n_elts` and initializes the elements
* to the value `t`.
*/
pub pure fn from_elem<T:Copy>(n_elts: uint, t: T) -> @[T] {
pub fn from_elem<T:Copy>(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<T:Copy> 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))
}
}

View File

@ -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 {
static pure fn from_str(s: &str) -> Option<bool> {
fn from_str(s: &str) -> Option<bool> {
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]

View File

@ -21,14 +21,14 @@ pub struct Cell<T> {
}
impl<T:cmp::Eq> cmp::Eq for Cell<T> {
pure fn eq(&self, other: &Cell<T>) -> bool {
fn eq(&self, other: &Cell<T>) -> bool {
unsafe {
let frozen_self: &Option<T> = transmute(&mut self.value);
let frozen_other: &Option<T> = transmute(&mut other.value);
frozen_self == frozen_other
}
}
pure fn ne(&self, other: &Cell<T>) -> bool { !self.eq(other) }
fn ne(&self, other: &Cell<T>) -> bool { !self.eq(other) }
}
/// Creates a new full cell with the given value.
@ -36,7 +36,7 @@ pub fn Cell<T>(value: T) -> Cell<T> {
Cell { value: Some(value) }
}
pub pure fn empty_cell<T>() -> Cell<T> {
pub fn empty_cell<T>() -> Cell<T> {
Cell { value: None }
}
@ -61,7 +61,7 @@ pub impl<T> Cell<T> {
}
/// 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()
}

View File

@ -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<uint> {
pub fn to_digit(c: char, radix: uint) -> Option<uint> {
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<uint> {
* Fails if given an `radix` > 36.
*/
#[inline]
pub pure fn from_digit(num: uint, radix: uint) -> Option<char> {
pub fn from_digit(num: uint, radix: uint) -> Option<char> {
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<char> {
* - 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]

View File

@ -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<T: Ord>(a: &T, b: &T) -> Ordering {
fn icmp<T: Ord>(a: &T, b: &T) -> Ordering {
if *a < *b { Less }
else if *a > *b { Greater }
else { Equal }
@ -54,52 +54,52 @@ pure fn icmp<T: Ord>(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<T:Ord>(v1: &T, v2: &T) -> bool {
pub fn lt<T:Ord>(v1: &T, v2: &T) -> bool {
(*v1).lt(v2)
}
#[inline(always)]
pub pure fn le<T:Ord>(v1: &T, v2: &T) -> bool {
pub fn le<T:Ord>(v1: &T, v2: &T) -> bool {
(*v1).le(v2)
}
#[inline(always)]
pub pure fn eq<T:Eq>(v1: &T, v2: &T) -> bool {
pub fn eq<T:Eq>(v1: &T, v2: &T) -> bool {
(*v1).eq(v2)
}
#[inline(always)]
pub pure fn ne<T:Eq>(v1: &T, v2: &T) -> bool {
pub fn ne<T:Eq>(v1: &T, v2: &T) -> bool {
(*v1).ne(v2)
}
#[inline(always)]
pub pure fn ge<T:Ord>(v1: &T, v2: &T) -> bool {
pub fn ge<T:Ord>(v1: &T, v2: &T) -> bool {
(*v1).ge(v2)
}
#[inline(always)]
pub pure fn gt<T:Ord>(v1: &T, v2: &T) -> bool {
pub fn gt<T:Ord>(v1: &T, v2: &T) -> bool {
(*v1).gt(v2)
}
@ -155,16 +155,16 @@ pub pure fn gt<T:Ord>(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<T> {
pure fn equiv(&self, other: &T) -> bool;
fn equiv(&self, other: &T) -> bool;
}
#[inline(always)]
pub pure fn min<T:Ord>(v1: T, v2: T) -> T {
pub fn min<T:Ord>(v1: T, v2: T) -> T {
if v1 < v2 { v1 } else { v2 }
}
#[inline(always)]
pub pure fn max<T:Ord>(v1: T, v2: T) -> T {
pub fn max<T:Ord>(v1: T, v2: T) -> T {
if v1 > v2 { v1 } else { v2 }
}

View File

@ -50,7 +50,7 @@ pub trait GenericPort<T> {
/// Ports that can `peek`
pub trait Peekable<T> {
/// 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<T:Owned>(self: &Chan<T>, x: T) -> bool {
pub impl<T: Owned> Port<T> {
fn recv(&self) -> T { port_recv(self) }
fn try_recv(&self) -> Option<T> { port_try_recv(self) }
pure fn peek(&self) -> bool { port_peek(self) }
fn peek(&self) -> bool { port_peek(self) }
}
impl<T: Owned> GenericPort<T> for Port<T> {
@ -180,11 +180,11 @@ fn port_try_recv<T:Owned>(self: &Port<T>) -> Option<T> {
}
impl<T: Owned> Peekable<T> for Port<T> {
pure fn peek(&self) -> bool { port_peek(self) }
fn peek(&self) -> bool { port_peek(self) }
}
#[inline(always)]
pure fn port_peek<T:Owned>(self: &Port<T>) -> bool {
fn port_peek<T:Owned>(self: &Port<T>) -> bool {
unsafe {
let mut endp = None;
endp <-> self.endp;
@ -198,7 +198,7 @@ pure fn port_peek<T:Owned>(self: &Port<T>) -> bool {
}
impl<T: Owned> Selectable for Port<T> {
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<T: Owned>() -> PortSet<T>{
pub impl<T:Owned> PortSet<T> {
fn recv(&self) -> T { port_set_recv(self) }
fn try_recv(&self) -> Option<T> { port_set_try_recv(self) }
pure fn peek(&self) -> bool { port_set_peek(self) }
fn peek(&self) -> bool { port_set_peek(self) }
}
pub impl<T: Owned> PortSet<T> {
@ -272,11 +272,11 @@ fn port_set_try_recv<T:Owned>(self: &PortSet<T>) -> Option<T> {
}
impl<T: Owned> Peekable<T> for PortSet<T> {
pure fn peek(&self) -> bool { port_set_peek(self) }
fn peek(&self) -> bool { port_set_peek(self) }
}
#[inline(always)]
pure fn port_set_peek<T:Owned>(self: &PortSet<T>) -> bool {
fn port_set_peek<T:Owned>(self: &PortSet<T>) -> 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| {

View File

@ -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<K, V>: 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<K, V>: Mutable {
pub trait Set<T>: 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<T>: 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);
}

View File

@ -42,7 +42,7 @@ pub struct DList<T> {
}
priv impl<T> DListNode<T> {
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<T> DListNode<T> {
pub impl<T> DListNode<T> {
/// Get the next node in the list, if there is one.
pure fn next_link(@mut self) -> DListLink<T> {
fn next_link(@mut self) -> DListLink<T> {
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<T> {
fn next_node(@mut self) -> @mut DListNode<T> {
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<T> {
fn prev_link(@mut self) -> DListLink<T> {
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<T> {
fn prev_node(@mut self) -> @mut DListNode<T> {
match self.prev_link() {
Some(nobe) => nobe,
None => fail!(~"This dlist node has no previous neighbour.")
@ -92,17 +92,17 @@ pub impl<T> DListNode<T> {
}
/// Creates a new dlist node with the given data.
pub pure fn new_dlist_node<T>(data: T) -> @mut DListNode<T> {
pub fn new_dlist_node<T>(data: T) -> @mut DListNode<T> {
@mut DListNode { data: data, linked: false, prev: None, next: None }
}
/// Creates a new, empty dlist.
pub pure fn DList<T>() -> @mut DList<T> {
pub fn DList<T>() -> @mut DList<T> {
@mut DList { size: 0, hd: None, tl: None }
}
/// Creates a new dlist with a single element
pub pure fn from_elem<T>(data: T) -> @mut DList<T> {
pub fn from_elem<T>(data: T) -> @mut DList<T> {
let list = DList();
unsafe { list.push(data); }
list
@ -126,7 +126,7 @@ pub fn concat<T>(lists: @mut DList<@mut DList<T>>) -> @mut DList<T> {
}
priv impl<T> DList<T> {
static pure fn new_link(data: T) -> DListLink<T> {
fn new_link(data: T) -> DListLink<T> {
Some(@mut DListNode {
data: data,
linked: true,
@ -134,7 +134,7 @@ priv impl<T> DList<T> {
next: None
})
}
pure fn assert_mine(@mut self, nobe: @mut DListNode<T>) {
fn assert_mine(@mut self, nobe: @mut DListNode<T>) {
// 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<T> DList<T> {
pub impl<T> DList<T> {
/// 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<T> DList<T> {
tl
}
/// Get the node at the list's head. O(1).
pure fn peek_n(@mut self) -> DListLink<T> { self.hd }
fn peek_n(@mut self) -> DListLink<T> { self.hd }
/// Get the node at the list's tail. O(1).
pure fn peek_tail_n(@mut self) -> DListLink<T> { self.tl }
fn peek_tail_n(@mut self) -> DListLink<T> { self.tl }
/// Get the node at the list's head, failing if empty. O(1).
pure fn head_n(@mut self) -> @mut DListNode<T> {
fn head_n(@mut self) -> @mut DListNode<T> {
match self.hd {
Some(nobe) => nobe,
None => fail!(
@ -329,7 +329,7 @@ pub impl<T> DList<T> {
}
}
/// Get the node at the list's tail, failing if empty. O(1).
pure fn tail_n(@mut self) -> @mut DListNode<T> {
fn tail_n(@mut self) -> @mut DListNode<T> {
match self.tl {
Some(nobe) => nobe,
None => fail!(
@ -399,7 +399,7 @@ pub impl<T> DList<T> {
}
/// Iterate over nodes.
pure fn each_node(@mut self, f: &fn(@mut DListNode<T>) -> bool) {
fn each_node(@mut self, f: &fn(@mut DListNode<T>) -> bool) {
let mut link = self.peek_n();
while link.is_some() {
let nobe = link.get();
@ -471,23 +471,23 @@ pub impl<T:Copy> DList<T> {
}
/// Get data at the list's head. O(1).
pure fn peek(@mut self) -> Option<T> {
fn peek(@mut self) -> Option<T> {
self.peek_n().map(|nobe| nobe.data)
}
/// Get data at the list's tail. O(1).
pure fn peek_tail(@mut self) -> Option<T> {
fn peek_tail(@mut self) -> Option<T> {
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<T> BaseIter<T> for @mut DList<T> {
* 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<T> BaseIter<T> for @mut DList<T> {
}
#[inline(always)]
pure fn size_hint(&self) -> Option<uint> { Some(self.len()) }
fn size_hint(&self) -> Option<uint> { Some(self.len()) }
}
#[cfg(test)]

View File

@ -87,7 +87,7 @@ pub fn partition<T, U>(eithers: ~[Either<T, U>])
}
#[inline(always)]
pub pure fn flip<T, U>(eith: Either<T, U>) -> Either<U, T> {
pub fn flip<T, U>(eith: Either<T, U>) -> Either<U, T> {
//! Flips between left and right of a given either
match eith {
@ -97,7 +97,7 @@ pub pure fn flip<T, U>(eith: Either<T, U>) -> Either<U, T> {
}
#[inline(always)]
pub pure fn to_result<T, U>(eith: Either<T, U>)
pub fn to_result<T, U>(eith: Either<T, U>)
-> Result<U, T> {
/*!
* Converts either::t to a result::t
@ -113,21 +113,21 @@ pub pure fn to_result<T, U>(eith: Either<T, U>)
}
#[inline(always)]
pub pure fn is_left<T, U>(eith: &Either<T, U>) -> bool {
pub fn is_left<T, U>(eith: &Either<T, U>) -> bool {
//! Checks whether the given value is a left
match *eith { Left(_) => true, _ => false }
}
#[inline(always)]
pub pure fn is_right<T, U>(eith: &Either<T, U>) -> bool {
pub fn is_right<T, U>(eith: &Either<T, U>) -> bool {
//! Checks whether the given value is a right
match *eith { Right(_) => true, _ => false }
}
#[inline(always)]
pub pure fn unwrap_left<T,U>(eith: Either<T,U>) -> T {
pub fn unwrap_left<T,U>(eith: Either<T,U>) -> 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<T,U>(eith: Either<T,U>) -> T {
}
#[inline(always)]
pub pure fn unwrap_right<T,U>(eith: Either<T,U>) -> U {
pub fn unwrap_right<T,U>(eith: Either<T,U>) -> U {
//! Retrieves the value in the right branch. Fails if the either is Left.
match eith {

View File

@ -13,5 +13,5 @@
use option::Option;
pub trait FromStr {
static pure fn from_str(s: &str) -> Option<Self>;
fn from_str(s: &str) -> Option<Self>;
}

View File

@ -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<A:Hash> 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<A:IterBytes> 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<A:IterBytes> Hash for A {
}
}
pure fn hash_keyed_2<A: IterBytes,
B: IterBytes>(a: &A, b: &B,
k0: u64, k1: u64) -> u64 {
fn hash_keyed_2<A: IterBytes,
B: IterBytes>(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: IterBytes,
}
}
pure fn hash_keyed_3<A: IterBytes,
B: IterBytes,
C: IterBytes>(a: &A, b: &B, c: &C,
k0: u64, k1: u64) -> u64 {
fn hash_keyed_3<A: IterBytes,
B: IterBytes,
C: IterBytes>(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: IterBytes,
}
}
pure fn hash_keyed_4<A: IterBytes,
B: IterBytes,
C: IterBytes,
D: IterBytes>(a: &A, b: &B, c: &C, d: &D,
k0: u64, k1: u64) -> u64 {
fn hash_keyed_4<A: IterBytes,
B: IterBytes,
C: IterBytes,
D: IterBytes>(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: IterBytes,
}
}
pure fn hash_keyed_5<A: IterBytes,
B: IterBytes,
C: IterBytes,
D: IterBytes,
E: IterBytes>(a: &A, b: &B, c: &C, d: &D, e: &E,
k0: u64, k1: u64) -> u64 {
fn hash_keyed_5<A: IterBytes,
B: IterBytes,
C: IterBytes,
D: IterBytes,
E: IterBytes>(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); }

View File

@ -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<K:Eq + Hash,V>(
fn linear_map_with_capacity_and_keys<K:Eq + Hash,V>(
k0: u64, k1: u64,
initial_capacity: uint) -> LinearMap<K, V> {
LinearMap {
@ -72,21 +72,21 @@ pub mod linear {
priv impl<K:Hash + IterBytes + Eq,V> LinearMap<K, V> {
#[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<Q:Hash + IterBytes + Equiv<K>>(
&self,
k: &Q)
-> SearchResult {
fn bucket_for_key_equiv<Q:Hash + IterBytes + Equiv<K>>(&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<Q:Equiv<K>>(&self,
hash: uint,
k: &Q)
-> SearchResult {
fn bucket_for_key_with_hash_equiv<Q:Equiv<K>>(&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<K, V>
{
/// 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<uint> { Some(self.len()) }
fn size_hint(&self) -> Option<uint> { Some(self.len()) }
}
impl<K:Hash + IterBytes + Eq,V> Container for LinearMap<K, V> {
/// 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<K:Hash + IterBytes + Eq,V> Mutable for LinearMap<K, V> {
@ -308,7 +308,7 @@ pub mod linear {
impl<K:Hash + IterBytes + Eq,V> Map<K, V> for LinearMap<K, V> {
/// 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,
@ -373,7 +373,7 @@ pub mod linear {
pub impl<K:Hash + IterBytes + Eq,V> LinearMap<K, V> {
/// Create an empty LinearMap
static fn new() -> LinearMap<K, V> {
fn new() -> LinearMap<K, V> {
linear_map_with_capacity(INITIAL_CAPACITY)
}
@ -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<Q:Hash + IterBytes + Equiv<K>>(
&self,
key: &Q)
-> bool {
fn contains_key_equiv<Q:Hash + IterBytes + Equiv<K>>(&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<Q:Hash + IterBytes + Equiv<K>>(&self, k: &Q)
-> Option<&'self V> {
fn find_equiv<Q:Hash + IterBytes + Equiv<K>>(&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<K:Hash + IterBytes + Eq,V:Eq> Eq for LinearMap<K, V> {
pure fn eq(&self, other: &LinearMap<K, V>) -> bool {
fn eq(&self, other: &LinearMap<K, V>) -> 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<K, V>) -> bool { !self.eq(other) }
fn ne(&self, other: &LinearMap<K, V>) -> bool { !self.eq(other) }
}
pub struct LinearSet<T> {
@ -540,25 +538,21 @@ pub mod linear {
impl<T:Hash + IterBytes + Eq> BaseIter<T> for LinearSet<T> {
/// Visit all values in order
pure fn each(&self, f: &fn(&T) -> bool) { self.map.each_key(f) }
pure fn size_hint(&self) -> Option<uint> { Some(self.len()) }
fn each(&self, f: &fn(&T) -> bool) { self.map.each_key(f) }
fn size_hint(&self) -> Option<uint> { Some(self.len()) }
}
impl<T:Hash + IterBytes + Eq> Eq for LinearSet<T> {
pure fn eq(&self, other: &LinearSet<T>) -> bool {
self.map == other.map
}
pure fn ne(&self, other: &LinearSet<T>) -> bool {
self.map != other.map
}
fn eq(&self, other: &LinearSet<T>) -> bool { self.map == other.map }
fn ne(&self, other: &LinearSet<T>) -> bool { self.map != other.map }
}
impl<T:Hash + IterBytes + Eq> Container for LinearSet<T> {
/// 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<T:Hash + IterBytes + Eq> Mutable for LinearSet<T> {
@ -568,9 +562,7 @@ pub mod linear {
impl<T:Hash + IterBytes + Eq> Set<T> for LinearSet<T> {
/// 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<T>) -> bool {
fn is_disjoint(&self, other: &LinearSet<T>) -> 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<T>) -> bool {
fn is_subset(&self, other: &LinearSet<T>) -> 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<T>) -> bool {
fn is_superset(&self, other: &LinearSet<T>) -> bool {
other.is_subset(self)
}
/// Visit the values representing the difference
pure fn difference(&self, other: &LinearSet<T>, f: &fn(&T) -> bool) {
fn difference(&self, other: &LinearSet<T>, 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<T>,
f: &fn(&T) -> bool) {
fn symmetric_difference(&self,
other: &LinearSet<T>,
f: &fn(&T) -> bool) {
self.difference(other, f);
other.difference(self, f);
}
/// Visit the values representing the intersection
pure fn intersection(&self,
other: &LinearSet<T>,
f: &fn(&T) -> bool) {
fn intersection(&self, other: &LinearSet<T>, 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<T>, f: &fn(&T) -> bool) {
fn union(&self, other: &LinearSet<T>, f: &fn(&T) -> bool) {
for self.each |v| {
if !f(v) { return }
}
@ -639,7 +630,7 @@ pub mod linear {
pub impl <T:Hash + IterBytes + Eq> LinearSet<T> {
/// Create an empty LinearSet
static fn new() -> LinearSet<T> { LinearSet{map: LinearMap::new()} }
fn new() -> LinearSet<T> { LinearSet{map: LinearMap::new()} }
/// Reserve space for at least `n` elements in the hash table.
fn reserve_at_least(&mut self, n: uint) {

View File

@ -646,11 +646,11 @@ impl Reader for BytesReader<'self> {
fn tell(&self) -> uint { self.pos }
}
pub pure fn with_bytes_reader<t>(bytes: &[u8], f: &fn(@Reader) -> t) -> t {
pub fn with_bytes_reader<t>(bytes: &[u8], f: &fn(@Reader) -> t) -> t {
f(@BytesReader { bytes: bytes, pos: 0u } as @Reader)
}
pub pure fn with_str_reader<T>(s: &str, f: &fn(@Reader) -> T) -> T {
pub fn with_str_reader<T>(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.

View File

@ -23,12 +23,12 @@ use vec;
pub type InitOp<T> = &'self fn(uint) -> T;
pub trait BaseIter<A> {
pure fn each(&self, blk: &fn(v: &A) -> bool);
pure fn size_hint(&self) -> Option<uint>;
fn each(&self, blk: &fn(v: &A) -> bool);
fn size_hint(&self) -> Option<uint>;
}
pub trait ReverseIter<A>: BaseIter<A> {
pure fn each_reverse(&self, blk: &fn(&A) -> bool);
fn each_reverse(&self, blk: &fn(&A) -> bool);
}
pub trait MutableIter<A>: BaseIter<A> {
@ -36,41 +36,40 @@ pub trait MutableIter<A>: BaseIter<A> {
}
pub trait ExtendedIter<A> {
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<B>(&self, b0: B, blk: &fn(&B, &A) -> B) -> B;
pure fn position(&self, f: &fn(&A) -> bool) -> Option<uint>;
pure fn map_to_vec<B>(&self, op: &fn(&A) -> B) -> ~[B];
pure fn flat_map_to_vec<B,IB: BaseIter<B>>(&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<B>(&self, b0: B, blk: &fn(&B, &A) -> B) -> B;
fn position(&self, f: &fn(&A) -> bool) -> Option<uint>;
fn map_to_vec<B>(&self, op: &fn(&A) -> B) -> ~[B];
fn flat_map_to_vec<B,IB: BaseIter<B>>(&self, op: &fn(&A) -> IB) -> ~[B];
}
pub trait EqIter<A:Eq> {
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<A:Copy> {
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<A>;
fn filter_to_vec(&self, pred: &fn(&A) -> bool) -> ~[A];
fn to_vec(&self) -> ~[A];
fn find(&self, p: &fn(&A) -> bool) -> Option<A>;
}
pub trait CopyableOrderedIter<A:Copy + Ord> {
pure fn min(&self) -> A;
pure fn max(&self) -> A;
fn min(&self) -> A;
fn max(&self) -> A;
}
pub trait CopyableNonstrictIter<A:Copy> {
// 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<A> {
* as an argument a function that will push an element
* onto the sequence being constructed.
*/
static 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<A,IA:BaseIter<A>>(self: &IA,
blk: &fn(uint, &A) -> bool) {
pub fn eachi<A,IA:BaseIter<A>>(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<A,IA:BaseIter<A>>(self: &IA,
}
#[inline(always)]
pub pure fn all<A,IA:BaseIter<A>>(self: &IA,
blk: &fn(&A) -> bool) -> bool {
pub fn all<A,IA:BaseIter<A>>(self: &IA, blk: &fn(&A) -> bool) -> bool {
for self.each |a| {
if !blk(a) { return false; }
}
@ -113,8 +109,7 @@ pub pure fn all<A,IA:BaseIter<A>>(self: &IA,
}
#[inline(always)]
pub pure fn any<A,IA:BaseIter<A>>(self: &IA,
blk: &fn(&A) -> bool) -> bool {
pub fn any<A,IA:BaseIter<A>>(self: &IA, blk: &fn(&A) -> bool) -> bool {
for self.each |a| {
if blk(a) { return true; }
}
@ -122,8 +117,9 @@ pub pure fn any<A,IA:BaseIter<A>>(self: &IA,
}
#[inline(always)]
pub pure fn filter_to_vec<A:Copy,IA:BaseIter<A>>(
self: &IA, prd: &fn(&A) -> bool) -> ~[A] {
pub fn filter_to_vec<A:Copy,IA:BaseIter<A>>(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<A:Copy,IA:BaseIter<A>>(
}
#[inline(always)]
pub pure fn map_to_vec<A,B,IA:BaseIter<A>>(self: &IA,
op: &fn(&A) -> B)
-> ~[B] {
pub fn map_to_vec<A,B,IA:BaseIter<A>>(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<A,B,IA:BaseIter<A>>(self: &IA,
}
#[inline(always)]
pub pure fn flat_map_to_vec<A,B,IA:BaseIter<A>,IB:BaseIter<B>>(
self: &IA, op: &fn(&A) -> IB) -> ~[B] {
pub fn flat_map_to_vec<A,B,IA:BaseIter<A>,IB:BaseIter<B>>(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<A,B,IA:BaseIter<A>,IB:BaseIter<B>>(
}
#[inline(always)]
pub pure fn foldl<A,B,IA:BaseIter<A>>(self: &IA, b0: B,
blk: &fn(&B, &A) -> B)
-> B {
pub fn foldl<A,B,IA:BaseIter<A>>(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<A,B,IA:BaseIter<A>>(self: &IA, b0: B,
}
#[inline(always)]
pub pure fn to_vec<A:Copy,IA:BaseIter<A>>(self: &IA) -> ~[A] {
pub fn to_vec<A:Copy,IA:BaseIter<A>>(self: &IA) -> ~[A] {
foldl::<A,~[A],IA>(self, ~[], |r, a| vec::append(copy (*r), ~[*a]))
}
#[inline(always)]
pub pure fn contains<A:Eq,IA:BaseIter<A>>(self: &IA, x: &A) -> bool {
pub fn contains<A:Eq,IA:BaseIter<A>>(self: &IA, x: &A) -> bool {
for self.each |a| {
if *a == *x { return true; }
}
@ -179,7 +173,7 @@ pub pure fn contains<A:Eq,IA:BaseIter<A>>(self: &IA, x: &A) -> bool {
}
#[inline(always)]
pub pure fn count<A:Eq,IA:BaseIter<A>>(self: &IA, x: &A) -> uint {
pub fn count<A:Eq,IA:BaseIter<A>>(self: &IA, x: &A) -> uint {
do foldl(self, 0) |count, value| {
if *value == *x {
*count + 1
@ -190,9 +184,8 @@ pub pure fn count<A:Eq,IA:BaseIter<A>>(self: &IA, x: &A) -> uint {
}
#[inline(always)]
pub pure fn position<A,IA:BaseIter<A>>(self: &IA, f: &fn(&A) -> bool)
-> Option<uint>
{
pub fn position<A,IA:BaseIter<A>>(self: &IA, f: &fn(&A) -> bool)
-> Option<uint> {
let mut i = 0;
for self.each |a| {
if f(a) { return Some(i); }
@ -206,7 +199,7 @@ pub pure fn position<A,IA:BaseIter<A>>(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<A:Copy + Ord,IA:BaseIter<A>>(self: &IA) -> A {
pub fn min<A:Copy + Ord,IA:BaseIter<A>>(self: &IA) -> A {
match do foldl::<A,Option<A>,IA>(self, None) |a, b| {
match a {
&Some(ref a_) if *a_ < *b => {
@ -230,7 +223,7 @@ pub pure fn min<A:Copy + Ord,IA:BaseIter<A>>(self: &IA) -> A {
}
#[inline(always)]
pub pure fn max<A:Copy + Ord,IA:BaseIter<A>>(self: &IA) -> A {
pub fn max<A:Copy + Ord,IA:BaseIter<A>>(self: &IA) -> A {
match do foldl::<A,Option<A>,IA>(self, None) |a, b| {
match a {
&Some(ref a_) if *a_ > *b => {
@ -245,8 +238,8 @@ pub pure fn max<A:Copy + Ord,IA:BaseIter<A>>(self: &IA) -> A {
}
#[inline(always)]
pub pure fn find<A:Copy,IA:BaseIter<A>>(self: &IA,
f: &fn(&A) -> bool) -> Option<A> {
pub fn find<A:Copy,IA:BaseIter<A>>(self: &IA, f: &fn(&A) -> bool)
-> Option<A> {
for self.each |i| {
if f(i) { return Some(*i) }
}
@ -266,8 +259,7 @@ pub pure fn find<A:Copy,IA:BaseIter<A>>(self: &IA,
* onto the sequence being constructed.
*/
#[inline(always)]
pub pure fn build<A,B: Buildable<A>>(builder: &fn(push: &pure fn(A)))
-> B {
pub fn build<A,B: Buildable<A>>(builder: &fn(push: &fn(A))) -> B {
Buildable::build_sized(4, builder)
}
@ -285,10 +277,8 @@ pub pure fn build<A,B: Buildable<A>>(builder: &fn(push: &pure fn(A)))
* onto the sequence being constructed.
*/
#[inline(always)]
pub pure fn build_sized_opt<A,B: Buildable<A>>(
size: Option<uint>,
builder: &fn(push: &pure fn(A))) -> B {
pub fn build_sized_opt<A,B: Buildable<A>>(size: Option<uint>,
builder: &fn(push: &fn(A))) -> B {
Buildable::build_sized(size.get_or_default(4), builder)
}
@ -312,8 +302,7 @@ pub fn map<T,IT: BaseIter<T>,U,BU: Buildable<U>>(v: &IT, f: &fn(&T) -> U)
* to the value returned by the function `op`.
*/
#[inline(always)]
pub pure fn from_fn<T,BT: Buildable<T>>(n_elts: uint,
op: InitOp<T>) -> BT {
pub fn from_fn<T,BT: Buildable<T>>(n_elts: uint, op: InitOp<T>) -> 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<T,BT: Buildable<T>>(n_elts: uint,
* to the value `t`.
*/
#[inline(always)]
pub pure fn from_elem<T:Copy,BT:Buildable<T>>(n_elts: uint,
t: T) -> BT {
pub fn from_elem<T:Copy,BT:Buildable<T>>(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<T:Copy,BT:Buildable<T>>(n_elts: uint,
/// Appends two generic sequences.
#[inline(always)]
pub pure fn append<T:Copy,IT:BaseIter<T>,BT:Buildable<T>>(
lhs: &IT, rhs: &IT) -> BT {
pub fn append<T:Copy,IT:BaseIter<T>,BT:Buildable<T>>(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<T:Copy,IT:BaseIter<T>,BT:Buildable<T>>(
/// Copies a generic sequence, possibly converting it to a different
/// type of sequence.
#[inline(always)]
pub pure fn copy_seq<T:Copy,IT:BaseIter<T>,BT:Buildable<T>>(
v: &IT) -> BT {
pub fn copy_seq<T:Copy,IT:BaseIter<T>,BT:Buildable<T>>(v: &IT) -> BT {
do build_sized_opt(v.size_hint()) |push| {
for v.each |x| { push(*x); }
}

View File

@ -37,13 +37,13 @@ pub mod raw {
}
#[inline(always)]
pub pure fn ptr_eq<T>(a: @T, b: @T) -> bool {
pub fn ptr_eq<T>(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<T>(a: @mut T, b: @mut T) -> bool {
pub fn mut_ptr_eq<T>(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<T>(a: @mut T, b: @mut T) -> bool {
#[cfg(notest)]
impl<T:Eq> 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<T:Eq> 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<T:Ord> 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<T:Ord> 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]

View File

@ -55,7 +55,7 @@ pub impl<T> Data<T> {
}
}
pure fn borrow_const<R>(&self, op: &fn(t: &const T) -> R) -> R {
fn borrow_const<R>(&self, op: &fn(t: &const T) -> R) -> R {
op(&const self.value)
}

View File

@ -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 }
}

View File

@ -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)]
static pure fn zero() -> f32 { 0.0 }
fn zero() -> f32 { 0.0 }
}
impl num::One for f32 {
#[inline(always)]
static 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)]
static pure fn from<N:NumCast>(n: N) -> f32 { n.to_f32() }
fn from<N:NumCast>(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<f32,f32> for f32 {
pure fn add(&self, other: &f32) -> f32 { *self + *other }
fn add(&self, other: &f32) -> f32 { *self + *other }
}
#[cfg(notest)]
impl ops::Sub<f32,f32> for f32 {
pure fn sub(&self, other: &f32) -> f32 { *self - *other }
fn sub(&self, other: &f32) -> f32 { *self - *other }
}
#[cfg(notest)]
impl ops::Mul<f32,f32> for f32 {
pure fn mul(&self, other: &f32) -> f32 { *self * *other }
fn mul(&self, other: &f32) -> f32 { *self * *other }
}
#[cfg(notest)]
impl ops::Div<f32,f32> for f32 {
pure fn div(&self, other: &f32) -> f32 { *self / *other }
fn div(&self, other: &f32) -> f32 { *self / *other }
}
#[cfg(notest)]
impl ops::Modulo<f32,f32> for f32 {
pure fn modulo(&self, other: &f32) -> f32 { *self % *other }
fn modulo(&self, other: &f32) -> f32 { *self % *other }
}
#[cfg(notest)]
impl ops::Neg<f32> 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<f32> {
pub fn from_str(num: &str) -> Option<f32> {
strconv::from_str_common(num, 10u, true, true, true,
strconv::ExpDec, false)
}
@ -536,7 +538,7 @@ pub pure fn from_str(num: &str) -> Option<f32> {
* `Some(n)` where `n` is the floating-point number represented by `[num]`.
*/
#[inline(always)]
pub pure fn from_str_hex(num: &str) -> Option<f32> {
pub fn from_str_hex(num: &str) -> Option<f32> {
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<f32> {
* `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<f32> {
pub fn from_str_radix(num: &str, rdx: uint) -> Option<f32> {
strconv::from_str_common(num, rdx, true, true, false,
strconv::ExpNone, false)
}
impl from_str::FromStr for f32 {
#[inline(always)]
static pure fn from_str(val: &str) -> Option<f32> { from_str(val) }
fn from_str(val: &str) -> Option<f32> { from_str(val) }
}
impl num::FromStrRadix for f32 {
#[inline(always)]
static pure fn from_str_radix(val: &str, rdx: uint) -> Option<f32> {
fn from_str_radix(val: &str, rdx: uint) -> Option<f32> {
from_str_radix(val, rdx)
}
}

View File

@ -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)]
static pure fn from<N:NumCast>(n: N) -> f64 { n.to_f64() }
fn from<N:NumCast>(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)]
static pure fn zero() -> f64 { 0.0 }
fn zero() -> f64 { 0.0 }
}
impl num::One for f64 {
#[inline(always)]
static pure fn one() -> f64 { 1.0 }
fn one() -> f64 { 1.0 }
}
#[cfg(notest)]
impl ops::Add<f64,f64> for f64 {
pure fn add(&self, other: &f64) -> f64 { *self + *other }
fn add(&self, other: &f64) -> f64 { *self + *other }
}
#[cfg(notest)]
impl ops::Sub<f64,f64> for f64 {
pure fn sub(&self, other: &f64) -> f64 { *self - *other }
fn sub(&self, other: &f64) -> f64 { *self - *other }
}
#[cfg(notest)]
impl ops::Mul<f64,f64> for f64 {
pure fn mul(&self, other: &f64) -> f64 { *self * *other }
fn mul(&self, other: &f64) -> f64 { *self * *other }
}
#[cfg(notest)]
impl ops::Div<f64,f64> for f64 {
pure fn div(&self, other: &f64) -> f64 { *self / *other }
fn div(&self, other: &f64) -> f64 { *self / *other }
}
#[cfg(notest)]
impl ops::Modulo<f64,f64> for f64 {
pure fn modulo(&self, other: &f64) -> f64 { *self % *other }
fn modulo(&self, other: &f64) -> f64 { *self % *other }
}
#[cfg(notest)]
impl ops::Neg<f64> 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<f64> {
pub fn from_str(num: &str) -> Option<f64> {
strconv::from_str_common(num, 10u, true, true, true,
strconv::ExpDec, false)
}
@ -560,7 +560,7 @@ pub pure fn from_str(num: &str) -> Option<f64> {
* `Some(n)` where `n` is the floating-point number represented by `[num]`.
*/
#[inline(always)]
pub pure fn from_str_hex(num: &str) -> Option<f64> {
pub fn from_str_hex(num: &str) -> Option<f64> {
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<f64> {
* `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<f64> {
pub fn from_str_radix(num: &str, rdx: uint) -> Option<f64> {
strconv::from_str_common(num, rdx, true, true, false,
strconv::ExpNone, false)
}
impl from_str::FromStr for f64 {
#[inline(always)]
static pure fn from_str(val: &str) -> Option<f64> { from_str(val) }
fn from_str(val: &str) -> Option<f64> { from_str(val) }
}
impl num::FromStrRadix for f64 {
#[inline(always)]
static pure fn from_str_radix(val: &str, rdx: uint) -> Option<f64> {
fn from_str_radix(val: &str, rdx: uint) -> Option<f64> {
from_str_radix(val, rdx)
}
}

View File

@ -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<float> {
pub fn from_str(num: &str) -> Option<float> {
strconv::from_str_common(num, 10u, true, true, true,
strconv::ExpDec, false)
}
@ -272,7 +272,7 @@ pub pure fn from_str(num: &str) -> Option<float> {
* `Some(n)` where `n` is the floating-point number represented by `[num]`.
*/
#[inline(always)]
pub pure fn from_str_hex(num: &str) -> Option<float> {
pub fn from_str_hex(num: &str) -> Option<float> {
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<float> {
* `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<float> {
pub fn from_str_radix(num: &str, radix: uint) -> Option<float> {
strconv::from_str_common(num, radix, true, true, false,
strconv::ExpNone, false)
}
impl from_str::FromStr for float {
#[inline(always)]
static pure fn from_str(val: &str) -> Option<float> { from_str(val) }
fn from_str(val: &str) -> Option<float> { from_str(val) }
}
impl num::FromStrRadix for float {
#[inline(always)]
static pure fn from_str_radix(val: &str, radix: uint) -> Option<float> {
fn from_str_radix(val: &str, radix: uint) -> Option<float> {
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)]
static pure fn zero() -> float { 0.0 }
fn zero() -> float { 0.0 }
}
impl num::One for float {
#[inline(always)]
static 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)]
static pure fn from<N:NumCast>(n: N) -> float { n.to_float() }
fn from<N:NumCast>(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<float,float> for float {
pure fn add(&self, other: &float) -> float { *self + *other }
fn add(&self, other: &float) -> float { *self + *other }
}
#[cfg(notest)]
impl ops::Sub<float,float> for float {
pure fn sub(&self, other: &float) -> float { *self - *other }
fn sub(&self, other: &float) -> float { *self - *other }
}
#[cfg(notest)]
impl ops::Mul<float,float> for float {
pure fn mul(&self, other: &float) -> float { *self * *other }
fn mul(&self, other: &float) -> float { *self * *other }
}
#[cfg(notest)]
impl ops::Div<float,float> for float {
pure fn div(&self, other: &float) -> float { *self / *other }
fn div(&self, other: &float) -> float { *self / *other }
}
#[cfg(notest)]
impl ops::Modulo<float,float> for float {
pure fn modulo(&self, other: &float) -> float { *self % *other }
fn modulo(&self, other: &float) -> float { *self % *other }
}
#[cfg(notest)]
impl ops::Neg<float> for float {
pure fn neg(&self) -> float { -*self }
fn neg(&self) -> float { -*self }
}
#[test]

View File

@ -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)]
static pure fn zero() -> T { 0 }
fn zero() -> T { 0 }
}
impl num::One for T {
#[inline(always)]
static pure fn one() -> T { 1 }
fn one() -> T { 1 }
}
#[cfg(notest)]
impl ops::Add<T,T> for T {
pure fn add(&self, other: &T) -> T { *self + *other }
fn add(&self, other: &T) -> T { *self + *other }
}
#[cfg(notest)]
impl ops::Sub<T,T> for T {
pure fn sub(&self, other: &T) -> T { *self - *other }
fn sub(&self, other: &T) -> T { *self - *other }
}
#[cfg(notest)]
impl ops::Mul<T,T> for T {
pure fn mul(&self, other: &T) -> T { *self * *other }
fn mul(&self, other: &T) -> T { *self * *other }
}
#[cfg(notest)]
impl ops::Div<T,T> for T {
pure fn div(&self, other: &T) -> T { *self / *other }
fn div(&self, other: &T) -> T { *self / *other }
}
#[cfg(notest)]
impl ops::Modulo<T,T> for T {
pure fn modulo(&self, other: &T) -> T { *self % *other }
fn modulo(&self, other: &T) -> T { *self % *other }
}
#[cfg(notest)]
impl ops::Neg<T> 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<T> {
pub fn from_str(s: &str) -> Option<T> {
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<T> {
pub fn from_str_radix(s: &str, radix: uint) -> Option<T> {
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<T> {
pub fn parse_bytes(buf: &[u8], radix: uint) -> Option<T> {
strconv::from_str_bytes_common(buf, radix, true, false, false,
strconv::ExpNone, false)
}
impl FromStr for T {
#[inline(always)]
static pure fn from_str(s: &str) -> Option<T> {
fn from_str(s: &str) -> Option<T> {
from_str(s)
}
}
impl FromStrRadix for T {
#[inline(always)]
static pure fn from_str_radix(&self, s: &str, radix: uint) -> Option<T> {
fn from_str_radix(s: &str, radix: uint) -> Option<T> {
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<U>(n: T, radix: uint, f: &fn(v: &[u8]) -> U) -> U {
pub fn to_str_bytes<U>(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<U>(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)
}
}

View File

@ -22,23 +22,23 @@ impl NumCast for i16 {
* Cast `n` to a `i16`
*/
#[inline(always)]
static pure fn from<N:NumCast>(n: N) -> i16 { n.to_i16() }
fn from<N:NumCast>(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]

View File

@ -22,23 +22,23 @@ impl NumCast for i32 {
* Cast `n` to a `i32`
*/
#[inline(always)]
static pure fn from<N:NumCast>(n: N) -> i32 { n.to_i32() }
fn from<N:NumCast>(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]

View File

@ -22,23 +22,23 @@ impl NumCast for i64 {
* Cast `n` to a `i64`
*/
#[inline(always)]
static pure fn from<N:NumCast>(n: N) -> i64 { n.to_i64() }
fn from<N:NumCast>(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]

View File

@ -22,23 +22,23 @@ impl NumCast for i8 {
* Cast `n` to a `i8`
*/
#[inline(always)]
static pure fn from<N:NumCast>(n: N) -> i8 { n.to_i8() }
fn from<N:NumCast>(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]

View File

@ -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)]
static pure fn from<N:NumCast>(n: N) -> int { n.to_int() }
fn from<N:NumCast>(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]

View File

@ -17,28 +17,28 @@ use kinds::Copy;
pub mod strconv;
pub trait IntConvertible {
pure fn to_int(&self) -> int;
static pure fn from_int(n: int) -> Self;
fn to_int(&self) -> int;
fn from_int(n: int) -> Self;
}
pub trait Zero {
static pure fn zero() -> Self;
fn zero() -> Self;
}
pub trait One {
static pure fn one() -> Self;
fn one() -> Self;
}
pub pure fn abs<T:Ord + Zero + Neg<T>>(v: T) -> T {
pub fn abs<T:Ord + Zero + Neg<T>>(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<T:NumCast,U:NumCast>(n: T) -> U {
pub fn cast<T:NumCast,U:NumCast>(n: T) -> U {
NumCast::from(n)
}
@ -67,31 +67,31 @@ pub pure fn cast<T:NumCast,U:NumCast>(n: T) -> U {
* An interface for generic numeric type casts
*/
pub trait NumCast {
static pure fn from<T:NumCast>(n: T) -> Self;
fn from<T:NumCast>(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 {
static pub pure fn from_str_radix(str: &str, radix: uint) -> Option<Self>;
pub fn from_str_radix(str: &str, radix: uint) -> Option<Self>;
}
// 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<T:NumCast+One+Zero+Copy+Div<T,T>+Mul<T,T>>(
pub fn pow_with_uint<T:NumCast+One+Zero+Copy+Div<T,T>+Mul<T,T>>(
radix: uint, pow: uint) -> T {
let _0: T = Zero::zero();
let _1: T = One::one();

View File

@ -37,12 +37,12 @@ pub enum SignFormat {
}
#[inline(always)]
pure fn is_NaN<T:Eq>(num: &T) -> bool {
fn is_NaN<T:Eq>(num: &T) -> bool {
*num != *num
}
#[inline(always)]
pure fn is_inf<T:Eq+NumStrConv>(num: &T) -> bool {
fn is_inf<T:Eq+NumStrConv>(num: &T) -> bool {
match NumStrConv::inf() {
None => false,
Some(n) => *num == n
@ -50,7 +50,7 @@ pure fn is_inf<T:Eq+NumStrConv>(num: &T) -> bool {
}
#[inline(always)]
pure fn is_neg_inf<T:Eq+NumStrConv>(num: &T) -> bool {
fn is_neg_inf<T:Eq+NumStrConv>(num: &T) -> bool {
match NumStrConv::neg_inf() {
None => false,
Some(n) => *num == n
@ -58,7 +58,7 @@ pure fn is_neg_inf<T:Eq+NumStrConv>(num: &T) -> bool {
}
#[inline(always)]
pure fn is_neg_zero<T:Eq+One+Zero+NumStrConv+Div<T,T>>(num: &T) -> bool {
fn is_neg_zero<T:Eq+One+Zero+NumStrConv+Div<T,T>>(num: &T) -> bool {
let _0: T = Zero::zero();
let _1: T = One::one();
@ -66,35 +66,35 @@ pure fn is_neg_zero<T:Eq+One+Zero+NumStrConv+Div<T,T>>(num: &T) -> bool {
}
pub trait NumStrConv {
static pure fn NaN() -> Option<Self>;
static pure fn inf() -> Option<Self>;
static pure fn neg_inf() -> Option<Self>;
static pure fn neg_zero() -> Option<Self>;
fn NaN() -> Option<Self>;
fn inf() -> Option<Self>;
fn neg_inf() -> Option<Self>;
fn neg_zero() -> Option<Self>;
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)]
static pure fn NaN() -> Option<$t> { Some( 0.0 / 0.0) }
fn NaN() -> Option<$t> { Some( 0.0 / 0.0) }
#[inline(always)]
static pure fn inf() -> Option<$t> { Some( 1.0 / 0.0) }
fn inf() -> Option<$t> { Some( 1.0 / 0.0) }
#[inline(always)]
static pure fn neg_inf() -> Option<$t> { Some(-1.0 / 0.0) }
fn neg_inf() -> Option<$t> { Some(-1.0 / 0.0) }
#[inline(always)]
static 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)] static pure fn NaN() -> Option<$t> { None }
#[inline(always)] static pure fn inf() -> Option<$t> { None }
#[inline(always)] static pure fn neg_inf() -> Option<$t> { None }
#[inline(always)] static 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<T:NumCast+Zero+One+Eq+Ord+NumStrConv+Copy+
pub fn to_str_bytes_common<T:NumCast+Zero+One+Eq+Ord+NumStrConv+Copy+
Div<T,T>+Neg<T>+Modulo<T,T>+Mul<T,T>>(
num: &T, radix: uint, negative_zero: bool,
sign: SignFormat, digits: SignificantDigits) -> (~[u8], bool) {
@ -383,7 +383,7 @@ pub pure fn to_str_bytes_common<T:NumCast+Zero+One+Eq+Ord+NumStrConv+Copy+
* `to_str_bytes_common()`, for details see there.
*/
#[inline(always)]
pub pure fn to_str_common<T:NumCast+Zero+One+Eq+Ord+NumStrConv+Copy+
pub fn to_str_common<T:NumCast+Zero+One+Eq+Ord+NumStrConv+Copy+
Div<T,T>+Neg<T>+Modulo<T,T>+Mul<T,T>>(
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<T:NumCast+Zero+One+Ord+Copy+Div<T,T>+
pub fn from_str_bytes_common<T:NumCast+Zero+One+Ord+Copy+Div<T,T>+
Mul<T,T>+Sub<T,T>+Neg<T>+Add<T,T>+
NumStrConv>(
buf: &[u8], radix: uint, negative: bool, fractional: bool,
@ -628,7 +628,7 @@ pub pure fn from_str_bytes_common<T:NumCast+Zero+One+Ord+Copy+Div<T,T>+
* `from_str_bytes_common()`, for details see there.
*/
#[inline(always)]
pub pure fn from_str_common<T:NumCast+Zero+One+Ord+Copy+Div<T,T>+Mul<T,T>+
pub fn from_str_common<T:NumCast+Zero+One+Ord+Copy+Div<T,T>+Mul<T,T>+
Sub<T,T>+Neg<T>+Add<T,T>+NumStrConv>(
buf: &str, radix: uint, negative: bool, fractional: bool,
special: bool, exponent: ExponentFormat, empty_zero: bool

View File

@ -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)]
static pure fn zero() -> T { 0 }
fn zero() -> T { 0 }
}
impl num::One for T {
#[inline(always)]
static pure fn one() -> T { 1 }
fn one() -> T { 1 }
}
#[cfg(notest)]
impl ops::Add<T,T> for T {
pure fn add(&self, other: &T) -> T { *self + *other }
fn add(&self, other: &T) -> T { *self + *other }
}
#[cfg(notest)]
impl ops::Sub<T,T> for T {
pure fn sub(&self, other: &T) -> T { *self - *other }
fn sub(&self, other: &T) -> T { *self - *other }
}
#[cfg(notest)]
impl ops::Mul<T,T> for T {
pure fn mul(&self, other: &T) -> T { *self * *other }
fn mul(&self, other: &T) -> T { *self * *other }
}
#[cfg(notest)]
impl ops::Div<T,T> for T {
pure fn div(&self, other: &T) -> T { *self / *other }
fn div(&self, other: &T) -> T { *self / *other }
}
#[cfg(notest)]
impl ops::Modulo<T,T> for T {
pure fn modulo(&self, other: &T) -> T { *self % *other }
fn modulo(&self, other: &T) -> T { *self % *other }
}
#[cfg(notest)]
impl ops::Neg<T> 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<T> {
pub fn from_str(s: &str) -> Option<T> {
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<T> {
pub fn from_str_radix(s: &str, radix: uint) -> Option<T> {
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<T> {
pub fn parse_bytes(buf: &[u8], radix: uint) -> Option<T> {
strconv::from_str_bytes_common(buf, radix, false, false, false,
strconv::ExpNone, false)
}
impl FromStr for T {
#[inline(always)]
static pure fn from_str(s: &str) -> Option<T> {
fn from_str(s: &str) -> Option<T> {
from_str(s)
}
}
impl FromStrRadix for T {
#[inline(always)]
static pure fn from_str_radix(&self, s: &str, radix: uint) -> Option<T> {
fn from_str_radix(s: &str, radix: uint) -> Option<T> {
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<U>(n: T, radix: uint, f: &fn(v: &[u8]) -> U) -> U {
pub fn to_str_bytes<U>(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<U>(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)
}
}

View File

@ -24,23 +24,23 @@ impl NumCast for u16 {
* Cast `n` to a `u16`
*/
#[inline(always)]
static pure fn from<N:NumCast>(n: N) -> u16 { n.to_u16() }
fn from<N:NumCast>(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]

View File

@ -24,23 +24,23 @@ impl NumCast for u32 {
* Cast `n` to a `u32`
*/
#[inline(always)]
static pure fn from<N:NumCast>(n: N) -> u32 { n.to_u32() }
fn from<N:NumCast>(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]

View File

@ -24,23 +24,23 @@ impl NumCast for u64 {
* Cast `n` to a `u64`
*/
#[inline(always)]
static pure fn from<N:NumCast>(n: N) -> u64 { n.to_u64() }
fn from<N:NumCast>(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]

View File

@ -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)]
static pure fn from<N:NumCast>(n: N) -> u8 { n.to_u8() }
fn from<N:NumCast>(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]

View File

@ -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::<uint>() * 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)]
static pure fn from<N:NumCast>(n: N) -> uint { n.to_uint() }
fn from<N:NumCast>(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]

View File

@ -17,65 +17,65 @@ pub trait Drop {
#[lang="add"]
pub trait Add<RHS,Result> {
pure fn add(&self, rhs: &RHS) -> Result;
fn add(&self, rhs: &RHS) -> Result;
}
#[lang="sub"]
pub trait Sub<RHS,Result> {
pure fn sub(&self, rhs: &RHS) -> Result;
fn sub(&self, rhs: &RHS) -> Result;
}
#[lang="mul"]
pub trait Mul<RHS,Result> {
pure fn mul(&self, rhs: &RHS) -> Result;
fn mul(&self, rhs: &RHS) -> Result;
}
#[lang="div"]
pub trait Div<RHS,Result> {
pure fn div(&self, rhs: &RHS) -> Result;
fn div(&self, rhs: &RHS) -> Result;
}
#[lang="modulo"]
pub trait Modulo<RHS,Result> {
pure fn modulo(&self, rhs: &RHS) -> Result;
fn modulo(&self, rhs: &RHS) -> Result;
}
#[lang="neg"]
pub trait Neg<Result> {
pure fn neg(&self) -> Result;
fn neg(&self) -> Result;
}
#[lang="not"]
pub trait Not<Result> {
pure fn not(&self) -> Result;
fn not(&self) -> Result;
}
#[lang="bitand"]
pub trait BitAnd<RHS,Result> {
pure fn bitand(&self, rhs: &RHS) -> Result;
fn bitand(&self, rhs: &RHS) -> Result;
}
#[lang="bitor"]
pub trait BitOr<RHS,Result> {
pure fn bitor(&self, rhs: &RHS) -> Result;
fn bitor(&self, rhs: &RHS) -> Result;
}
#[lang="bitxor"]
pub trait BitXor<RHS,Result> {
pure fn bitxor(&self, rhs: &RHS) -> Result;
fn bitxor(&self, rhs: &RHS) -> Result;
}
#[lang="shl"]
pub trait Shl<RHS,Result> {
pure fn shl(&self, rhs: &RHS) -> Result;
fn shl(&self, rhs: &RHS) -> Result;
}
#[lang="shr"]
pub trait Shr<RHS,Result> {
pure fn shr(&self, rhs: &RHS) -> Result;
fn shr(&self, rhs: &RHS) -> Result;
}
#[lang="index"]
pub trait Index<Index,Result> {
pure fn index(&self, index: Index) -> Result;
fn index(&self, index: Index) -> Result;
}

View File

@ -59,7 +59,7 @@ pub enum Option<T> {
}
impl<T:Ord> Ord for Option<T> {
pure fn lt(&self, other: &Option<T>) -> bool {
fn lt(&self, other: &Option<T>) -> bool {
match (self, other) {
(&None, &None) => false,
(&None, &Some(_)) => true,
@ -68,7 +68,7 @@ impl<T:Ord> Ord for Option<T> {
}
}
pure fn le(&self, other: &Option<T>) -> bool {
fn le(&self, other: &Option<T>) -> bool {
match (self, other) {
(&None, &None) => true,
(&None, &Some(_)) => true,
@ -77,18 +77,18 @@ impl<T:Ord> Ord for Option<T> {
}
}
pure fn ge(&self, other: &Option<T>) -> bool {
fn ge(&self, other: &Option<T>) -> bool {
! (self < other)
}
pure fn gt(&self, other: &Option<T>) -> bool {
fn gt(&self, other: &Option<T>) -> bool {
! (self <= other)
}
}
impl<T: Copy + Add<T,T>> Add<Option<T>, Option<T>> for Option<T> {
#[inline(always)]
pure fn add(&self, other: &Option<T>) -> Option<T> {
fn add(&self, other: &Option<T>) -> Option<T> {
match (*self, *other) {
(None, None) => None,
(_, None) => *self,
@ -99,7 +99,7 @@ impl<T: Copy + Add<T,T>> Add<Option<T>, Option<T>> for Option<T> {
}
#[inline(always)]
pub pure fn get<T:Copy>(opt: Option<T>) -> T {
pub fn get<T:Copy>(opt: Option<T>) -> T {
/*!
Gets the value out of an option
@ -122,7 +122,7 @@ pub pure fn get<T:Copy>(opt: Option<T>) -> T {
}
#[inline(always)]
pub pure fn get_ref<T>(opt: &'r Option<T>) -> &'r T {
pub fn get_ref<T>(opt: &'r Option<T>) -> &'r T {
/*!
Gets an immutable reference to the value inside an option.
@ -143,7 +143,7 @@ pub pure fn get_ref<T>(opt: &'r Option<T>) -> &'r T {
}
}
pub pure fn get_mut_ref<T>(opt: &'r mut Option<T>) -> &'r mut T {
pub fn get_mut_ref<T>(opt: &'r mut Option<T>) -> &'r mut T {
/*!
Gets a mutable reference to the value inside an option.
@ -165,14 +165,14 @@ pub pure fn get_mut_ref<T>(opt: &'r mut Option<T>) -> &'r mut T {
}
#[inline(always)]
pub pure fn map<T, U>(opt: &'r Option<T>, f: &fn(x: &'r T) -> U) -> Option<U> {
pub fn map<T, U>(opt: &'r Option<T>, f: &fn(x: &'r T) -> U) -> Option<U> {
//! 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<T, U>(opt: Option<T>,
pub fn map_consume<T, U>(opt: Option<T>,
f: &fn(v: T) -> U) -> Option<U> {
/*!
* As `map`, but consumes the option and gives `f` ownership to avoid
@ -182,7 +182,7 @@ pub pure fn map_consume<T, U>(opt: Option<T>,
}
#[inline(always)]
pub pure fn chain<T, U>(opt: Option<T>,
pub fn chain<T, U>(opt: Option<T>,
f: &fn(t: T) -> Option<U>) -> Option<U> {
/*!
* Update an optional value by optionally running its content through a
@ -196,7 +196,7 @@ pub pure fn chain<T, U>(opt: Option<T>,
}
#[inline(always)]
pub pure fn chain_ref<T, U>(opt: &Option<T>,
pub fn chain_ref<T, U>(opt: &Option<T>,
f: &fn(x: &T) -> Option<U>) -> Option<U> {
/*!
* Update an optional value by optionally running its content by reference
@ -207,7 +207,7 @@ pub pure fn chain_ref<T, U>(opt: &Option<T>,
}
#[inline(always)]
pub pure fn or<T>(opta: Option<T>, optb: Option<T>) -> Option<T> {
pub fn or<T>(opta: Option<T>, optb: Option<T>) -> Option<T> {
/*!
* Returns the leftmost Some() value, or None if both are None.
*/
@ -218,7 +218,7 @@ pub pure fn or<T>(opta: Option<T>, optb: Option<T>) -> Option<T> {
}
#[inline(always)]
pub pure fn while_some<T>(x: Option<T>, blk: &fn(v: T) -> Option<T>) {
pub fn while_some<T>(x: Option<T>, blk: &fn(v: T) -> Option<T>) {
//! 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<T>(x: Option<T>, blk: &fn(v: T) -> Option<T>) {
}
#[inline(always)]
pub pure fn is_none<T>(opt: &const Option<T>) -> bool {
pub fn is_none<T>(opt: &const Option<T>) -> bool {
//! Returns true if the option equals `none`
match *opt { None => true, Some(_) => false }
}
#[inline(always)]
pub pure fn is_some<T>(opt: &const Option<T>) -> bool {
pub fn is_some<T>(opt: &const Option<T>) -> bool {
//! Returns true if the option contains some value
!is_none(opt)
}
#[inline(always)]
pub pure fn get_or_zero<T:Copy + Zero>(opt: Option<T>) -> T {
pub fn get_or_zero<T:Copy + Zero>(opt: Option<T>) -> 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<T:Copy>(opt: Option<T>, def: T) -> T {
pub fn get_or_default<T:Copy>(opt: Option<T>, 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<T, U>(opt: &'r Option<T>, def: U,
pub fn map_default<T, U>(opt: &'r Option<T>, 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<T, U>(opt: &'r Option<T>, def: U,
}
#[inline(always)]
pub pure fn unwrap<T>(opt: Option<T>) -> T {
pub fn unwrap<T>(opt: Option<T>) -> T {
/*!
Moves a value out of an option type and returns it.
@ -302,7 +302,7 @@ pub fn swap_unwrap<T>(opt: &mut Option<T>) -> T {
}
#[inline(always)]
pub pure fn expect<T>(opt: Option<T>, reason: &str) -> T {
pub fn expect<T>(opt: Option<T>, reason: &str) -> T {
//! As unwrap, but with a specified failure message.
match opt {
Some(val) => val,
@ -313,12 +313,12 @@ pub pure fn expect<T>(opt: Option<T>, reason: &str) -> T {
impl<T> BaseIter<T> for Option<T> {
/// 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<uint> {
fn size_hint(&self) -> Option<uint> {
if self.is_some() { Some(1) } else { Some(0) }
}
}
@ -333,42 +333,42 @@ impl<T> MutableIter<T> for Option<T> {
pub impl<T> Option<T> {
/// 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<U>(&self, f: &fn(x: &T) -> Option<U>) -> Option<U> {
fn chain_ref<U>(&self, f: &fn(x: &T) -> Option<U>) -> Option<U> {
chain_ref(self, f)
}
/// Maps a `some` value from one type to another by reference
#[inline(always)]
pure fn map<U>(&self, f: &fn(&'self T) -> U) -> Option<U> { map(self, f) }
fn map<U>(&self, f: &fn(&'self T) -> U) -> Option<U> { map(self, f) }
/// As `map`, but consumes the option and gives `f` ownership to avoid
/// copying.
#[inline(always)]
pure fn map_consume<U>(self, f: &fn(v: T) -> U) -> Option<U> {
fn map_consume<U>(self, f: &fn(v: T) -> U) -> Option<U> {
map_consume(self, f)
}
/// Applies a function to the contained value or returns a default
#[inline(always)]
pure fn map_default<U>(&self, def: U, f: &fn(&'self T) -> U) -> U {
fn map_default<U>(&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<U>(self, def: U, f: &fn(v: T) -> U) -> U {
fn map_consume_default<U>(self, def: U, f: &fn(v: T) -> U) -> U {
match self { None => def, Some(v) => f(v) }
}
@ -403,7 +403,7 @@ pub impl<T> Option<T> {
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<T> Option<T> {
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<T> Option<T> {
* 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<T> Option<T> {
* 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<T:Copy> Option<T> {
@ -471,21 +471,21 @@ pub impl<T:Copy> Option<T> {
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<T>) {
fn while_some(self, blk: &fn(v: T) -> Option<T>) {
while_some(self, blk)
}
}
pub impl<T:Copy + Zero> Option<T> {
#[inline(always)]
pure fn get_or_zero(self) -> T { get_or_zero(self) }
fn get_or_zero(self) -> T { get_or_zero(self) }
}
#[test]

View File

@ -15,20 +15,20 @@
#[cfg(notest)]
impl<T:Eq> 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<T:Ord> 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) }
}

View File

@ -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 {
static 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 {
static 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 {
static 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 &&

View File

@ -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<T:Owned,Tbuffer:Owned>(p: RecvPacketBuffered<T, Tbuffer>)
}
/// Returns true if messages are available.
pub pure fn peek<T:Owned,Tb:Owned>(p: &RecvPacketBuffered<T, Tb>) -> bool {
pub fn peek<T:Owned,Tb:Owned>(p: &RecvPacketBuffered<T, Tb>) -> bool {
match unsafe {(*p.header()).state} {
Empty | Terminated => false,
Blocked => fail!(~"peeking on blocked packet"),
@ -723,11 +723,11 @@ pub fn select2<A:Owned,Ab:Owned,B:Owned,Bb:Owned>(
#[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<T,Tbuffer> SendPacketBuffered<T,Tbuffer> {
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<T:Owned,Tbuffer:Owned> RecvPacketBuffered<T, Tbuffer> {
}
impl<T:Owned,Tbuffer:Owned> Selectable for RecvPacketBuffered<T, Tbuffer> {
pure fn header(&self) -> *PacketHeader {
fn header(&self) -> *PacketHeader {
match self.p {
Some(packet) => unsafe {
let packet = &*packet;

View File

@ -51,11 +51,11 @@ pub mod rusti {
/// Get an unsafe pointer to a value
#[inline(always)]
pub pure fn addr_of<T>(val: &T) -> *T { unsafe { rusti::addr_of(*val) } }
pub fn addr_of<T>(val: &T) -> *T { unsafe { rusti::addr_of(*val) } }
/// Calculate the offset from a pointer
#[inline(always)]
pub pure fn offset<T>(ptr: *T, count: uint) -> *T {
pub fn offset<T>(ptr: *T, count: uint) -> *T {
unsafe {
(ptr as uint + count * sys::size_of::<T>()) as *T
}
@ -63,7 +63,7 @@ pub pure fn offset<T>(ptr: *T, count: uint) -> *T {
/// Calculate the offset from a const pointer
#[inline(always)]
pub pure fn const_offset<T>(ptr: *const T, count: uint) -> *const T {
pub fn const_offset<T>(ptr: *const T, count: uint) -> *const T {
unsafe {
(ptr as uint + count * sys::size_of::<T>()) as *T
}
@ -71,7 +71,7 @@ pub pure fn const_offset<T>(ptr: *const T, count: uint) -> *const T {
/// Calculate the offset from a mut pointer
#[inline(always)]
pub pure fn mut_offset<T>(ptr: *mut T, count: uint) -> *mut T {
pub fn mut_offset<T>(ptr: *mut T, count: uint) -> *mut T {
(ptr as uint + count * sys::size_of::<T>()) as *mut T
}
@ -93,19 +93,19 @@ pub unsafe fn position<T>(buf: *T, f: &fn(&T) -> bool) -> uint {
/// Create an unsafe null pointer
#[inline(always)]
pub pure fn null<T>() -> *T { unsafe { cast::reinterpret_cast(&0u) } }
pub fn null<T>() -> *T { unsafe { cast::reinterpret_cast(&0u) } }
/// Create an unsafe mutable null pointer
#[inline(always)]
pub pure fn mut_null<T>() -> *mut T { unsafe { cast::reinterpret_cast(&0u) } }
pub fn mut_null<T>() -> *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<T>(ptr: *const T) -> bool { ptr == null() }
pub fn is_null<T>(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<T>(ptr: *const T) -> bool { !is_null(ptr) }
pub fn is_not_null<T>(ptr: *const T) -> bool { !is_null(ptr) }
/**
* Copies data from one location to another
@ -138,7 +138,7 @@ pub unsafe fn set_memory<T>(dst: *mut T, c: int, count: uint) {
reinterpret_cast.
*/
#[inline(always)]
pub pure fn to_unsafe_ptr<T>(thing: &T) -> *T {
pub fn to_unsafe_ptr<T>(thing: &T) -> *T {
unsafe { cast::reinterpret_cast(&thing) }
}
@ -148,7 +148,7 @@ pub pure fn to_unsafe_ptr<T>(thing: &T) -> *T {
reinterpret_cast.
*/
#[inline(always)]
pub pure fn to_const_unsafe_ptr<T>(thing: &const T) -> *const T {
pub fn to_const_unsafe_ptr<T>(thing: &const T) -> *const T {
unsafe { cast::reinterpret_cast(&thing) }
}
@ -158,7 +158,7 @@ pub pure fn to_const_unsafe_ptr<T>(thing: &const T) -> *const T {
reinterpret_cast.
*/
#[inline(always)]
pub pure fn to_mut_unsafe_ptr<T>(thing: &mut T) -> *mut T {
pub fn to_mut_unsafe_ptr<T>(thing: &mut T) -> *mut T {
unsafe { cast::reinterpret_cast(&thing) }
}
@ -170,7 +170,7 @@ pub pure fn to_mut_unsafe_ptr<T>(thing: &mut T) -> *mut T {
(I couldn't think of a cutesy name for this one.)
*/
#[inline(always)]
pub pure fn to_uint<T>(thing: &T) -> uint {
pub fn to_uint<T>(thing: &T) -> uint {
unsafe {
cast::reinterpret_cast(&thing)
}
@ -178,7 +178,7 @@ pub pure fn to_uint<T>(thing: &T) -> uint {
/// Determine if two borrowed pointers point to the same thing.
#[inline(always)]
pub pure fn ref_eq<T>(thing: &'a T, other: &'b T) -> bool {
pub fn ref_eq<T>(thing: &'a T, other: &'b T) -> bool {
to_uint(thing) == to_uint(other)
}
@ -223,46 +223,46 @@ pub unsafe fn array_each<T>(arr: **T, cb: &fn(*T)) {
}
pub trait Ptr<T> {
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<T> Ptr<T> 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<T> Ptr<T> 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<T> 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<T> 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<T> 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<T> 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<T> 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<T> 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<T> Ord for *const T {
#[cfg(notest)]
impl<T:Eq> 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<T:Eq> Eq for &'self const T {
#[cfg(notest)]
impl<T:Ord> 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)
}
}

View File

@ -22,95 +22,95 @@ use libc::size_t;
/// A type that can be randomly generated using an RNG
pub trait Rand {
static fn rand(rng: @rand::Rng) -> Self;
fn rand(rng: @rand::Rng) -> Self;
}
impl Rand for int {
static fn rand(rng: @rand::Rng) -> int {
fn rand(rng: @rand::Rng) -> int {
rng.gen_int()
}
}
impl Rand for i8 {
static fn rand(rng: @rand::Rng) -> i8 {
fn rand(rng: @rand::Rng) -> i8 {
rng.gen_i8()
}
}
impl Rand for i16 {
static fn rand(rng: @rand::Rng) -> i16 {
fn rand(rng: @rand::Rng) -> i16 {
rng.gen_i16()
}
}
impl Rand for i32 {
static fn rand(rng: @rand::Rng) -> i32 {
fn rand(rng: @rand::Rng) -> i32 {
rng.gen_i32()
}
}
impl Rand for i64 {
static fn rand(rng: @rand::Rng) -> i64 {
fn rand(rng: @rand::Rng) -> i64 {
rng.gen_i64()
}
}
impl Rand for u8 {
static fn rand(rng: @rand::Rng) -> u8 {
fn rand(rng: @rand::Rng) -> u8 {
rng.gen_u8()
}
}
impl Rand for u16 {
static fn rand(rng: @rand::Rng) -> u16 {
fn rand(rng: @rand::Rng) -> u16 {
rng.gen_u16()
}
}
impl Rand for u32 {
static fn rand(rng: @rand::Rng) -> u32 {
fn rand(rng: @rand::Rng) -> u32 {
rng.gen_u32()
}
}
impl Rand for u64 {
static fn rand(rng: @rand::Rng) -> u64 {
fn rand(rng: @rand::Rng) -> u64 {
rng.gen_u64()
}
}
impl Rand for float {
static fn rand(rng: @rand::Rng) -> float {
fn rand(rng: @rand::Rng) -> float {
rng.gen_float()
}
}
impl Rand for f32 {
static fn rand(rng: @rand::Rng) -> f32 {
fn rand(rng: @rand::Rng) -> f32 {
rng.gen_f32()
}
}
impl Rand for f64 {
static fn rand(rng: @rand::Rng) -> f64 {
fn rand(rng: @rand::Rng) -> f64 {
rng.gen_f64()
}
}
impl Rand for char {
static fn rand(rng: @rand::Rng) -> char {
fn rand(rng: @rand::Rng) -> char {
rng.gen_char()
}
}
impl Rand for bool {
static fn rand(rng: @rand::Rng) -> bool {
fn rand(rng: @rand::Rng) -> bool {
rng.gen_bool()
}
}
impl<T:Rand> Rand for Option<T> {
static fn rand(rng: @rand::Rng) -> Option<T> {
fn rand(rng: @rand::Rng) -> Option<T> {
if rng.gen_bool() {
Some(Rand::rand(rng))
} else {
@ -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
}

View File

@ -36,7 +36,7 @@ pub enum Result<T, U> {
* If the result is an error
*/
#[inline(always)]
pub pure fn get<T:Copy,U>(res: &Result<T, U>) -> T {
pub fn get<T:Copy,U>(res: &Result<T, U>) -> T {
match *res {
Ok(copy t) => t,
Err(ref the_err) => unsafe {
@ -53,7 +53,7 @@ pub pure fn get<T:Copy,U>(res: &Result<T, U>) -> T {
* If the result is an error
*/
#[inline(always)]
pub pure fn get_ref<T, U>(res: &'a Result<T, U>) -> &'a T {
pub fn get_ref<T, U>(res: &'a Result<T, U>) -> &'a T {
match *res {
Ok(ref t) => t,
Err(ref the_err) => unsafe {
@ -70,7 +70,7 @@ pub pure fn get_ref<T, U>(res: &'a Result<T, U>) -> &'a T {
* If the result is not an error
*/
#[inline(always)]
pub pure fn get_err<T, U: Copy>(res: &Result<T, U>) -> U {
pub fn get_err<T, U: Copy>(res: &Result<T, U>) -> U {
match *res {
Err(copy u) => u,
Ok(_) => fail!(~"get_err called on ok result")
@ -79,7 +79,7 @@ pub pure fn get_err<T, U: Copy>(res: &Result<T, U>) -> U {
/// Returns true if the result is `ok`
#[inline(always)]
pub pure fn is_ok<T, U>(res: &Result<T, U>) -> bool {
pub fn is_ok<T, U>(res: &Result<T, U>) -> bool {
match *res {
Ok(_) => true,
Err(_) => false
@ -88,7 +88,7 @@ pub pure fn is_ok<T, U>(res: &Result<T, U>) -> bool {
/// Returns true if the result is `err`
#[inline(always)]
pub pure fn is_err<T, U>(res: &Result<T, U>) -> bool {
pub fn is_err<T, U>(res: &Result<T, U>) -> bool {
!is_ok(res)
}
@ -99,7 +99,7 @@ pub pure fn is_err<T, U>(res: &Result<T, U>) -> bool {
* result variants are converted to `either::left`.
*/
#[inline(always)]
pub pure fn to_either<T:Copy,U:Copy>(res: &Result<U, T>)
pub fn to_either<T:Copy,U:Copy>(res: &Result<U, T>)
-> Either<T, U> {
match *res {
Ok(copy res) => either::Right(res),
@ -122,7 +122,7 @@ pub pure fn to_either<T:Copy,U:Copy>(res: &Result<U, T>)
* }
*/
#[inline(always)]
pub pure fn chain<T, U, V>(res: Result<T, V>, op: &fn(T)
pub fn chain<T, U, V>(res: Result<T, V>, op: &fn(T)
-> Result<U, V>) -> Result<U, V> {
match res {
Ok(t) => op(t),
@ -139,7 +139,7 @@ pub pure fn chain<T, U, V>(res: Result<T, V>, op: &fn(T)
* successful result while handling an error.
*/
#[inline(always)]
pub pure fn chain_err<T, U, V>(
pub fn chain_err<T, U, V>(
res: Result<T, V>,
op: &fn(t: V) -> Result<T, U>)
-> Result<T, U> {
@ -164,7 +164,7 @@ pub pure fn chain_err<T, U, V>(
* }
*/
#[inline(always)]
pub pure fn iter<T, E>(res: &Result<T, E>, f: &fn(&T)) {
pub fn iter<T, E>(res: &Result<T, E>, f: &fn(&T)) {
match *res {
Ok(ref t) => f(t),
Err(_) => ()
@ -180,7 +180,7 @@ pub pure fn iter<T, E>(res: &Result<T, E>, f: &fn(&T)) {
* handling an error.
*/
#[inline(always)]
pub pure fn iter_err<T, E>(res: &Result<T, E>, f: &fn(&E)) {
pub fn iter_err<T, E>(res: &Result<T, E>, f: &fn(&E)) {
match *res {
Ok(_) => (),
Err(ref e) => f(e)
@ -202,7 +202,7 @@ pub pure fn iter_err<T, E>(res: &Result<T, E>, f: &fn(&E)) {
* }
*/
#[inline(always)]
pub pure fn map<T, E: Copy, U: Copy>(res: &Result<T, E>, op: &fn(&T) -> U)
pub fn map<T, E: Copy, U: Copy>(res: &Result<T, E>, op: &fn(&T) -> U)
-> Result<U, E> {
match *res {
Ok(ref t) => Ok(op(t)),
@ -219,7 +219,7 @@ pub pure fn map<T, E: Copy, U: Copy>(res: &Result<T, E>, op: &fn(&T) -> U)
* successful result while handling an error.
*/
#[inline(always)]
pub pure fn map_err<T:Copy,E,F:Copy>(res: &Result<T, E>, op: &fn(&E) -> F)
pub fn map_err<T:Copy,E,F:Copy>(res: &Result<T, E>, op: &fn(&E) -> F)
-> Result<T, F> {
match *res {
Ok(copy t) => Ok(t),
@ -229,53 +229,53 @@ pub pure fn map_err<T:Copy,E,F:Copy>(res: &Result<T, E>, op: &fn(&E) -> F)
pub impl<T, E> Result<T, E> {
#[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<U>(self, op: &fn(T) -> Result<U,E>) -> Result<U,E> {
fn chain<U>(self, op: &fn(T) -> Result<U,E>) -> Result<U,E> {
chain(self, op)
}
#[inline(always)]
pure fn chain_err<F>(self, op: &fn(E) -> Result<T,F>) -> Result<T,F> {
fn chain_err<F>(self, op: &fn(E) -> Result<T,F>) -> Result<T,F> {
chain_err(self, op)
}
}
pub impl<T:Copy,E> Result<T, E> {
#[inline(always)]
pure fn get(&self) -> T { get(self) }
fn get(&self) -> T { get(self) }
#[inline(always)]
pure fn map_err<F:Copy>(&self, op: &fn(&E) -> F) -> Result<T,F> {
fn map_err<F:Copy>(&self, op: &fn(&E) -> F) -> Result<T,F> {
map_err(self, op)
}
}
pub impl<T, E: Copy> Result<T, E> {
#[inline(always)]
pure fn get_err(&self) -> E { get_err(self) }
fn get_err(&self) -> E { get_err(self) }
#[inline(always)]
pure fn map<U:Copy>(&self, op: &fn(&T) -> U) -> Result<U,E> {
fn map<U:Copy>(&self, op: &fn(&T) -> U) -> Result<U,E> {
map(self, op)
}
}
@ -375,7 +375,7 @@ pub fn iter_vec2<S,T,U:Copy>(ss: &[S], ts: &[T],
/// Unwraps a result, assuming it is an `ok(T)`
#[inline(always)]
pub pure fn unwrap<T, U>(res: Result<T, U>) -> T {
pub fn unwrap<T, U>(res: Result<T, U>) -> T {
match res {
Ok(t) => t,
Err(_) => fail!(~"unwrap called on an err result")
@ -384,7 +384,7 @@ pub pure fn unwrap<T, U>(res: Result<T, U>) -> T {
/// Unwraps a result, assuming it is an `err(U)`
#[inline(always)]
pub pure fn unwrap_err<T, U>(res: Result<T, U>) -> U {
pub fn unwrap_err<T, U>(res: Result<T, U>) -> U {
match res {
Err(u) => u,
Ok(_) => fail!(~"unwrap called on an ok result")

View File

@ -19,14 +19,14 @@ use cast::{transmute, transmute_mut_unsafe,
pub struct Context(~Registers);
pub impl Context {
static fn empty() -> Context {
fn empty() -> Context {
Context(new_regs())
}
/// Create a new context that will resume execution by running ~fn()
/// # Safety Note
/// The `start` closure must remain valid for the life of the Task
static fn new(start: &~fn(), stack: &mut StackSegment) -> Context {
fn new(start: &~fn(), stack: &mut StackSegment) -> Context {
// The C-ABI function that is the task entry point
extern fn task_start_wrapper(f: &~fn()) { (*f)() }
@ -49,7 +49,7 @@ pub impl Context {
return Context(regs);
}
static fn swap(out_context: &mut Context, in_context: &Context) {
fn swap(out_context: &mut Context, in_context: &Context) {
let out_regs: &mut Registers = match out_context {
&Context(~ref mut r) => r
};
@ -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<T>(ptr: *mut T, count: int) -> *mut T {
pub fn mut_offset<T>(ptr: *mut T, count: int) -> *mut T {
use core::sys::size_of;
unsafe {
(ptr as int + count * (size_of::<T>() as int)) as *mut T

View File

@ -50,11 +50,11 @@ pub struct Scheduler {
// complaining
type UnsafeTaskReceiver = sys::Closure;
trait HackAroundBorrowCk {
static fn from_fn(&fn(&mut Scheduler, ~Task)) -> Self;
fn from_fn(&fn(&mut Scheduler, ~Task)) -> Self;
fn to_fn(self) -> &fn(&mut Scheduler, ~Task);
}
impl HackAroundBorrowCk for UnsafeTaskReceiver {
static fn from_fn(f: &fn(&mut Scheduler, ~Task)) -> UnsafeTaskReceiver {
fn from_fn(f: &fn(&mut Scheduler, ~Task)) -> UnsafeTaskReceiver {
unsafe { transmute(f) }
}
fn to_fn(self) -> &fn(&mut Scheduler, ~Task) {
@ -70,7 +70,7 @@ enum CleanupJob {
pub impl Scheduler {
static pub fn new(event_loop: ~EventLoopObject) -> Scheduler {
pub fn new(event_loop: ~EventLoopObject) -> Scheduler {
Scheduler {
event_loop: event_loop,
task_queue: WorkQueue::new(),
@ -114,7 +114,7 @@ pub impl Scheduler {
return tlsched.take_scheduler();
}
static fn local(f: &fn(&mut Scheduler)) {
fn local(f: &fn(&mut Scheduler)) {
let mut tlsched = ThreadLocalScheduler::new();
f(tlsched.get_scheduler());
}
@ -296,7 +296,7 @@ pub struct Task {
}
impl Task {
static pub fn new(stack_pool: &mut StackPool, start: ~fn()) -> Task {
pub fn new(stack_pool: &mut StackPool, start: ~fn()) -> Task {
// XXX: Putting main into a ~ so it's a thin pointer and can
// be passed to the spawn function. Another unfortunate
// allocation
@ -337,7 +337,7 @@ impl Task {
struct ThreadLocalScheduler(tls::Key);
impl ThreadLocalScheduler {
static fn new() -> ThreadLocalScheduler {
fn new() -> ThreadLocalScheduler {
unsafe {
// NB: This assumes that the TLS key has been created prior.
// Currently done in rust_start.

View File

@ -15,7 +15,7 @@ pub struct StackSegment {
}
pub impl StackSegment {
static fn new(size: uint) -> StackSegment {
fn new(size: uint) -> StackSegment {
// Crate a block of uninitialized values
let mut stack = vec::with_capacity(size);
unsafe {
@ -37,7 +37,7 @@ pub impl StackSegment {
pub struct StackPool(());
impl StackPool {
static pub fn new() -> StackPool { StackPool(()) }
pub fn new() -> StackPool { StackPool(()) }
fn take_segment(&self, min_size: uint) -> StackSegment {
StackSegment::new(min_size)

View File

@ -20,7 +20,7 @@ struct Thread {
}
impl Thread {
static pub fn start(main: ~fn()) -> Thread {
pub fn start(main: ~fn()) -> Thread {
fn substart(main: &fn()) -> *raw_thread {
unsafe { rust_raw_thread_start(&main) }
}

View File

@ -74,7 +74,7 @@ impl Callback for NullCallback { }
/// A type that wraps a native handle
trait NativeHandle<T> {
static pub fn from_native_handle(T) -> Self;
pub fn from_native_handle(T) -> Self;
pub fn native_handle(&self) -> T;
}
@ -86,7 +86,7 @@ pub struct Loop {
}
pub impl Loop {
static fn new() -> Loop {
fn new() -> Loop {
let handle = unsafe { uvll::loop_new() };
fail_unless!(handle.is_not_null());
NativeHandle::from_native_handle(handle)
@ -102,7 +102,7 @@ pub impl Loop {
}
impl NativeHandle<*uvll::uv_loop_t> for Loop {
static fn from_native_handle(handle: *uvll::uv_loop_t) -> Loop {
fn from_native_handle(handle: *uvll::uv_loop_t) -> Loop {
Loop { handle: handle }
}
fn native_handle(&self) -> *uvll::uv_loop_t {
@ -132,7 +132,7 @@ type IdleCallback = ~fn(IdleWatcher, Option<UvError>);
impl Callback for IdleCallback { }
pub impl IdleWatcher {
static fn new(loop_: &mut Loop) -> IdleWatcher {
fn new(loop_: &mut Loop) -> IdleWatcher {
unsafe {
let handle = uvll::idle_new();
fail_unless!(handle.is_not_null());
@ -177,7 +177,7 @@ pub impl IdleWatcher {
}
impl NativeHandle<*uvll::uv_idle_t> for IdleWatcher {
static fn from_native_handle(handle: *uvll::uv_idle_t) -> IdleWatcher {
fn from_native_handle(handle: *uvll::uv_idle_t) -> IdleWatcher {
IdleWatcher(handle)
}
fn native_handle(&self) -> *uvll::uv_idle_t {
@ -307,7 +307,7 @@ pub impl StreamWatcher {
}
impl NativeHandle<*uvll::uv_stream_t> for StreamWatcher {
static fn from_native_handle(
fn from_native_handle(
handle: *uvll::uv_stream_t) -> StreamWatcher {
StreamWatcher(handle)
}
@ -328,7 +328,7 @@ type ConnectionCallback = ~fn(StreamWatcher, Option<UvError>);
impl Callback for ConnectionCallback { }
pub impl TcpWatcher {
static fn new(loop_: &mut Loop) -> TcpWatcher {
fn new(loop_: &mut Loop) -> TcpWatcher {
unsafe {
let size = size_of::<uvll::uv_tcp_t>() as size_t;
let handle = malloc(size) as *uvll::uv_tcp_t;
@ -421,7 +421,7 @@ pub impl TcpWatcher {
}
impl NativeHandle<*uvll::uv_tcp_t> for TcpWatcher {
static fn from_native_handle(handle: *uvll::uv_tcp_t) -> TcpWatcher {
fn from_native_handle(handle: *uvll::uv_tcp_t) -> TcpWatcher {
TcpWatcher(handle)
}
fn native_handle(&self) -> *uvll::uv_tcp_t {
@ -441,7 +441,7 @@ impl Request for ConnectRequest { }
impl ConnectRequest {
static fn new() -> ConnectRequest {
fn new() -> ConnectRequest {
let connect_handle = unsafe {
malloc(size_of::<uvll::uv_connect_t>() as size_t)
};
@ -465,7 +465,7 @@ impl ConnectRequest {
}
impl NativeHandle<*uvll::uv_connect_t> for ConnectRequest {
static fn from_native_handle(
fn from_native_handle(
handle: *uvll:: uv_connect_t) -> ConnectRequest {
ConnectRequest(handle)
}
@ -480,7 +480,7 @@ impl Request for WriteRequest { }
impl WriteRequest {
static fn new() -> WriteRequest {
fn new() -> WriteRequest {
let write_handle = unsafe {
malloc(size_of::<uvll::uv_write_t>() as size_t)
};
@ -503,7 +503,7 @@ impl WriteRequest {
}
impl NativeHandle<*uvll::uv_write_t> for WriteRequest {
static fn from_native_handle(handle: *uvll:: uv_write_t) -> WriteRequest {
fn from_native_handle(handle: *uvll:: uv_write_t) -> WriteRequest {
WriteRequest(handle)
}
fn native_handle(&self) -> *uvll::uv_write_t {
@ -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())
}
}

View File

@ -29,14 +29,14 @@ pub struct UvEventLoop {
}
pub impl UvEventLoop {
static fn new() -> UvEventLoop {
fn new() -> UvEventLoop {
UvEventLoop {
uvio: UvIoFactory(Loop::new())
}
}
/// A convenience constructor
static fn new_scheduler() -> Scheduler {
fn new_scheduler() -> Scheduler {
Scheduler::new(~UvEventLoop::new())
}
}
@ -221,7 +221,7 @@ impl TcpListener for UvTcpListener {
pub struct UvStream(StreamWatcher);
impl UvStream {
static fn new(watcher: StreamWatcher) -> UvStream {
fn new(watcher: StreamWatcher) -> UvStream {
UvStream(watcher)
}

View File

@ -15,7 +15,7 @@ pub struct WorkQueue<T> {
}
pub impl<T> WorkQueue<T> {
static fn new() -> WorkQueue<T> {
fn new() -> WorkQueue<T> {
WorkQueue {
queue: ~[]
}

File diff suppressed because it is too large Load Diff

View File

@ -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<T:Eq>(x1: &T, x2: &T) -> bool {
pub fn shape_eq<T:Eq>(x1: &T, x2: &T) -> bool {
*x1 == *x2
}
pub pure fn shape_lt<T:Ord>(x1: &T, x2: &T) -> bool {
pub fn shape_lt<T:Ord>(x1: &T, x2: &T) -> bool {
*x1 < *x2
}
pub pure fn shape_le<T:Ord>(x1: &T, x2: &T) -> bool {
pub fn shape_le<T:Ord>(x1: &T, x2: &T) -> bool {
*x1 <= *x2
}
@ -79,13 +79,13 @@ pub pure fn shape_le<T:Ord>(x1: &T, x2: &T) -> bool {
* performing dark magick.
*/
#[inline(always)]
pub pure fn get_type_desc<T>() -> *TypeDesc {
pub fn get_type_desc<T>() -> *TypeDesc {
unsafe { rusti::get_tydesc::<T>() as *TypeDesc }
}
/// Returns the size of a type
#[inline(always)]
pub pure fn size_of<T>() -> uint {
pub fn size_of<T>() -> uint {
unsafe { rusti::size_of::<T>() }
}
@ -95,7 +95,7 @@ pub pure fn size_of<T>() -> uint {
* Useful for building structures containing variable-length arrays.
*/
#[inline(always)]
pub pure fn nonzero_size_of<T>() -> uint {
pub fn nonzero_size_of<T>() -> uint {
let s = size_of::<T>();
if s == 0 { 1 } else { s }
}
@ -107,26 +107,26 @@ pub pure fn nonzero_size_of<T>() -> uint {
* than the preferred alignment.
*/
#[inline(always)]
pub pure fn min_align_of<T>() -> uint {
pub fn min_align_of<T>() -> uint {
unsafe { rusti::min_align_of::<T>() }
}
/// Returns the preferred alignment of a type
#[inline(always)]
pub pure fn pref_align_of<T>() -> uint {
pub fn pref_align_of<T>() -> uint {
unsafe { rusti::pref_align_of::<T>() }
}
/// Returns the refcount of a shared box (as just before calling this)
#[inline(always)]
pub pure fn refcount<T>(t: @T) -> uint {
pub fn refcount<T>(t: @T) -> uint {
unsafe {
let ref_ptr: *uint = cast::reinterpret_cast(&t);
*ref_ptr - 1
}
}
pub pure fn log_str<T>(t: &T) -> ~str {
pub fn log_str<T>(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: &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)

View File

@ -24,14 +24,14 @@ pub trait LocalData { }
impl<T:Durable> 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

View File

@ -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

View File

@ -126,7 +126,7 @@ type TaskGroupArc = unstable::Exclusive<Option<TaskGroupData>>;
type TaskGroupInner = &'self mut Option<TaskGroupData>;
// 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()
}

View File

@ -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<A:IterBytes> 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<A:IterBytes> IterBytes for &'self [A] {
impl<A:IterBytes,B:IterBytes> 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<A:IterBytes,B:IterBytes> IterBytes for (A,B) {
impl<A:IterBytes,B:IterBytes,C:IterBytes> 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<A:IterBytes,B:IterBytes,C:IterBytes> IterBytes for (A,B,C) {
}
// Move this to vec, probably.
pure fn borrow<A>(a: &'x [A]) -> &'x [A] {
fn borrow<A>(a: &'x [A]) -> &'x [A] {
a
}
impl<A:IterBytes> 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<A:IterBytes> 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:IterBytes,B:IterBytes>(a: &A, b: &B,
pub fn iter_bytes_2<A:IterBytes,B:IterBytes>(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:IterBytes,B:IterBytes>(a: &A, b: &B,
b.iter_bytes(lsb0, |bytes| {flag = z(bytes); flag});
}
pub pure fn iter_bytes_3<A: IterBytes,
pub fn iter_bytes_3<A: IterBytes,
B: IterBytes,
C: IterBytes>(a: &A, b: &B, c: &C,
lsb0: bool, z: Cb) {
@ -269,7 +269,7 @@ pub pure fn iter_bytes_3<A: IterBytes,
c.iter_bytes(lsb0, |bytes| {flag = z(bytes); flag});
}
pub pure fn iter_bytes_4<A: IterBytes,
pub fn iter_bytes_4<A: IterBytes,
B: IterBytes,
C: IterBytes,
D: IterBytes>(a: &A, b: &B, c: &C,
@ -285,7 +285,7 @@ pub pure fn iter_bytes_4<A: IterBytes,
d.iter_bytes(lsb0, |bytes| {flag = z(bytes); flag});
}
pub pure fn iter_bytes_5<A: IterBytes,
pub fn iter_bytes_5<A: IterBytes,
B: IterBytes,
C: IterBytes,
D: IterBytes,
@ -304,7 +304,7 @@ pub pure fn iter_bytes_5<A: IterBytes,
e.iter_bytes(lsb0, |bytes| {flag = z(bytes); flag});
}
pub pure fn iter_bytes_6<A: IterBytes,
pub fn iter_bytes_6<A: IterBytes,
B: IterBytes,
C: IterBytes,
D: IterBytes,
@ -326,7 +326,7 @@ pub pure fn iter_bytes_6<A: IterBytes,
f.iter_bytes(lsb0, |bytes| {flag = z(bytes); flag});
}
pub pure fn iter_bytes_7<A: IterBytes,
pub fn iter_bytes_7<A: IterBytes,
B: IterBytes,
C: IterBytes,
D: IterBytes,
@ -354,7 +354,7 @@ pub pure fn iter_bytes_7<A: IterBytes,
impl IterBytes for &'self str {
#[inline(always)]
pure fn iter_bytes(&self, _lsb0: bool, f: Cb) {
fn iter_bytes(&self, _lsb0: bool, f: Cb) {
do str::byte_slice(*self) |bytes| {
f(bytes);
}
@ -363,7 +363,7 @@ impl IterBytes for &'self str {
impl IterBytes for ~str {
#[inline(always)]
pure fn iter_bytes(&self, _lsb0: bool, f: Cb) {
fn iter_bytes(&self, _lsb0: bool, f: Cb) {
do str::byte_slice(*self) |bytes| {
f(bytes);
}
@ -372,7 +372,7 @@ impl IterBytes for ~str {
impl IterBytes for @str {
#[inline(always)]
pure fn iter_bytes(&self, _lsb0: bool, f: Cb) {
fn iter_bytes(&self, _lsb0: bool, f: Cb) {
do str::byte_slice(*self) |bytes| {
f(bytes);
}
@ -381,7 +381,7 @@ impl IterBytes for @str {
impl<A:IterBytes> IterBytes for Option<A> {
#[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<A:IterBytes> IterBytes for Option<A> {
impl<A:IterBytes> 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<A:IterBytes> 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<A:IterBytes> 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<A:IterBytes> IterBytes for ~A {
// to the target; it just gives you the pointer-bytes.
impl<A> 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);
}
}

View File

@ -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<A:ToStr,B:ToStr> 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<A:ToStr,B:ToStr> ToStr for (A, B) {
}
impl<A:ToStr,B:ToStr,C:ToStr> 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<A:ToStr,B:ToStr,C:ToStr> ToStr for (A, B, C) {
impl<A:ToStr> 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<A:ToStr> ToStr for &'self [A] {
impl<A:ToStr> 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<A:ToStr> ToStr for ~[A] {
impl<A:ToStr> ToStr for @[A] {
#[inline(always)]
pure fn to_str(&self) -> ~str {
fn to_str(&self) -> ~str {
unsafe {
// FIXME #4568
// Bleh -- not really unsafe

View File

@ -32,17 +32,17 @@ pub struct TrieMap<T> {
impl<T> BaseIter<(uint, &'self T)> for TrieMap<T> {
/// 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<uint> { Some(self.len()) }
fn size_hint(&self) -> Option<uint> { Some(self.len()) }
}
impl<T> ReverseIter<(uint, &'self T)> for TrieMap<T> {
/// 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<T> ReverseIter<(uint, &'self T)> for TrieMap<T> {
impl<T> Container for TrieMap<T> {
/// 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<T> Mutable for TrieMap<T> {
@ -69,19 +69,19 @@ impl<T> Mutable for TrieMap<T> {
impl<T> Map<uint, T> for TrieMap<T> {
/// 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<T> Map<uint, T> for TrieMap<T> {
/// 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<T> = &self.root;
let mut idx = 0;
loop {
@ -139,19 +139,19 @@ impl<T> Map<uint, T> for TrieMap<T> {
pub impl<T> TrieMap<T> {
/// Create an empty TrieMap
#[inline(always)]
static pure fn new() -> TrieMap<T> {
fn new() -> TrieMap<T> {
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<uint> 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<uint> { Some(self.len()) }
fn each(&self, f: &fn(&uint) -> bool) { self.map.each_key(f) }
fn size_hint(&self) -> Option<uint> { Some(self.len()) }
}
impl ReverseIter<uint> 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<uint> 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)]
static 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<T> {
impl<T> TrieNode<T> {
#[inline(always)]
static pure fn new() -> TrieNode<T> {
fn new() -> TrieNode<T> {
// FIXME: #5244: [Nothing, ..SIZE] should be possible without Copy
TrieNode{count: 0,
children: [Nothing, Nothing, Nothing, Nothing,
@ -231,7 +231,7 @@ impl<T> TrieNode<T> {
}
impl<T> TrieNode<T> {
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<T> TrieNode<T> {
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<T> TrieNode<T> {
// 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
}

View File

@ -16,30 +16,30 @@ use vec;
#[cfg(notest)] use cmp::{Eq, Ord};
pub trait CopyableTuple<T, U> {
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<T:Copy,U:Copy> CopyableTuple<T, U> 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<T:Copy,U:Copy> CopyableTuple<T, U> for (T, U) {
}
pub trait ImmutableTuple<T, U> {
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<T, U> ImmutableTuple<T, U> 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<A:Copy,B:Copy> ExtendedTupleOps<A,B> for (~[A], ~[B]) {
#[cfg(notest)]
impl<A:Eq,B:Eq> 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<A:Eq,B:Eq> 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<A:Ord,B:Ord> 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<A:Ord,B:Ord> 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<A:Eq,B:Eq,C:Eq> 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<A:Eq,B:Eq,C:Eq> 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<A:Ord,B:Ord,C:Ord> 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<A:Ord,B:Ord,C:Ord> 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]

View File

@ -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'

View File

@ -140,7 +140,7 @@ pub mod ct {
}
pub impl<T> Parsed<T> {
static pure fn new(&self, val: T, next: uint) -> Parsed<T> {
fn new(val: T, next: uint) -> Parsed<T> {
Parsed {val: val, next: next}
}
}
@ -705,7 +705,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);
@ -718,7 +718,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 {
@ -730,17 +730,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 {
@ -753,7 +753,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)
@ -768,14 +768,14 @@ pub mod rt {
}
return unsafe { pad(cv, s, PadFloat) };
}
pub pure fn conv_poly<T>(cv: Conv, v: &T) -> ~str {
pub fn conv_poly<T>(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) };
@ -784,7 +784,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 {
~""
@ -798,7 +798,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
@ -828,7 +828,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 = {
@ -858,7 +858,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
}
}

View File

@ -18,11 +18,11 @@ use prelude::*;
/// The identity function.
#[inline(always)]
pub pure fn id<T>(x: T) -> T { x }
pub fn id<T>(x: T) -> T { x }
/// Ignores a value.
#[inline(always)]
pub pure fn ignore<T>(_x: T) { }
pub fn ignore<T>(_x: T) { }
/// Sets `*ptr` to `new_value`, invokes `op()`, and then restores the
/// original value of `*ptr`.

File diff suppressed because it is too large Load Diff

View File

@ -25,8 +25,8 @@ fn vec_equal<T>(v: ~[T],
return true;
}
pure fn builtin_equal<T>(&&a: T, &&b: T) -> bool { return a == b; }
pure fn builtin_equal_int(&&a: int, &&b: int) -> bool { return a == b; }
fn builtin_equal<T>(&&a: T, &&b: T) -> bool { return a == b; }
fn builtin_equal_int(&&a: int, &&b: int) -> bool { return a == b; }
fn main() {
fail_unless!((builtin_equal(5, 5)));

View File

@ -95,11 +95,11 @@ pub fn common_exprs() -> ~[ast::expr] {
]
}
pub pure fn safe_to_steal_expr(e: @ast::expr, tm: test_mode) -> bool {
pub fn safe_to_steal_expr(e: @ast::expr, tm: test_mode) -> bool {
safe_to_use_expr(*e, tm)
}
pub pure fn safe_to_use_expr(e: ast::expr, tm: test_mode) -> bool {
pub fn safe_to_use_expr(e: ast::expr, tm: test_mode) -> bool {
match tm {
tm_converge => {
match e.node {

View File

@ -20,7 +20,7 @@ use core::util;
use core::vec;
use core::hashmap::linear::LinearSet;
pure fn not_win32(os: session::os) -> bool {
fn not_win32(os: session::os) -> bool {
match os {
session::os_win32 => false,
_ => true

View File

@ -872,7 +872,7 @@ pub fn get_item_attrs(cdata: cmd,
}
}
pure fn struct_field_family_to_visibility(family: Family) -> ast::visibility {
fn struct_field_family_to_visibility(family: Family) -> ast::visibility {
match family {
PublicField => ast::public,
PrivateField => ast::private,

View File

@ -444,7 +444,7 @@ pub impl LoanKind {
/// Creates and returns a new root_map
impl to_bytes::IterBytes for root_map_key {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
to_bytes::iter_bytes_2(&self.id, &self.derefs, lsb0, f);
}
}

View File

@ -82,7 +82,7 @@ pub struct LanguageItems {
}
pub impl LanguageItems {
static pub fn new(&self) -> LanguageItems {
pub fn new() -> LanguageItems {
LanguageItems {
items: [ None, ..35 ]
}
@ -96,7 +96,7 @@ pub impl LanguageItems {
}
}
static pub fn item_name(&self, index: uint) -> &'static str {
pub fn item_name(index: uint) -> &'static str {
match index {
0 => "const",
1 => "copy",

View File

@ -534,7 +534,7 @@ fn check_item_while_true(cx: ty::ctxt, it: @ast::item) {
}
fn check_item_type_limits(cx: ty::ctxt, it: @ast::item) {
pure fn is_valid<T:cmp::Ord>(binop: ast::binop, v: T,
fn is_valid<T:cmp::Ord>(binop: ast::binop, v: T,
min: T, max: T) -> bool {
match binop {
ast::lt => v <= max,
@ -546,7 +546,7 @@ fn check_item_type_limits(cx: ty::ctxt, it: @ast::item) {
}
}
pure fn rev_binop(binop: ast::binop) -> ast::binop {
fn rev_binop(binop: ast::binop) -> ast::binop {
match binop {
ast::lt => ast::gt,
ast::le => ast::ge,
@ -556,7 +556,7 @@ fn check_item_type_limits(cx: ty::ctxt, it: @ast::item) {
}
}
pure fn int_ty_range(int_ty: ast::int_ty) -> (i64, i64) {
fn int_ty_range(int_ty: ast::int_ty) -> (i64, i64) {
match int_ty {
ast::ty_i => (int::min_value as i64, int::max_value as i64),
ast::ty_char => (u32::min_value as i64, u32::max_value as i64),
@ -567,7 +567,7 @@ fn check_item_type_limits(cx: ty::ctxt, it: @ast::item) {
}
}
pure fn uint_ty_range(uint_ty: ast::uint_ty) -> (u64, u64) {
fn uint_ty_range(uint_ty: ast::uint_ty) -> (u64, u64) {
match uint_ty {
ast::ty_u => (uint::min_value as u64, uint::max_value as u64),
ast::ty_u8 => (u8::min_value as u64, u8::max_value as u64),
@ -622,7 +622,7 @@ fn check_item_type_limits(cx: ty::ctxt, it: @ast::item) {
}
}
pure fn is_comparison(binop: ast::binop) -> bool {
fn is_comparison(binop: ast::binop) -> bool {
match binop {
ast::eq | ast::lt | ast::le |
ast::ne | ast::ge | ast::gt => true,

View File

@ -141,13 +141,13 @@ struct Variable(uint);
struct LiveNode(uint);
impl cmp::Eq for Variable {
pure fn eq(&self, other: &Variable) -> bool { *(*self) == *(*other) }
pure fn ne(&self, other: &Variable) -> bool { *(*self) != *(*other) }
fn eq(&self, other: &Variable) -> bool { *(*self) == *(*other) }
fn ne(&self, other: &Variable) -> bool { *(*self) != *(*other) }
}
impl cmp::Eq for LiveNode {
pure fn eq(&self, other: &LiveNode) -> bool { *(*self) == *(*other) }
pure fn ne(&self, other: &LiveNode) -> bool { *(*self) != *(*other) }
fn eq(&self, other: &LiveNode) -> bool { *(*self) == *(*other) }
fn ne(&self, other: &LiveNode) -> bool { *(*self) != *(*other) }
}
enum LiveNodeKind {
@ -158,7 +158,7 @@ enum LiveNodeKind {
}
impl cmp::Eq for LiveNodeKind {
pure fn eq(&self, other: &LiveNodeKind) -> bool {
fn eq(&self, other: &LiveNodeKind) -> bool {
match (*self) {
FreeVarNode(e0a) => {
match (*other) {
@ -186,7 +186,7 @@ impl cmp::Eq for LiveNodeKind {
}
}
}
pure fn ne(&self, other: &LiveNodeKind) -> bool { !(*self).eq(other) }
fn ne(&self, other: &LiveNodeKind) -> bool { !(*self).eq(other) }
}
fn live_node_kind_to_str(lnk: LiveNodeKind, cx: ty::ctxt) -> ~str {
@ -224,11 +224,11 @@ pub fn check_crate(tcx: ty::ctxt,
}
impl to_str::ToStr for LiveNode {
pure fn to_str(&self) -> ~str { fmt!("ln(%u)", **self) }
fn to_str(&self) -> ~str { fmt!("ln(%u)", **self) }
}
impl to_str::ToStr for Variable {
pure fn to_str(&self) -> ~str { fmt!("v(%u)", **self) }
fn to_str(&self) -> ~str { fmt!("v(%u)", **self) }
}
// ______________________________________________________________________
@ -254,7 +254,7 @@ impl to_str::ToStr for Variable {
// assignment. And so forth.
pub impl LiveNode {
pure fn is_valid(&self) -> bool { **self != uint::max_value }
fn is_valid(&self) -> bool { **self != uint::max_value }
}
fn invalid_node() -> LiveNode { LiveNode(uint::max_value) }

View File

@ -305,13 +305,13 @@ pub struct mem_categorization_ctxt {
}
impl ToStr for MutabilityCategory {
pure fn to_str(&self) -> ~str {
fn to_str(&self) -> ~str {
fmt!("%?", *self)
}
}
pub impl MutabilityCategory {
static fn from_mutbl(&self, m: ast::mutability) -> MutabilityCategory {
fn from_mutbl(m: ast::mutability) -> MutabilityCategory {
match m {
m_imm => McImmutable,
m_const => McReadOnly,

View File

@ -151,7 +151,7 @@ pub enum NamespaceResult {
}
pub impl NamespaceResult {
pure fn is_unknown(&self) -> bool {
fn is_unknown(&self) -> bool {
match *self {
UnknownResult => true,
_ => false

View File

@ -41,10 +41,10 @@ enum x86_64_reg_class {
}
impl cmp::Eq for x86_64_reg_class {
pure fn eq(&self, other: &x86_64_reg_class) -> bool {
fn eq(&self, other: &x86_64_reg_class) -> bool {
((*self) as uint) == ((*other) as uint)
}
pure fn ne(&self, other: &x86_64_reg_class) -> bool { !(*self).eq(other) }
fn ne(&self, other: &x86_64_reg_class) -> bool { !(*self).eq(other) }
}
fn is_sse(++c: x86_64_reg_class) -> bool {

View File

@ -678,9 +678,9 @@ pub fn block_parent(cx: block) -> block {
// Accessors
pub impl block_ {
pure fn ccx(@mut self) -> @CrateContext { *self.fcx.ccx }
pure fn tcx(@mut self) -> ty::ctxt { self.fcx.ccx.tcx }
pure fn sess(@mut self) -> Session { self.fcx.ccx.sess }
fn ccx(@mut self) -> @CrateContext { *self.fcx.ccx }
fn tcx(@mut self) -> ty::ctxt { self.fcx.ccx.tcx }
fn sess(@mut self) -> Session { self.fcx.ccx.sess }
fn node_id_to_str(@mut self, id: ast::node_id) -> ~str {
ast_map::node_id_to_str(self.tcx().items, id, self.sess().intr())
@ -1290,7 +1290,7 @@ pub struct mono_id_ {
pub type mono_id = @mono_id_;
impl to_bytes::IterBytes for mono_param_id {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
match *self {
mono_precise(t, ref mids) =>
to_bytes::iter_bytes_3(&0u8, &ty::type_id(t), mids, lsb0, f),
@ -1304,7 +1304,7 @@ impl to_bytes::IterBytes for mono_param_id {
}
impl to_bytes::IterBytes for mono_id_ {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
to_bytes::iter_bytes_2(&self.def, &self.params, lsb0, f);
}
}

View File

@ -158,14 +158,14 @@ pub impl DatumMode {
}
impl cmp::Eq for DatumMode {
pure fn eq(&self, other: &DatumMode) -> bool {
fn eq(&self, other: &DatumMode) -> bool {
(*self) as uint == (*other as uint)
}
pure fn ne(&self, other: &DatumMode) -> bool { !(*self).eq(other) }
fn ne(&self, other: &DatumMode) -> bool { !(*self).eq(other) }
}
impl to_bytes::IterBytes for DatumMode {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
(*self as uint).iter_bytes(lsb0, f)
}
}

View File

@ -175,7 +175,7 @@ pub impl Dest {
}
impl cmp::Eq for Dest {
pure fn eq(&self, other: &Dest) -> bool {
fn eq(&self, other: &Dest) -> bool {
match ((*self), (*other)) {
(SaveIn(e0a), SaveIn(e0b)) => e0a == e0b,
(Ignore, Ignore) => true,
@ -183,7 +183,7 @@ impl cmp::Eq for Dest {
(Ignore, _) => false,
}
}
pure fn ne(&self, other: &Dest) -> bool { !(*self).eq(other) }
fn ne(&self, other: &Dest) -> bool { !(*self).eq(other) }
}
fn drop_and_cancel_clean(bcx: block, dat: Datum) -> block {
@ -1695,7 +1695,7 @@ pub enum cast_kind {
}
impl cmp::Eq for cast_kind {
pure fn eq(&self, other: &cast_kind) -> bool {
fn eq(&self, other: &cast_kind) -> bool {
match ((*self), (*other)) {
(cast_pointer, cast_pointer) => true,
(cast_integral, cast_integral) => true,
@ -1709,7 +1709,7 @@ impl cmp::Eq for cast_kind {
(cast_other, _) => false,
}
}
pure fn ne(&self, other: &cast_kind) -> bool { !(*self).eq(other) }
fn ne(&self, other: &cast_kind) -> bool { !(*self).eq(other) }
}
pub fn cast_type_kind(t: ty::t) -> cast_kind {

View File

@ -218,8 +218,8 @@ pub fn simplified_glue_type(tcx: ty::ctxt, field: uint, t: ty::t) -> ty::t {
return t;
}
pub pure fn cast_glue(ccx: @CrateContext, ti: @mut tydesc_info, v: ValueRef)
-> ValueRef {
pub fn cast_glue(ccx: @CrateContext, ti: @mut tydesc_info, v: ValueRef)
-> ValueRef {
unsafe {
let llfnty = type_of_glue_fn(ccx, ti.ty);
llvm::LLVMConstPointerCast(v, T_ptr(llfnty))

View File

@ -282,7 +282,7 @@ pub fn trans_static_method_callee(bcx: block,
// When we translate a static fn defined in a trait like:
//
// trait<T1...Tn> Trait {
// static fn foo<M1...Mn>(...) {...}
// fn foo<M1...Mn>(...) {...}
// }
//
// this winds up being translated as something like:

View File

@ -121,7 +121,7 @@ pub struct creader_cache_key {
type creader_cache = HashMap<creader_cache_key, t>;
impl to_bytes::IterBytes for creader_cache_key {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
to_bytes::iter_bytes_3(&self.cnum, &self.pos, &self.len, lsb0, f);
}
}
@ -135,18 +135,18 @@ struct intern_key {
// implementation will not recurse through sty and you will get stack
// exhaustion.
impl cmp::Eq for intern_key {
pure fn eq(&self, other: &intern_key) -> bool {
fn eq(&self, other: &intern_key) -> bool {
unsafe {
*self.sty == *other.sty && self.o_def_id == other.o_def_id
}
}
pure fn ne(&self, other: &intern_key) -> bool {
fn ne(&self, other: &intern_key) -> bool {
!self.eq(other)
}
}
impl to_bytes::IterBytes for intern_key {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
unsafe {
to_bytes::iter_bytes_2(&*self.sty, &self.o_def_id, lsb0, f);
}
@ -165,7 +165,7 @@ pub type opt_region_variance = Option<region_variance>;
pub enum region_variance { rv_covariant, rv_invariant, rv_contravariant }
impl cmp::Eq for region_variance {
pure fn eq(&self, other: &region_variance) -> bool {
fn eq(&self, other: &region_variance) -> bool {
match ((*self), (*other)) {
(rv_covariant, rv_covariant) => true,
(rv_invariant, rv_invariant) => true,
@ -175,7 +175,7 @@ impl cmp::Eq for region_variance {
(rv_contravariant, _) => false
}
}
pure fn ne(&self, other: &region_variance) -> bool { !(*self).eq(other) }
fn ne(&self, other: &region_variance) -> bool { !(*self).eq(other) }
}
#[auto_encode]
@ -334,7 +334,7 @@ struct t_box_ {
enum t_opaque {}
pub type t = *t_opaque;
pub pure fn get(t: t) -> t_box {
pub fn get(t: t) -> t_box {
unsafe {
let t2 = cast::reinterpret_cast::<t, t_box>(&t);
let t3 = t2;
@ -343,21 +343,21 @@ pub pure fn get(t: t) -> t_box {
}
}
pub pure fn tbox_has_flag(tb: t_box, flag: tbox_flag) -> bool {
pub fn tbox_has_flag(tb: t_box, flag: tbox_flag) -> bool {
(tb.flags & (flag as uint)) != 0u
}
pub pure fn type_has_params(t: t) -> bool {
pub fn type_has_params(t: t) -> bool {
tbox_has_flag(get(t), has_params)
}
pub pure fn type_has_self(t: t) -> bool { tbox_has_flag(get(t), has_self) }
pub pure fn type_needs_infer(t: t) -> bool {
pub fn type_has_self(t: t) -> bool { tbox_has_flag(get(t), has_self) }
pub fn type_needs_infer(t: t) -> bool {
tbox_has_flag(get(t), needs_infer)
}
pub pure fn type_has_regions(t: t) -> bool {
pub fn type_has_regions(t: t) -> bool {
tbox_has_flag(get(t), has_regions)
}
pub pure fn type_def_id(t: t) -> Option<ast::def_id> { get(t).o_def_id }
pub pure fn type_id(t: t) -> uint { get(t).id }
pub fn type_def_id(t: t) -> Option<ast::def_id> { get(t).o_def_id }
pub fn type_id(t: t) -> uint { get(t).id }
#[deriving(Eq)]
pub struct BareFnTy {
@ -388,13 +388,13 @@ pub struct FnSig {
}
impl to_bytes::IterBytes for BareFnTy {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
to_bytes::iter_bytes_3(&self.purity, &self.abi, &self.sig, lsb0, f)
}
}
impl to_bytes::IterBytes for ClosureTy {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
to_bytes::iter_bytes_5(&self.purity, &self.sigil, &self.onceness,
&self.region, &self.sig, lsb0, f)
}
@ -407,7 +407,7 @@ pub struct param_ty {
}
impl to_bytes::IterBytes for param_ty {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
to_bytes::iter_bytes_2(&self.idx, &self.def_id, lsb0, f)
}
}
@ -616,7 +616,7 @@ pub enum InferTy {
}
impl to_bytes::IterBytes for InferTy {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
match *self {
TyVar(ref tv) => to_bytes::iter_bytes_2(&0u8, tv, lsb0, f),
IntVar(ref iv) => to_bytes::iter_bytes_2(&1u8, iv, lsb0, f),
@ -633,7 +633,7 @@ pub enum InferRegion {
}
impl to_bytes::IterBytes for InferRegion {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
match *self {
ReVar(ref rv) => to_bytes::iter_bytes_2(&0u8, rv, lsb0, f),
ReSkolemized(ref v, _) => to_bytes::iter_bytes_2(&1u8, v, lsb0, f)
@ -642,7 +642,7 @@ impl to_bytes::IterBytes for InferRegion {
}
impl cmp::Eq for InferRegion {
pure fn eq(&self, other: &InferRegion) -> bool {
fn eq(&self, other: &InferRegion) -> bool {
match ((*self), *other) {
(ReVar(rva), ReVar(rvb)) => {
rva == rvb
@ -653,13 +653,13 @@ impl cmp::Eq for InferRegion {
_ => false
}
}
pure fn ne(&self, other: &InferRegion) -> bool {
fn ne(&self, other: &InferRegion) -> bool {
!((*self) == (*other))
}
}
impl to_bytes::IterBytes for param_bound {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
match *self {
bound_copy => 0u8.iter_bytes(lsb0, f),
bound_durable => 1u8.iter_bytes(lsb0, f),
@ -672,50 +672,50 @@ impl to_bytes::IterBytes for param_bound {
}
pub trait Vid {
pure fn to_uint(&self) -> uint;
fn to_uint(&self) -> uint;
}
impl Vid for TyVid {
pure fn to_uint(&self) -> uint { **self }
fn to_uint(&self) -> uint { **self }
}
impl ToStr for TyVid {
pure fn to_str(&self) -> ~str { fmt!("<V%u>", self.to_uint()) }
fn to_str(&self) -> ~str { fmt!("<V%u>", self.to_uint()) }
}
impl Vid for IntVid {
pure fn to_uint(&self) -> uint { **self }
fn to_uint(&self) -> uint { **self }
}
impl ToStr for IntVid {
pure fn to_str(&self) -> ~str { fmt!("<VI%u>", self.to_uint()) }
fn to_str(&self) -> ~str { fmt!("<VI%u>", self.to_uint()) }
}
impl Vid for FloatVid {
pure fn to_uint(&self) -> uint { **self }
fn to_uint(&self) -> uint { **self }
}
impl ToStr for FloatVid {
pure fn to_str(&self) -> ~str { fmt!("<VF%u>", self.to_uint()) }
fn to_str(&self) -> ~str { fmt!("<VF%u>", self.to_uint()) }
}
impl Vid for RegionVid {
pure fn to_uint(&self) -> uint { self.id }
fn to_uint(&self) -> uint { self.id }
}
impl ToStr for RegionVid {
pure fn to_str(&self) -> ~str { fmt!("%?", self.id) }
fn to_str(&self) -> ~str { fmt!("%?", self.id) }
}
impl ToStr for FnSig {
pure fn to_str(&self) -> ~str {
fn to_str(&self) -> ~str {
// grr, without tcx not much we can do.
return ~"(...)";
}
}
impl ToStr for InferTy {
pure fn to_str(&self) -> ~str {
fn to_str(&self) -> ~str {
match *self {
TyVar(ref v) => v.to_str(),
IntVar(ref v) => v.to_str(),
@ -725,7 +725,7 @@ impl ToStr for InferTy {
}
impl ToStr for IntVarValue {
pure fn to_str(&self) -> ~str {
fn to_str(&self) -> ~str {
match *self {
IntType(ref v) => v.to_str(),
UintType(ref v) => v.to_str(),
@ -734,25 +734,25 @@ impl ToStr for IntVarValue {
}
impl to_bytes::IterBytes for TyVid {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
self.to_uint().iter_bytes(lsb0, f)
}
}
impl to_bytes::IterBytes for IntVid {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
self.to_uint().iter_bytes(lsb0, f)
}
}
impl to_bytes::IterBytes for FloatVid {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
self.to_uint().iter_bytes(lsb0, f)
}
}
impl to_bytes::IterBytes for RegionVid {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
self.to_uint().iter_bytes(lsb0, f)
}
}
@ -1112,7 +1112,7 @@ pub fn mk_with_id(cx: ctxt, base: t, def_id: ast::def_id) -> t {
}
// Converts s to its machine type equivalent
pub pure fn mach_sty(cfg: @session::config, t: t) -> sty {
pub fn mach_sty(cfg: @session::config, t: t) -> sty {
match get(t).sty {
ty_int(ast::ty_i) => ty_int(cfg.int_type),
ty_uint(ast::ty_u) => ty_uint(cfg.uint_type),
@ -1532,14 +1532,14 @@ pub fn get_element_type(ty: t, i: uint) -> t {
}
}
pub pure fn type_is_box(ty: t) -> bool {
pub fn type_is_box(ty: t) -> bool {
match get(ty).sty {
ty_box(_) => return true,
_ => return false
}
}
pub pure fn type_is_boxed(ty: t) -> bool {
pub fn type_is_boxed(ty: t) -> bool {
match get(ty).sty {
ty_box(_) | ty_opaque_box |
ty_evec(_, vstore_box) | ty_estr(vstore_box) => true,
@ -1547,35 +1547,35 @@ pub pure fn type_is_boxed(ty: t) -> bool {
}
}
pub pure fn type_is_region_ptr(ty: t) -> bool {
pub fn type_is_region_ptr(ty: t) -> bool {
match get(ty).sty {
ty_rptr(_, _) => true,
_ => false
}
}
pub pure fn type_is_slice(ty: t) -> bool {
pub fn type_is_slice(ty: t) -> bool {
match get(ty).sty {
ty_evec(_, vstore_slice(_)) | ty_estr(vstore_slice(_)) => true,
_ => return false
}
}
pub pure fn type_is_unique_box(ty: t) -> bool {
pub fn type_is_unique_box(ty: t) -> bool {
match get(ty).sty {
ty_uniq(_) => return true,
_ => return false
}
}
pub pure fn type_is_unsafe_ptr(ty: t) -> bool {
pub fn type_is_unsafe_ptr(ty: t) -> bool {
match get(ty).sty {
ty_ptr(_) => return true,
_ => return false
}
}
pub pure fn type_is_vec(ty: t) -> bool {
pub fn type_is_vec(ty: t) -> bool {
return match get(ty).sty {
ty_evec(_, _) | ty_unboxed_vec(_) => true,
ty_estr(_) => true,
@ -1583,7 +1583,7 @@ pub pure fn type_is_vec(ty: t) -> bool {
};
}
pub pure fn type_is_unique(ty: t) -> bool {
pub fn type_is_unique(ty: t) -> bool {
match get(ty).sty {
ty_uniq(_) |
ty_evec(_, vstore_uniq) |
@ -1598,7 +1598,7 @@ pub pure fn type_is_unique(ty: t) -> bool {
(A ty_ptr is scalar because it represents a non-managed pointer, so its
contents are abstract to rustc.)
*/
pub pure fn type_is_scalar(ty: t) -> bool {
pub fn type_is_scalar(ty: t) -> bool {
match get(ty).sty {
ty_nil | ty_bool | ty_int(_) | ty_float(_) | ty_uint(_) |
ty_infer(IntVar(_)) | ty_infer(FloatVar(_)) | ty_type |
@ -1720,7 +1720,7 @@ pub impl TypeContents {
!self.intersects(TypeContents::noncopyable(cx))
}
static fn noncopyable(_cx: ctxt) -> TypeContents {
fn noncopyable(_cx: ctxt) -> TypeContents {
TC_DTOR + TC_BORROWED_MUT + TC_ONCE_CLOSURE + TC_OWNED_CLOSURE +
TC_EMPTY_ENUM
}
@ -1729,7 +1729,7 @@ pub impl TypeContents {
!self.intersects(TypeContents::nondurable(cx))
}
static fn nondurable(_cx: ctxt) -> TypeContents {
fn nondurable(_cx: ctxt) -> TypeContents {
TC_BORROWED_POINTER
}
@ -1737,7 +1737,7 @@ pub impl TypeContents {
!self.intersects(TypeContents::nonowned(cx))
}
static fn nonowned(_cx: ctxt) -> TypeContents {
fn nonowned(_cx: ctxt) -> TypeContents {
TC_MANAGED + TC_BORROWED_POINTER
}
@ -1749,7 +1749,7 @@ pub impl TypeContents {
!self.intersects(TypeContents::nonconst(cx))
}
static fn nonconst(_cx: ctxt) -> TypeContents {
fn nonconst(_cx: ctxt) -> TypeContents {
TC_MUTABLE
}
@ -1757,7 +1757,7 @@ pub impl TypeContents {
self.intersects(TypeContents::nonimplicitly_copyable(cx))
}
static fn nonimplicitly_copyable(cx: ctxt) -> TypeContents {
fn nonimplicitly_copyable(cx: ctxt) -> TypeContents {
let base = TypeContents::noncopyable(cx) + TC_OWNED_POINTER;
if cx.vecs_implicitly_copyable {base} else {base + TC_OWNED_VEC}
}
@ -1766,7 +1766,7 @@ pub impl TypeContents {
!self.intersects(TypeContents::nondefault_mode(cx))
}
static fn nondefault_mode(cx: ctxt) -> TypeContents {
fn nondefault_mode(cx: ctxt) -> TypeContents {
let tc = TypeContents::nonimplicitly_copyable(cx);
tc + TC_BIG + TC_OWNED_VEC // disregard cx.vecs_implicitly_copyable
}
@ -1776,26 +1776,26 @@ pub impl TypeContents {
self.intersects(tc)
}
static fn owned(&self, _cx: ctxt) -> TypeContents {
fn owned(_cx: ctxt) -> TypeContents {
//! Any kind of owned contents.
TC_OWNED_CLOSURE + TC_OWNED_POINTER + TC_OWNED_VEC
}
}
impl ops::Add<TypeContents,TypeContents> for TypeContents {
pure fn add(&self, other: &TypeContents) -> TypeContents {
fn add(&self, other: &TypeContents) -> TypeContents {
TypeContents {bits: self.bits | other.bits}
}
}
impl ops::Sub<TypeContents,TypeContents> for TypeContents {
pure fn sub(&self, other: &TypeContents) -> TypeContents {
fn sub(&self, other: &TypeContents) -> TypeContents {
TypeContents {bits: self.bits & !other.bits}
}
}
impl ToStr for TypeContents {
pure fn to_str(&self) -> ~str {
fn to_str(&self) -> ~str {
fmt!("TypeContents(%s)", u32::to_str_radix(self.bits, 2))
}
}
@ -2534,7 +2534,7 @@ pub fn index_sty(cx: ctxt, sty: &sty) -> Option<mt> {
}
impl to_bytes::IterBytes for bound_region {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
match *self {
ty::br_self => 0u8.iter_bytes(lsb0, f),
@ -2554,7 +2554,7 @@ impl to_bytes::IterBytes for bound_region {
}
impl to_bytes::IterBytes for Region {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
match *self {
re_bound(ref br) =>
to_bytes::iter_bytes_2(&0u8, br, lsb0, f),
@ -2574,7 +2574,7 @@ impl to_bytes::IterBytes for Region {
}
impl to_bytes::IterBytes for vstore {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
match *self {
vstore_fixed(ref u) =>
to_bytes::iter_bytes_2(&0u8, u, lsb0, f),
@ -2589,7 +2589,7 @@ impl to_bytes::IterBytes for vstore {
}
impl to_bytes::IterBytes for TraitStore {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
match *self {
BareTraitStore => 0u8.iter_bytes(lsb0, f),
UniqTraitStore => 1u8.iter_bytes(lsb0, f),
@ -2600,7 +2600,7 @@ impl to_bytes::IterBytes for TraitStore {
}
impl to_bytes::IterBytes for substs {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
to_bytes::iter_bytes_3(&self.self_r,
&self.self_ty,
&self.tps, lsb0, f)
@ -2608,28 +2608,28 @@ impl to_bytes::IterBytes for substs {
}
impl to_bytes::IterBytes for mt {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
to_bytes::iter_bytes_2(&self.ty,
&self.mutbl, lsb0, f)
}
}
impl to_bytes::IterBytes for field {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
to_bytes::iter_bytes_2(&self.ident,
&self.mt, lsb0, f)
}
}
impl to_bytes::IterBytes for arg {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
to_bytes::iter_bytes_2(&self.mode,
&self.ty, lsb0, f)
}
}
impl to_bytes::IterBytes for FnSig {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
to_bytes::iter_bytes_2(&self.inputs,
&self.output,
lsb0, f);
@ -2637,7 +2637,7 @@ impl to_bytes::IterBytes for FnSig {
}
impl to_bytes::IterBytes for sty {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
match *self {
ty_nil => 0u8.iter_bytes(lsb0, f),
ty_bool => 1u8.iter_bytes(lsb0, f),
@ -2768,7 +2768,7 @@ pub fn ty_fn_purity(fty: t) -> ast::purity {
}
}
pub pure fn ty_fn_ret(fty: t) -> t {
pub fn ty_fn_ret(fty: t) -> t {
match get(fty).sty {
ty_bare_fn(ref f) => f.sig.output,
ty_closure(ref f) => f.sig.output,
@ -2786,7 +2786,7 @@ pub fn is_fn_ty(fty: t) -> bool {
}
}
pub pure fn ty_vstore(ty: t) -> vstore {
pub fn ty_vstore(ty: t) -> vstore {
match get(ty).sty {
ty_evec(_, vstore) => vstore,
ty_estr(vstore) => vstore,
@ -3716,13 +3716,13 @@ pub enum DtorKind {
}
pub impl DtorKind {
pure fn is_not_present(&const self) -> bool {
fn is_not_present(&const self) -> bool {
match *self {
NoDtor => true,
_ => false
}
}
pure fn is_present(&const self) -> bool {
fn is_present(&const self) -> bool {
!self.is_not_present()
}
}
@ -4000,7 +4000,7 @@ pub fn lookup_struct_field(cx: ctxt,
}
}
pure fn is_public(f: field_ty) -> bool {
fn is_public(f: field_ty) -> bool {
// XXX: This is wrong.
match f.vis {
public | inherited => true,
@ -4260,7 +4260,7 @@ pub fn eval_repeat_count(tcx: ctxt, count_expr: @ast::expr) -> uint {
}
// Determine what purity to check a nested function under
pub pure fn determine_inherited_purity(parent_purity: ast::purity,
pub fn determine_inherited_purity(parent_purity: ast::purity,
child_purity: ast::purity,
child_sigil: ast::Sigil)
-> ast::purity {
@ -4364,14 +4364,14 @@ pub fn get_impl_id(tcx: ctxt, trait_id: def_id, self_ty: t) -> def_id {
}
impl cmp::Eq for mt {
pure fn eq(&self, other: &mt) -> bool {
fn eq(&self, other: &mt) -> bool {
(*self).ty == (*other).ty && (*self).mutbl == (*other).mutbl
}
pure fn ne(&self, other: &mt) -> bool { !(*self).eq(other) }
fn ne(&self, other: &mt) -> bool { !(*self).eq(other) }
}
impl cmp::Eq for Region {
pure fn eq(&self, other: &Region) -> bool {
fn eq(&self, other: &Region) -> bool {
match (*self) {
re_bound(e0a) => {
match (*other) {
@ -4405,11 +4405,11 @@ impl cmp::Eq for Region {
}
}
}
pure fn ne(&self, other: &Region) -> bool { !(*self).eq(other) }
fn ne(&self, other: &Region) -> bool { !(*self).eq(other) }
}
impl cmp::Eq for bound_region {
pure fn eq(&self, other: &bound_region) -> bool {
fn eq(&self, other: &bound_region) -> bool {
match (*self) {
br_self => {
match (*other) {
@ -4443,11 +4443,11 @@ impl cmp::Eq for bound_region {
}
}
}
pure fn ne(&self, other: &bound_region) -> bool { !(*self).eq(other) }
fn ne(&self, other: &bound_region) -> bool { !(*self).eq(other) }
}
impl cmp::Eq for param_bound {
pure fn eq(&self, other: &param_bound) -> bool {
fn eq(&self, other: &param_bound) -> bool {
match (*self) {
bound_copy => {
match (*other) {
@ -4481,7 +4481,7 @@ impl cmp::Eq for param_bound {
}
}
}
pure fn ne(&self, other: &param_bound) -> bool { !self.eq(other) }
fn ne(&self, other: &param_bound) -> bool { !self.eq(other) }
}
// Local Variables:

View File

@ -51,27 +51,23 @@ use util::common::indenter;
use std::list;
pub trait LatticeValue {
static fn sub(&self, cf: &CombineFields, a: &Self, b: &Self) -> ures;
static fn lub(&self, cf: &CombineFields, a: &Self, b: &Self)
-> cres<Self>;
static fn glb(&self, cf: &CombineFields, a: &Self, b: &Self)
-> cres<Self>;
fn sub(cf: &CombineFields, a: &Self, b: &Self) -> ures;
fn lub(cf: &CombineFields, a: &Self, b: &Self) -> cres<Self>;
fn glb(cf: &CombineFields, a: &Self, b: &Self) -> cres<Self>;
}
pub type LatticeOp<T> = &'self fn(cf: &CombineFields, a: &T, b: &T) -> cres<T>;
impl LatticeValue for ty::t {
static fn sub(&self, cf: &CombineFields, a: &ty::t, b: &ty::t) -> ures {
fn sub(cf: &CombineFields, a: &ty::t, b: &ty::t) -> ures {
Sub(*cf).tys(*a, *b).to_ures()
}
static fn lub(&self, cf: &CombineFields, a: &ty::t, b: &ty::t)
-> cres<ty::t> {
fn lub(cf: &CombineFields, a: &ty::t, b: &ty::t) -> cres<ty::t> {
Lub(*cf).tys(*a, *b)
}
static fn glb(&self, cf: &CombineFields, a: &ty::t, b: &ty::t)
-> cres<ty::t> {
fn glb(cf: &CombineFields, a: &ty::t, b: &ty::t) -> cres<ty::t> {
Glb(*cf).tys(*a, *b)
}
}

View File

@ -563,7 +563,7 @@ enum Constraint {
}
impl cmp::Eq for Constraint {
pure fn eq(&self, other: &Constraint) -> bool {
fn eq(&self, other: &Constraint) -> bool {
match ((*self), (*other)) {
(ConstrainVarSubVar(v0a, v1a), ConstrainVarSubVar(v0b, v1b)) => {
v0a == v0b && v1a == v1b
@ -579,11 +579,11 @@ impl cmp::Eq for Constraint {
(ConstrainVarSubReg(*), _) => false
}
}
pure fn ne(&self, other: &Constraint) -> bool { !(*self).eq(other) }
fn ne(&self, other: &Constraint) -> bool { !(*self).eq(other) }
}
impl to_bytes::IterBytes for Constraint {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
match *self {
ConstrainVarSubVar(ref v0, ref v1) =>
to_bytes::iter_bytes_3(&0u8, v0, v1, lsb0, f),
@ -603,14 +603,14 @@ struct TwoRegions {
}
impl cmp::Eq for TwoRegions {
pure fn eq(&self, other: &TwoRegions) -> bool {
fn eq(&self, other: &TwoRegions) -> bool {
(*self).a == (*other).a && (*self).b == (*other).b
}
pure fn ne(&self, other: &TwoRegions) -> bool { !(*self).eq(other) }
fn ne(&self, other: &TwoRegions) -> bool { !(*self).eq(other) }
}
impl to_bytes::IterBytes for TwoRegions {
pure fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
fn iter_bytes(&self, +lsb0: bool, f: to_bytes::Cb) {
to_bytes::iter_bytes_2(&self.a, &self.b, lsb0, f)
}
}

View File

@ -35,8 +35,8 @@ pub struct Node<V, T> {
}
pub trait UnifyVid<T> {
static fn appropriate_vals_and_bindings(&self, infcx: &'v mut InferCtxt)
-> &'v mut ValsAndBindings<Self, T>;
fn appropriate_vals_and_bindings(infcx: &'v mut InferCtxt)
-> &'v mut ValsAndBindings<Self, T>;
}
pub impl InferCtxt {
@ -144,7 +144,7 @@ pub impl InferCtxt {
// doesn't have a subtyping relationship we need to worry about.
pub trait SimplyUnifiable {
static fn to_type_err(&self, expected_found<Self>) -> ty::type_err;
fn to_type_err(expected_found<Self>) -> ty::type_err;
}
pub fn mk_err<T:SimplyUnifiable>(+a_is_expected: bool,
@ -235,36 +235,34 @@ pub impl InferCtxt {
// ______________________________________________________________________
impl UnifyVid<Bounds<ty::t>> for ty::TyVid {
static fn appropriate_vals_and_bindings(&self, infcx: &'v mut InferCtxt)
fn appropriate_vals_and_bindings(infcx: &'v mut InferCtxt)
-> &'v mut ValsAndBindings<ty::TyVid, Bounds<ty::t>> {
return &mut infcx.ty_var_bindings;
}
}
impl UnifyVid<Option<IntVarValue>> for ty::IntVid {
static fn appropriate_vals_and_bindings(&self, infcx: &'v mut InferCtxt)
fn appropriate_vals_and_bindings(infcx: &'v mut InferCtxt)
-> &'v mut ValsAndBindings<ty::IntVid, Option<IntVarValue>> {
return &mut infcx.int_var_bindings;
}
}
impl SimplyUnifiable for IntVarValue {
static fn to_type_err(&self, err: expected_found<IntVarValue>)
-> ty::type_err {
fn to_type_err(err: expected_found<IntVarValue>) -> ty::type_err {
return ty::terr_int_mismatch(err);
}
}
impl UnifyVid<Option<ast::float_ty>> for ty::FloatVid {
static fn appropriate_vals_and_bindings(&self, infcx: &'v mut InferCtxt)
fn appropriate_vals_and_bindings(infcx: &'v mut InferCtxt)
-> &'v mut ValsAndBindings<ty::FloatVid, Option<ast::float_ty>> {
return &mut infcx.float_var_bindings;
}
}
impl SimplyUnifiable for ast::float_ty {
static fn to_type_err(&self, err: expected_found<ast::float_ty>)
-> ty::type_err {
fn to_type_err(err: expected_found<ast::float_ty>) -> ty::type_err {
return ty::terr_float_mismatch(err);
}
}

View File

@ -29,10 +29,10 @@ pub enum OutputFormat {
}
impl cmp::Eq for OutputFormat {
pure fn eq(&self, other: &OutputFormat) -> bool {
fn eq(&self, other: &OutputFormat) -> bool {
((*self) as uint) == ((*other) as uint)
}
pure fn ne(&self, other: &OutputFormat) -> bool { !(*self).eq(other) }
fn ne(&self, other: &OutputFormat) -> bool { !(*self).eq(other) }
}
/// How to organize the output
@ -44,10 +44,10 @@ pub enum OutputStyle {
}
impl cmp::Eq for OutputStyle {
pure fn eq(&self, other: &OutputStyle) -> bool {
fn eq(&self, other: &OutputStyle) -> bool {
((*self) as uint) == ((*other) as uint)
}
pure fn ne(&self, other: &OutputStyle) -> bool { !(*self).eq(other) }
fn ne(&self, other: &OutputStyle) -> bool { !(*self).eq(other) }
}
/// The configuration for a rustdoc session

View File

@ -358,11 +358,11 @@ impl PageUtils for ~[Page] {
}
pub trait Item {
pure fn item(&self) -> ItemDoc;
fn item(&self) -> ItemDoc;
}
impl Item for ItemTag {
pure fn item(&self) -> ItemDoc {
fn item(&self) -> ItemDoc {
match self {
&doc::ModTag(ref doc) => copy doc.item,
&doc::NmodTag(ref doc) => copy doc.item,
@ -378,64 +378,64 @@ impl Item for ItemTag {
}
impl Item for SimpleItemDoc {
pure fn item(&self) -> ItemDoc { copy self.item }
fn item(&self) -> ItemDoc { copy self.item }
}
impl Item for ModDoc {
pure fn item(&self) -> ItemDoc { copy self.item }
fn item(&self) -> ItemDoc { copy self.item }
}
impl Item for NmodDoc {
pure fn item(&self) -> ItemDoc { copy self.item }
fn item(&self) -> ItemDoc { copy self.item }
}
impl Item for EnumDoc {
pure fn item(&self) -> ItemDoc { copy self.item }
fn item(&self) -> ItemDoc { copy self.item }
}
impl Item for TraitDoc {
pure fn item(&self) -> ItemDoc { copy self.item }
fn item(&self) -> ItemDoc { copy self.item }
}
impl Item for ImplDoc {
pure fn item(&self) -> ItemDoc { copy self.item }
fn item(&self) -> ItemDoc { copy self.item }
}
impl Item for StructDoc {
pure fn item(&self) -> ItemDoc { copy self.item }
fn item(&self) -> ItemDoc { copy self.item }
}
pub trait ItemUtils {
pure fn id(&self) -> AstId;
pure fn name(&self) -> ~str;
pure fn path(&self) -> ~[~str];
pure fn brief(&self) -> Option<~str>;
pure fn desc(&self) -> Option<~str>;
pure fn sections(&self) -> ~[Section];
fn id(&self) -> AstId;
fn name(&self) -> ~str;
fn path(&self) -> ~[~str];
fn brief(&self) -> Option<~str>;
fn desc(&self) -> Option<~str>;
fn sections(&self) -> ~[Section];
}
impl<A:Item> ItemUtils for A {
pure fn id(&self) -> AstId {
fn id(&self) -> AstId {
self.item().id
}
pure fn name(&self) -> ~str {
fn name(&self) -> ~str {
copy self.item().name
}
pure fn path(&self) -> ~[~str] {
fn path(&self) -> ~[~str] {
copy self.item().path
}
pure fn brief(&self) -> Option<~str> {
fn brief(&self) -> Option<~str> {
copy self.item().brief
}
pure fn desc(&self) -> Option<~str> {
fn desc(&self) -> Option<~str> {
copy self.item().desc
}
pure fn sections(&self) -> ~[Section] {
fn sections(&self) -> ~[Section] {
copy self.item().sections
}
}

View File

@ -45,8 +45,8 @@ fn run(
writer_factory: WriterFactory
) -> doc::Doc {
pure fn mods_last(item1: &doc::ItemTag, item2: &doc::ItemTag) -> bool {
pure fn is_mod(item: &doc::ItemTag) -> bool {
fn mods_last(item1: &doc::ItemTag, item2: &doc::ItemTag) -> bool {
fn is_mod(item: &doc::ItemTag) -> bool {
match *item {
doc::ModTag(_) => true,
_ => false

View File

@ -16,7 +16,7 @@ use pass::Pass;
use sort_pass;
pub fn mk_pass() -> Pass {
pure fn by_item_name(item1: &doc::ItemTag, item2: &doc::ItemTag) -> bool {
fn by_item_name(item1: &doc::ItemTag, item2: &doc::ItemTag) -> bool {
(*item1).name() <= (*item2).name()
}
sort_pass::mk_pass(~"sort_item_name", by_item_name)

View File

@ -15,8 +15,8 @@ use pass::Pass;
use sort_pass;
pub fn mk_pass() -> Pass {
pure fn by_score(item1: &doc::ItemTag, item2: &doc::ItemTag) -> bool {
pure fn score(item: &doc::ItemTag) -> int {
fn by_score(item1: &doc::ItemTag, item2: &doc::ItemTag) -> bool {
fn score(item: &doc::ItemTag) -> int {
match *item {
doc::ConstTag(_) => 0,
doc::TyTag(_) => 1,

View File

@ -21,7 +21,7 @@ use util::NominalOp;
use std::sort;
pub type ItemLtEqOp = @pure fn(v1: &doc::ItemTag, v2: &doc::ItemTag) -> bool;
pub type ItemLtEqOp = @fn(v1: &doc::ItemTag, v2: &doc::ItemTag) -> bool;
type ItemLtEq = NominalOp<ItemLtEqOp>;
@ -59,7 +59,7 @@ fn fold_mod(
#[test]
fn test() {
pure fn name_lteq(item1: &doc::ItemTag, item2: &doc::ItemTag) -> bool {
fn name_lteq(item1: &doc::ItemTag, item2: &doc::ItemTag) -> bool {
(*item1).name() <= (*item2).name()
}
@ -76,7 +76,7 @@ fn test() {
#[test]
fn should_be_stable() {
pure fn always_eq(_item1: &doc::ItemTag, _item2: &doc::ItemTag) -> bool {
fn always_eq(_item1: &doc::ItemTag, _item2: &doc::ItemTag) -> bool {
true
}

View File

@ -123,7 +123,7 @@ pub fn Arena() -> Arena {
}
#[inline(always)]
pure fn round_up_to(base: uint, align: uint) -> uint {
fn round_up_to(base: uint, align: uint) -> uint {
(base + (align - 1)) & !(align - 1)
}

View File

@ -13,11 +13,11 @@ use core::str;
use core::vec;
pub trait ToBase64 {
pure fn to_base64(&self) -> ~str;
fn to_base64(&self) -> ~str;
}
impl ToBase64 for &'self [u8] {
pure fn to_base64(&self) -> ~str {
fn to_base64(&self) -> ~str {
let chars = str::chars(
~"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
);
@ -70,17 +70,17 @@ impl ToBase64 for &'self [u8] {
}
impl ToBase64 for &'self str {
pure fn to_base64(&self) -> ~str {
fn to_base64(&self) -> ~str {
str::to_bytes(*self).to_base64()
}
}
pub trait FromBase64 {
pure fn from_base64(&self) -> ~[u8];
fn from_base64(&self) -> ~[u8];
}
impl FromBase64 for ~[u8] {
pure fn from_base64(&self) -> ~[u8] {
fn from_base64(&self) -> ~[u8] {
if self.len() % 4u != 0u { fail!(~"invalid base64 length"); }
let len = self.len();
@ -142,7 +142,7 @@ impl FromBase64 for ~[u8] {
}
impl FromBase64 for ~str {
pure fn from_base64(&self) -> ~[u8] {
fn from_base64(&self) -> ~[u8] {
str::to_bytes(*self).from_base64()
}
}

View File

@ -53,16 +53,16 @@ pub mod BigDigit {
priv const hi_mask: uint = (-1 as uint) << bits;
priv const lo_mask: uint = (-1 as uint) >> bits;
priv pure fn get_hi(n: uint) -> BigDigit { (n >> bits) as BigDigit }
priv pure fn get_lo(n: uint) -> BigDigit { (n & lo_mask) as BigDigit }
priv fn get_hi(n: uint) -> BigDigit { (n >> bits) as BigDigit }
priv fn get_lo(n: uint) -> BigDigit { (n & lo_mask) as BigDigit }
/// Split one machine sized unsigned integer into two BigDigits.
pub pure fn from_uint(n: uint) -> (BigDigit, BigDigit) {
pub fn from_uint(n: uint) -> (BigDigit, BigDigit) {
(get_hi(n), get_lo(n))
}
/// Join two BigDigits into one machine sized unsigned integer
pub pure fn to_uint(hi: BigDigit, lo: BigDigit) -> uint {
pub fn to_uint(hi: BigDigit, lo: BigDigit) -> uint {
(lo as uint) | ((hi as uint) << bits)
}
}
@ -78,29 +78,29 @@ pub struct BigUint {
}
impl Eq for BigUint {
pure fn eq(&self, other: &BigUint) -> bool { self.cmp(other) == 0 }
pure fn ne(&self, other: &BigUint) -> bool { self.cmp(other) != 0 }
fn eq(&self, other: &BigUint) -> bool { self.cmp(other) == 0 }
fn ne(&self, other: &BigUint) -> bool { self.cmp(other) != 0 }
}
impl Ord for BigUint {
pure fn lt(&self, other: &BigUint) -> bool { self.cmp(other) < 0 }
pure fn le(&self, other: &BigUint) -> bool { self.cmp(other) <= 0 }
pure fn ge(&self, other: &BigUint) -> bool { self.cmp(other) >= 0 }
pure fn gt(&self, other: &BigUint) -> bool { self.cmp(other) > 0 }
fn lt(&self, other: &BigUint) -> bool { self.cmp(other) < 0 }
fn le(&self, other: &BigUint) -> bool { self.cmp(other) <= 0 }
fn ge(&self, other: &BigUint) -> bool { self.cmp(other) >= 0 }
fn gt(&self, other: &BigUint) -> bool { self.cmp(other) > 0 }
}
impl ToStr for BigUint {
pure fn to_str(&self) -> ~str { self.to_str_radix(10) }
fn to_str(&self) -> ~str { self.to_str_radix(10) }
}
impl from_str::FromStr for BigUint {
static pure fn from_str(s: &str) -> Option<BigUint> {
fn from_str(s: &str) -> Option<BigUint> {
BigUint::from_str_radix(s, 10)
}
}
impl Shl<uint, BigUint> for BigUint {
pure fn shl(&self, rhs: &uint) -> BigUint {
fn shl(&self, rhs: &uint) -> BigUint {
let n_unit = *rhs / BigDigit::bits;
let n_bits = *rhs % BigDigit::bits;
return self.shl_unit(n_unit).shl_bits(n_bits);
@ -108,7 +108,7 @@ impl Shl<uint, BigUint> for BigUint {
}
impl Shr<uint, BigUint> for BigUint {
pure fn shr(&self, rhs: &uint) -> BigUint {
fn shr(&self, rhs: &uint) -> BigUint {
let n_unit = *rhs / BigDigit::bits;
let n_bits = *rhs % BigDigit::bits;
return self.shr_unit(n_unit).shr_bits(n_bits);
@ -116,15 +116,15 @@ impl Shr<uint, BigUint> for BigUint {
}
impl Zero for BigUint {
static pure fn zero() -> BigUint { BigUint::new(~[]) }
fn zero() -> BigUint { BigUint::new(~[]) }
}
impl One for BigUint {
static pub pure fn one() -> BigUint { BigUint::new(~[1]) }
pub fn one() -> BigUint { BigUint::new(~[1]) }
}
impl Add<BigUint, BigUint> for BigUint {
pure fn add(&self, other: &BigUint) -> BigUint {
fn add(&self, other: &BigUint) -> BigUint {
let new_len = uint::max(self.data.len(), other.data.len());
let mut carry = 0;
@ -143,7 +143,7 @@ impl Add<BigUint, BigUint> for BigUint {
}
impl Sub<BigUint, BigUint> for BigUint {
pure fn sub(&self, other: &BigUint) -> BigUint {
fn sub(&self, other: &BigUint) -> BigUint {
let new_len = uint::max(self.data.len(), other.data.len());
let mut borrow = 0;
@ -168,7 +168,7 @@ impl Sub<BigUint, BigUint> for BigUint {
}
impl Mul<BigUint, BigUint> for BigUint {
pure fn mul(&self, other: &BigUint) -> BigUint {
fn mul(&self, other: &BigUint) -> BigUint {
if self.is_zero() || other.is_zero() { return Zero::zero(); }
let s_len = self.data.len(), o_len = other.data.len();
@ -200,7 +200,7 @@ impl Mul<BigUint, BigUint> for BigUint {
return ll + mm.shl_unit(half_len) + hh.shl_unit(half_len * 2);
pure fn mul_digit(a: &BigUint, n: BigDigit) -> BigUint {
fn mul_digit(a: &BigUint, n: BigDigit) -> BigUint {
if n == 0 { return Zero::zero(); }
if n == 1 { return copy *a; }
@ -216,14 +216,14 @@ impl Mul<BigUint, BigUint> for BigUint {
return BigUint::new(prod + [carry]);
}
pure fn cut_at(a: &BigUint, n: uint) -> (BigUint, BigUint) {
fn cut_at(a: &BigUint, n: uint) -> (BigUint, BigUint) {
let mid = uint::min(a.data.len(), n);
return (BigUint::from_slice(vec::slice(a.data, mid,
a.data.len())),
BigUint::from_slice(vec::slice(a.data, 0, mid)));
}
pure fn sub_sign(a: BigUint, b: BigUint) -> (int, BigUint) {
fn sub_sign(a: BigUint, b: BigUint) -> (int, BigUint) {
match a.cmp(&b) {
s if s < 0 => (s, b - a),
s if s > 0 => (s, a - b),
@ -234,36 +234,36 @@ impl Mul<BigUint, BigUint> for BigUint {
}
impl Div<BigUint, BigUint> for BigUint {
pure fn div(&self, other: &BigUint) -> BigUint {
fn div(&self, other: &BigUint) -> BigUint {
let (d, _) = self.divmod(other);
return d;
}
}
impl Modulo<BigUint, BigUint> for BigUint {
pure fn modulo(&self, other: &BigUint) -> BigUint {
fn modulo(&self, other: &BigUint) -> BigUint {
let (_, m) = self.divmod(other);
return m;
}
}
impl Neg<BigUint> for BigUint {
pure fn neg(&self) -> BigUint { fail!() }
fn neg(&self) -> BigUint { fail!() }
}
impl IntConvertible for BigUint {
pure fn to_int(&self) -> int {
fn to_int(&self) -> int {
uint::min(self.to_uint(), int::max_value as uint) as int
}
static pure fn from_int(n: int) -> BigUint {
fn from_int(n: int) -> BigUint {
if (n < 0) { Zero::zero() } else { BigUint::from_uint(n as uint) }
}
}
pub impl BigUint {
/// Creates and initializes an BigUint.
static pub pure fn new(v: ~[BigDigit]) -> BigUint {
pub fn new(v: ~[BigDigit]) -> BigUint {
// omit trailing zeros
let new_len = v.rposition(|n| *n != 0).map_default(0, |p| *p + 1);
@ -274,7 +274,7 @@ pub impl BigUint {
}
/// Creates and initializes an BigUint.
static pub pure fn from_uint(n: uint) -> BigUint {
pub fn from_uint(n: uint) -> BigUint {
match BigDigit::from_uint(n) {
(0, 0) => Zero::zero(),
(0, n0) => BigUint::new(~[n0]),
@ -283,18 +283,18 @@ pub impl BigUint {
}
/// Creates and initializes an BigUint.
static pub pure fn from_slice(slice: &[BigDigit]) -> BigUint {
pub fn from_slice(slice: &[BigDigit]) -> BigUint {
return BigUint::new(vec::from_slice(slice));
}
/// Creates and initializes an BigUint.
static pub pure fn from_str_radix(s: &str, radix: uint)
pub fn from_str_radix(s: &str, radix: uint)
-> Option<BigUint> {
BigUint::parse_bytes(str::to_bytes(s), radix)
}
/// Creates and initializes an BigUint.
static pub pure fn parse_bytes(buf: &[u8], radix: uint)
pub fn parse_bytes(buf: &[u8], radix: uint)
-> Option<BigUint> {
let (base, unit_len) = get_radix_base(radix);
let base_num: BigUint = BigUint::from_uint(base);
@ -316,10 +316,10 @@ pub impl BigUint {
}
}
pure fn abs(&self) -> BigUint { copy *self }
fn abs(&self) -> BigUint { copy *self }
/// Compare two BigUint value.
pure fn cmp(&self, other: &BigUint) -> int {
fn cmp(&self, other: &BigUint) -> int {
let s_len = self.data.len(), o_len = other.data.len();
if s_len < o_len { return -1; }
if s_len > o_len { return 1; }
@ -334,7 +334,7 @@ pub impl BigUint {
return 0;
}
pure fn divmod(&self, other: &BigUint) -> (BigUint, BigUint) {
fn divmod(&self, other: &BigUint) -> (BigUint, BigUint) {
if other.is_zero() { fail!() }
if self.is_zero() { return (Zero::zero(), Zero::zero()); }
if *other == One::one() { return (copy *self, Zero::zero()); }
@ -355,7 +355,7 @@ pub impl BigUint {
let (d, m) = divmod_inner(self << shift, other << shift);
return (d, m >> shift);
pure fn divmod_inner(a: BigUint, b: BigUint) -> (BigUint, BigUint) {
fn divmod_inner(a: BigUint, b: BigUint) -> (BigUint, BigUint) {
let mut r = a;
let mut d = Zero::zero::<BigUint>();
let mut n = 1;
@ -377,7 +377,7 @@ pub impl BigUint {
return (d, r);
}
pure fn div_estimate(a: &BigUint, b: &BigUint, n: uint)
fn div_estimate(a: &BigUint, b: &BigUint, n: uint)
-> (BigUint, BigUint, BigUint) {
if a.data.len() < n {
return (Zero::zero(), Zero::zero(), copy *a);
@ -405,26 +405,26 @@ pub impl BigUint {
}
}
pure fn quot(&self, other: &BigUint) -> BigUint {
fn quot(&self, other: &BigUint) -> BigUint {
let (q, _) = self.quotrem(other);
return q;
}
pure fn rem(&self, other: &BigUint) -> BigUint {
fn rem(&self, other: &BigUint) -> BigUint {
let (_, r) = self.quotrem(other);
return r;
}
pure fn quotrem(&self, other: &BigUint) -> (BigUint, BigUint) {
fn quotrem(&self, other: &BigUint) -> (BigUint, BigUint) {
self.divmod(other)
}
pure fn is_zero(&self) -> bool { self.data.is_empty() }
pure fn is_not_zero(&self) -> bool { !self.data.is_empty() }
pure fn is_positive(&self) -> bool { self.is_not_zero() }
pure fn is_negative(&self) -> bool { false }
pure fn is_nonpositive(&self) -> bool { self.is_zero() }
pure fn is_nonnegative(&self) -> bool { true }
fn is_zero(&self) -> bool { self.data.is_empty() }
fn is_not_zero(&self) -> bool { !self.data.is_empty() }
fn is_positive(&self) -> bool { self.is_not_zero() }
fn is_negative(&self) -> bool { false }
fn is_nonpositive(&self) -> bool { self.is_zero() }
fn is_nonnegative(&self) -> bool { true }
pure fn to_uint(&self) -> uint {
fn to_uint(&self) -> uint {
match self.data.len() {
0 => 0,
1 => self.data[0] as uint,
@ -433,7 +433,7 @@ pub impl BigUint {
}
}
pure fn to_str_radix(&self, radix: uint) -> ~str {
fn to_str_radix(&self, radix: uint) -> ~str {
fail_unless!(1 < radix && radix <= 16);
let (base, max_len) = get_radix_base(radix);
if base == BigDigit::base {
@ -441,7 +441,7 @@ pub impl BigUint {
}
return fill_concat(convert_base(copy *self, base), radix, max_len);
pure fn convert_base(n: BigUint, base: uint) -> ~[BigDigit] {
fn convert_base(n: BigUint, base: uint) -> ~[BigDigit] {
let divider = BigUint::from_uint(base);
let mut result = ~[];
let mut r = n;
@ -456,7 +456,7 @@ pub impl BigUint {
return result;
}
pure fn fill_concat(v: &[BigDigit], radix: uint, l: uint) -> ~str {
fn fill_concat(v: &[BigDigit], radix: uint, l: uint) -> ~str {
if v.is_empty() { return ~"0" }
let s = str::concat(vec::reversed(v).map(|n| {
let s = uint::to_str_radix(*n as uint, radix);
@ -466,13 +466,13 @@ pub impl BigUint {
}
}
priv pure fn shl_unit(self, n_unit: uint) -> BigUint {
priv fn shl_unit(self, n_unit: uint) -> BigUint {
if n_unit == 0 || self.is_zero() { return self; }
return BigUint::new(vec::from_elem(n_unit, 0) + self.data);
}
priv pure fn shl_bits(self, n_bits: uint) -> BigUint {
priv fn shl_bits(self, n_bits: uint) -> BigUint {
if n_bits == 0 || self.is_zero() { return self; }
let mut carry = 0;
@ -487,7 +487,7 @@ pub impl BigUint {
return BigUint::new(shifted + [carry]);
}
priv pure fn shr_unit(self, n_unit: uint) -> BigUint {
priv fn shr_unit(self, n_unit: uint) -> BigUint {
if n_unit == 0 { return self; }
if self.data.len() < n_unit { return Zero::zero(); }
return BigUint::from_slice(
@ -495,7 +495,7 @@ pub impl BigUint {
);
}
priv pure fn shr_bits(self, n_bits: uint) -> BigUint {
priv fn shr_bits(self, n_bits: uint) -> BigUint {
if n_bits == 0 || self.data.is_empty() { return self; }
let mut borrow = 0;
@ -509,7 +509,7 @@ pub impl BigUint {
}
#[cfg(target_arch = "x86_64")]
priv pure fn get_radix_base(radix: uint) -> (uint, uint) {
priv fn get_radix_base(radix: uint) -> (uint, uint) {
fail_unless!(1 < radix && radix <= 16);
match radix {
2 => (4294967296, 32),
@ -534,7 +534,7 @@ priv pure fn get_radix_base(radix: uint) -> (uint, uint) {
#[cfg(target_arch = "arm")]
#[cfg(target_arch = "x86")]
#[cfg(target_arch = "mips")]
priv pure fn get_radix_base(radix: uint) -> (uint, uint) {
priv fn get_radix_base(radix: uint) -> (uint, uint) {
fail_unless!(1 < radix && radix <= 16);
match radix {
2 => (65536, 16),
@ -560,20 +560,20 @@ priv pure fn get_radix_base(radix: uint) -> (uint, uint) {
pub enum Sign { Minus, Zero, Plus }
impl Eq for Sign {
pure fn eq(&self, other: &Sign) -> bool { self.cmp(other) == 0 }
pure fn ne(&self, other: &Sign) -> bool { self.cmp(other) != 0 }
fn eq(&self, other: &Sign) -> bool { self.cmp(other) == 0 }
fn ne(&self, other: &Sign) -> bool { self.cmp(other) != 0 }
}
impl Ord for Sign {
pure fn lt(&self, other: &Sign) -> bool { self.cmp(other) < 0 }
pure fn le(&self, other: &Sign) -> bool { self.cmp(other) <= 0 }
pure fn ge(&self, other: &Sign) -> bool { self.cmp(other) >= 0 }
pure fn gt(&self, other: &Sign) -> bool { self.cmp(other) > 0 }
fn lt(&self, other: &Sign) -> bool { self.cmp(other) < 0 }
fn le(&self, other: &Sign) -> bool { self.cmp(other) <= 0 }
fn ge(&self, other: &Sign) -> bool { self.cmp(other) >= 0 }
fn gt(&self, other: &Sign) -> bool { self.cmp(other) > 0 }
}
pub impl Sign {
/// Compare two Sign.
pure fn cmp(&self, other: &Sign) -> int {
fn cmp(&self, other: &Sign) -> int {
match (*self, *other) {
(Minus, Minus) | (Zero, Zero) | (Plus, Plus) => 0,
(Minus, Zero) | (Minus, Plus) | (Zero, Plus) => -1,
@ -582,7 +582,7 @@ pub impl Sign {
}
/// Negate Sign value.
pure fn neg(&self) -> Sign {
fn neg(&self) -> Sign {
match *self {
Minus => Plus,
Zero => Zero,
@ -598,53 +598,53 @@ pub struct BigInt {
}
impl Eq for BigInt {
pure fn eq(&self, other: &BigInt) -> bool { self.cmp(other) == 0 }
pure fn ne(&self, other: &BigInt) -> bool { self.cmp(other) != 0 }
fn eq(&self, other: &BigInt) -> bool { self.cmp(other) == 0 }
fn ne(&self, other: &BigInt) -> bool { self.cmp(other) != 0 }
}
impl Ord for BigInt {
pure fn lt(&self, other: &BigInt) -> bool { self.cmp(other) < 0 }
pure fn le(&self, other: &BigInt) -> bool { self.cmp(other) <= 0 }
pure fn ge(&self, other: &BigInt) -> bool { self.cmp(other) >= 0 }
pure fn gt(&self, other: &BigInt) -> bool { self.cmp(other) > 0 }
fn lt(&self, other: &BigInt) -> bool { self.cmp(other) < 0 }
fn le(&self, other: &BigInt) -> bool { self.cmp(other) <= 0 }
fn ge(&self, other: &BigInt) -> bool { self.cmp(other) >= 0 }
fn gt(&self, other: &BigInt) -> bool { self.cmp(other) > 0 }
}
impl ToStr for BigInt {
pure fn to_str(&self) -> ~str { self.to_str_radix(10) }
fn to_str(&self) -> ~str { self.to_str_radix(10) }
}
impl from_str::FromStr for BigInt {
static pure fn from_str(s: &str) -> Option<BigInt> {
fn from_str(s: &str) -> Option<BigInt> {
BigInt::from_str_radix(s, 10)
}
}
impl Shl<uint, BigInt> for BigInt {
pure fn shl(&self, rhs: &uint) -> BigInt {
fn shl(&self, rhs: &uint) -> BigInt {
BigInt::from_biguint(self.sign, self.data << *rhs)
}
}
impl Shr<uint, BigInt> for BigInt {
pure fn shr(&self, rhs: &uint) -> BigInt {
fn shr(&self, rhs: &uint) -> BigInt {
BigInt::from_biguint(self.sign, self.data >> *rhs)
}
}
impl Zero for BigInt {
static pub pure fn zero() -> BigInt {
pub fn zero() -> BigInt {
BigInt::from_biguint(Zero, Zero::zero())
}
}
impl One for BigInt {
static pub pure fn one() -> BigInt {
pub fn one() -> BigInt {
BigInt::from_biguint(Plus, One::one())
}
}
impl Add<BigInt, BigInt> for BigInt {
pure fn add(&self, other: &BigInt) -> BigInt {
fn add(&self, other: &BigInt) -> BigInt {
match (self.sign, other.sign) {
(Zero, _) => copy *other,
(_, Zero) => copy *self,
@ -658,7 +658,7 @@ impl Add<BigInt, BigInt> for BigInt {
}
impl Sub<BigInt, BigInt> for BigInt {
pure fn sub(&self, other: &BigInt) -> BigInt {
fn sub(&self, other: &BigInt) -> BigInt {
match (self.sign, other.sign) {
(Zero, _) => -other,
(_, Zero) => copy *self,
@ -678,7 +678,7 @@ impl Sub<BigInt, BigInt> for BigInt {
}
impl Mul<BigInt, BigInt> for BigInt {
pure fn mul(&self, other: &BigInt) -> BigInt {
fn mul(&self, other: &BigInt) -> BigInt {
match (self.sign, other.sign) {
(Zero, _) | (_, Zero) => Zero::zero(),
(Plus, Plus) | (Minus, Minus) => {
@ -692,27 +692,27 @@ impl Mul<BigInt, BigInt> for BigInt {
}
impl Div<BigInt, BigInt> for BigInt {
pure fn div(&self, other: &BigInt) -> BigInt {
fn div(&self, other: &BigInt) -> BigInt {
let (d, _) = self.divmod(other);
return d;
}
}
impl Modulo<BigInt, BigInt> for BigInt {
pure fn modulo(&self, other: &BigInt) -> BigInt {
fn modulo(&self, other: &BigInt) -> BigInt {
let (_, m) = self.divmod(other);
return m;
}
}
impl Neg<BigInt> for BigInt {
pure fn neg(&self) -> BigInt {
fn neg(&self) -> BigInt {
BigInt::from_biguint(self.sign.neg(), copy self.data)
}
}
impl IntConvertible for BigInt {
pure fn to_int(&self) -> int {
fn to_int(&self) -> int {
match self.sign {
Plus => uint::min(self.to_uint(), int::max_value as uint) as int,
Zero => 0,
@ -721,7 +721,7 @@ impl IntConvertible for BigInt {
}
}
static pure fn from_int(n: int) -> BigInt {
fn from_int(n: int) -> BigInt {
if n > 0 {
return BigInt::from_biguint(Plus, BigUint::from_uint(n as uint));
}
@ -736,12 +736,12 @@ impl IntConvertible for BigInt {
pub impl BigInt {
/// Creates and initializes an BigInt.
static pub pure fn new(sign: Sign, v: ~[BigDigit]) -> BigInt {
pub fn new(sign: Sign, v: ~[BigDigit]) -> BigInt {
BigInt::from_biguint(sign, BigUint::new(v))
}
/// Creates and initializes an BigInt.
static pub pure fn from_biguint(sign: Sign, data: BigUint) -> BigInt {
pub fn from_biguint(sign: Sign, data: BigUint) -> BigInt {
if sign == Zero || data.is_zero() {
return BigInt { sign: Zero, data: Zero::zero() };
}
@ -749,24 +749,24 @@ pub impl BigInt {
}
/// Creates and initializes an BigInt.
static pub pure fn from_uint(n: uint) -> BigInt {
pub fn from_uint(n: uint) -> BigInt {
if n == 0 { return Zero::zero(); }
return BigInt::from_biguint(Plus, BigUint::from_uint(n));
}
/// Creates and initializes an BigInt.
static pub pure fn from_slice(sign: Sign, slice: &[BigDigit]) -> BigInt {
pub fn from_slice(sign: Sign, slice: &[BigDigit]) -> BigInt {
BigInt::from_biguint(sign, BigUint::from_slice(slice))
}
/// Creates and initializes an BigInt.
static pub pure fn from_str_radix(s: &str, radix: uint)
pub fn from_str_radix(s: &str, radix: uint)
-> Option<BigInt> {
BigInt::parse_bytes(str::to_bytes(s), radix)
}
/// Creates and initializes an BigInt.
static pub pure fn parse_bytes(buf: &[u8], radix: uint)
pub fn parse_bytes(buf: &[u8], radix: uint)
-> Option<BigInt> {
if buf.is_empty() { return None; }
let mut sign = Plus;
@ -779,11 +779,11 @@ pub impl BigInt {
.map(|bu| BigInt::from_biguint(sign, *bu));
}
pure fn abs(&self) -> BigInt {
fn abs(&self) -> BigInt {
BigInt::from_biguint(Plus, copy self.data)
}
pure fn cmp(&self, other: &BigInt) -> int {
fn cmp(&self, other: &BigInt) -> int {
let ss = self.sign, os = other.sign;
if ss < os { return -1; }
if ss > os { return 1; }
@ -796,7 +796,7 @@ pub impl BigInt {
}
}
pure fn divmod(&self, other: &BigInt) -> (BigInt, BigInt) {
fn divmod(&self, other: &BigInt) -> (BigInt, BigInt) {
// m.sign == other.sign
let (d_ui, m_ui) = self.data.divmod(&other.data);
let d = BigInt::from_biguint(Plus, d_ui),
@ -818,16 +818,16 @@ pub impl BigInt {
}
}
pure fn quot(&self, other: &BigInt) -> BigInt {
fn quot(&self, other: &BigInt) -> BigInt {
let (q, _) = self.quotrem(other);
return q;
}
pure fn rem(&self, other: &BigInt) -> BigInt {
fn rem(&self, other: &BigInt) -> BigInt {
let (_, r) = self.quotrem(other);
return r;
}
pure fn quotrem(&self, other: &BigInt) -> (BigInt, BigInt) {
fn quotrem(&self, other: &BigInt) -> (BigInt, BigInt) {
// r.sign == self.sign
let (q_ui, r_ui) = self.data.quotrem(&other.data);
let q = BigInt::from_biguint(Plus, q_ui);
@ -841,14 +841,14 @@ pub impl BigInt {
}
}
pure fn is_zero(&self) -> bool { self.sign == Zero }
pure fn is_not_zero(&self) -> bool { self.sign != Zero }
pure fn is_positive(&self) -> bool { self.sign == Plus }
pure fn is_negative(&self) -> bool { self.sign == Minus }
pure fn is_nonpositive(&self) -> bool { self.sign != Plus }
pure fn is_nonnegative(&self) -> bool { self.sign != Minus }
fn is_zero(&self) -> bool { self.sign == Zero }
fn is_not_zero(&self) -> bool { self.sign != Zero }
fn is_positive(&self) -> bool { self.sign == Plus }
fn is_negative(&self) -> bool { self.sign == Minus }
fn is_nonpositive(&self) -> bool { self.sign != Plus }
fn is_nonnegative(&self) -> bool { self.sign != Minus }
pure fn to_uint(&self) -> uint {
fn to_uint(&self) -> uint {
match self.sign {
Plus => self.data.to_uint(),
Zero => 0,
@ -856,7 +856,7 @@ pub impl BigInt {
}
}
pure fn to_str_radix(&self, radix: uint) -> ~str {
fn to_str_radix(&self, radix: uint) -> ~str {
match self.sign {
Plus => self.data.to_str_radix(radix),
Zero => ~"0",

View File

@ -27,7 +27,7 @@ fn small_mask(nbits: uint) -> uint {
}
pub impl SmallBitv {
static fn new(bits: uint) -> SmallBitv {
fn new(bits: uint) -> SmallBitv {
SmallBitv {bits: bits}
}
@ -62,7 +62,7 @@ pub impl SmallBitv {
}
#[inline(always)]
pure fn get(&self, i: uint) -> bool {
fn get(&self, i: uint) -> bool {
(self.bits & (1 << i)) != 0
}
@ -124,7 +124,7 @@ fn big_mask(nbits: uint, elem: uint) -> uint {
}
pub impl BigBitv {
static fn new(storage: ~[uint]) -> BigBitv {
fn new(storage: ~[uint]) -> BigBitv {
BigBitv {storage: storage}
}
@ -181,7 +181,7 @@ pub impl BigBitv {
}
#[inline(always)]
pure fn get(&self, i: uint) -> bool {
fn get(&self, i: uint) -> bool {
let w = i / uint::bits;
let b = i % uint::bits;
let x = 1 & self.storage[w] >> b;
@ -256,7 +256,7 @@ priv impl Bitv {
}
pub impl Bitv {
static fn new(nbits: uint, init: bool) -> Bitv {
fn new(nbits: uint, init: bool) -> Bitv {
let rep = if nbits <= uint::bits {
Small(~SmallBitv::new(if init {!0} else {0}))
}
@ -299,7 +299,7 @@ pub impl Bitv {
/// Retrieve the value at index `i`
#[inline(always)]
pure fn get(&self, i: uint) -> bool {
fn get(&self, i: uint) -> bool {
fail_unless!((i < self.nbits));
match self.rep {
Big(ref b) => b.get(i),
@ -555,13 +555,13 @@ pub fn from_fn(len: uint, f: &fn(index: uint) -> bool) -> Bitv {
}
impl ops::Index<uint,bool> for Bitv {
pure fn index(&self, i: uint) -> bool {
fn index(&self, i: uint) -> bool {
self.get(i)
}
}
#[inline(always)]
pure fn iterate_bits(base: uint, bits: uint, f: &fn(uint) -> bool) -> bool {
fn iterate_bits(base: uint, bits: uint, f: &fn(uint) -> bool) -> bool {
if bits == 0 {
return true;
}
@ -592,12 +592,12 @@ pub struct BitvSet {
pub impl BitvSet {
/// Creates a new bit vector set with initially no contents
static fn new() -> BitvSet {
fn new() -> BitvSet {
BitvSet{ size: 0, bitv: BigBitv::new(~[0]) }
}
/// Creates a new bit vector set from the given bit vector
static fn from_bitv(bitv: Bitv) -> BitvSet {
fn from_bitv(bitv: Bitv) -> BitvSet {
let mut size = 0;
for bitv.ones |_| {
size += 1;
@ -612,7 +612,7 @@ pub impl BitvSet {
/// Returns the capacity in bits for this bit vector. Inserting any
/// element less than this amount will not trigger a resizing.
pure fn capacity(&self) -> uint { self.bitv.storage.len() * uint::bits }
fn capacity(&self) -> uint { self.bitv.storage.len() * uint::bits }
/// Consumes this set to return the underlying bit vector
fn unwrap(self) -> Bitv {
@ -667,9 +667,9 @@ pub impl BitvSet {
}
impl BaseIter<uint> for BitvSet {
pure fn size_hint(&self) -> Option<uint> { Some(self.len()) }
fn size_hint(&self) -> Option<uint> { Some(self.len()) }
pure fn each(&self, blk: &fn(v: &uint) -> bool) {
fn each(&self, blk: &fn(v: &uint) -> bool) {
for self.bitv.storage.eachi |i, &w| {
if !iterate_bits(i * uint::bits, w, |b| blk(&b)) {
return;
@ -679,7 +679,7 @@ impl BaseIter<uint> for BitvSet {
}
impl cmp::Eq for BitvSet {
pure fn eq(&self, other: &BitvSet) -> bool {
fn eq(&self, other: &BitvSet) -> bool {
if self.size != other.size {
return false;
}
@ -696,12 +696,12 @@ impl cmp::Eq for BitvSet {
return true;
}
pure fn ne(&self, other: &BitvSet) -> bool { !self.eq(other) }
fn ne(&self, other: &BitvSet) -> bool { !self.eq(other) }
}
impl Container for BitvSet {
pure fn len(&const self) -> uint { self.size }
pure fn is_empty(&const self) -> bool { self.size == 0 }
fn len(&const self) -> uint { self.size }
fn is_empty(&const self) -> bool { self.size == 0 }
}
impl Mutable for BitvSet {
@ -712,7 +712,7 @@ impl Mutable for BitvSet {
}
impl Set<uint> for BitvSet {
pure fn contains(&self, value: &uint) -> bool {
fn contains(&self, value: &uint) -> bool {
*value < self.bitv.storage.len() * uint::bits && self.bitv.get(*value)
}
@ -748,14 +748,14 @@ impl Set<uint> for BitvSet {
return true;
}
pure fn is_disjoint(&self, other: &BitvSet) -> bool {
fn is_disjoint(&self, other: &BitvSet) -> bool {
for self.intersection(other) |_| {
return false;
}
return true;
}
pure fn is_subset(&self, other: &BitvSet) -> bool {
fn is_subset(&self, other: &BitvSet) -> bool {
for self.each_common(other) |_, w1, w2| {
if w1 & w2 != w1 {
return false;
@ -774,11 +774,11 @@ impl Set<uint> for BitvSet {
return true;
}
pure fn is_superset(&self, other: &BitvSet) -> bool {
fn is_superset(&self, other: &BitvSet) -> bool {
other.is_subset(self)
}
pure fn difference(&self, other: &BitvSet, f: &fn(&uint) -> bool) {
fn difference(&self, other: &BitvSet, f: &fn(&uint) -> bool) {
for self.each_common(other) |i, w1, w2| {
if !iterate_bits(i, w1 & !w2, |b| f(&b)) {
return;
@ -790,7 +790,7 @@ impl Set<uint> for BitvSet {
);
}
pure fn symmetric_difference(&self, other: &BitvSet,
fn symmetric_difference(&self, other: &BitvSet,
f: &fn(&uint) -> bool) {
for self.each_common(other) |i, w1, w2| {
if !iterate_bits(i, w1 ^ w2, |b| f(&b)) {
@ -802,7 +802,7 @@ impl Set<uint> for BitvSet {
);
}
pure fn intersection(&self, other: &BitvSet, f: &fn(&uint) -> bool) {
fn intersection(&self, other: &BitvSet, f: &fn(&uint) -> bool) {
for self.each_common(other) |i, w1, w2| {
if !iterate_bits(i, w1 & w2, |b| f(&b)) {
return;
@ -810,7 +810,7 @@ impl Set<uint> for BitvSet {
}
}
pure fn union(&self, other: &BitvSet, f: &fn(&uint) -> bool) {
fn union(&self, other: &BitvSet, f: &fn(&uint) -> bool) {
for self.each_common(other) |i, w1, w2| {
if !iterate_bits(i, w1 | w2, |b| f(&b)) {
return;
@ -827,7 +827,7 @@ priv impl BitvSet {
/// both have in common. The three yielded arguments are (bit location,
/// w1, w2) where the bit location is the number of bits offset so far,
/// and w1/w2 are the words coming from the two vectors self, other.
pure fn each_common(&self, other: &BitvSet,
fn each_common(&self, other: &BitvSet,
f: &fn(uint, uint, uint) -> bool) {
let min = uint::min(self.bitv.storage.len(),
other.bitv.storage.len());
@ -845,7 +845,7 @@ priv impl BitvSet {
/// The yielded arguments are a bool, the bit offset, and a word. The bool
/// is true if the word comes from 'self', and false if it comes from
/// 'other'.
pure fn each_outlier(&self, other: &BitvSet,
fn each_outlier(&self, other: &BitvSet,
f: &fn(bool, uint, uint) -> bool) {
let len1 = self.bitv.storage.len();
let len2 = other.bitv.storage.len();

View File

@ -141,7 +141,7 @@ pub fn set<T:Copy>(t: CVec<T>, ofs: uint, v: T) {
*/
/// Returns the length of the vector
pub pure fn len<T>(t: CVec<T>) -> uint { t.len }
pub fn len<T>(t: CVec<T>) -> uint { t.len }
/// Returns a pointer to the first element of the vector
pub unsafe fn ptr<T>(t: CVec<T>) -> *mut T { t.base }

View File

@ -17,36 +17,36 @@ use core::float;
pub const FUZZY_EPSILON: float = 1.0e-6;
pub trait FuzzyEq<Eps> {
pure fn fuzzy_eq(&self, other: &Self) -> bool;
pure fn fuzzy_eq_eps(&self, other: &Self, epsilon: &Eps) -> bool;
fn fuzzy_eq(&self, other: &Self) -> bool;
fn fuzzy_eq_eps(&self, other: &Self, epsilon: &Eps) -> bool;
}
impl FuzzyEq<float> for float {
pure fn fuzzy_eq(&self, other: &float) -> bool {
fn fuzzy_eq(&self, other: &float) -> bool {
self.fuzzy_eq_eps(other, &FUZZY_EPSILON)
}
pure fn fuzzy_eq_eps(&self, other: &float, epsilon: &float) -> bool {
fn fuzzy_eq_eps(&self, other: &float, epsilon: &float) -> bool {
float::abs(*self - *other) < *epsilon
}
}
impl FuzzyEq<f32> for f32 {
pure fn fuzzy_eq(&self, other: &f32) -> bool {
fn fuzzy_eq(&self, other: &f32) -> bool {
self.fuzzy_eq_eps(other, &(FUZZY_EPSILON as f32))
}
pure fn fuzzy_eq_eps(&self, other: &f32, epsilon: &f32) -> bool {
fn fuzzy_eq_eps(&self, other: &f32, epsilon: &f32) -> bool {
f32::abs(*self - *other) < *epsilon
}
}
impl FuzzyEq<f64> for f64 {
pure fn fuzzy_eq(&self, other: &f64) -> bool {
fn fuzzy_eq(&self, other: &f64) -> bool {
self.fuzzy_eq_eps(other, &(FUZZY_EPSILON as f64))
}
pure fn fuzzy_eq_eps(&self, other: &f64, epsilon: &f64) -> bool {
fn fuzzy_eq_eps(&self, other: &f64, epsilon: &f64) -> bool {
f64::abs(*self - *other) < *epsilon
}
}
@ -71,11 +71,11 @@ mod test_complex{
struct Complex { r: float, i: float }
impl FuzzyEq<float> for Complex {
pure fn fuzzy_eq(&self, other: &Complex) -> bool {
fn fuzzy_eq(&self, other: &Complex) -> bool {
self.fuzzy_eq_eps(other, &FUZZY_EPSILON)
}
pure fn fuzzy_eq_eps(&self, other: &Complex,
fn fuzzy_eq_eps(&self, other: &Complex,
epsilon: &float) -> bool {
self.r.fuzzy_eq_eps(&other.r, epsilon) &&
self.i.fuzzy_eq_eps(&other.i, epsilon)

View File

@ -39,7 +39,7 @@ pub impl<T:Owned,U:Owned> DuplexStream<T, U> {
fn try_recv(&self) -> Option<U> {
self.port.try_recv()
}
pure fn peek(&self) -> bool {
fn peek(&self) -> bool {
self.port.peek()
}
}
@ -67,13 +67,13 @@ impl<T:Owned,U:Owned> GenericPort<U> for DuplexStream<T, U> {
}
impl<T:Owned,U:Owned> Peekable<U> for DuplexStream<T, U> {
pure fn peek(&self) -> bool {
fn peek(&self) -> bool {
self.port.peek()
}
}
impl<T:Owned,U:Owned> Selectable for DuplexStream<T, U> {
pure fn header(&self) -> *pipes::PacketHeader {
fn header(&self) -> *pipes::PacketHeader {
self.port.header()
}
}

View File

@ -25,10 +25,10 @@ pub struct Deque<T> {
impl<T> Container for Deque<T> {
/// Return the number of elements in the deque
pure fn len(&const self) -> uint { self.nelts }
fn len(&const self) -> uint { self.nelts }
/// Return true if the deque contains no elements
pure fn is_empty(&const self) -> bool { self.len() == 0 }
fn is_empty(&const self) -> bool { self.len() == 0 }
}
impl<T> Mutable for Deque<T> {
@ -43,7 +43,7 @@ impl<T> Mutable for Deque<T> {
pub impl<T> Deque<T> {
/// Create an empty Deque
static pure fn new() -> Deque<T> {
fn new() -> Deque<T> {
Deque{nelts: 0, lo: 0, hi: 0,
elts: vec::from_fn(initial_capacity, |_| None)}
}

View File

@ -69,7 +69,7 @@ pub mod reader {
// ebml reading
impl ops::Index<uint,Doc> for Doc {
pure fn index(&self, tag: uint) -> Doc {
fn index(&self, tag: uint) -> Doc {
unsafe {
get_doc(*self, tag)
}

View File

@ -314,7 +314,7 @@ impl<T,F:Flattener<T>,C:ByteChan> GenericChan<T> for FlatChan<T, F, C> {
}
pub impl<T,U:Unflattener<T>,P:BytePort> FlatPort<T, U, P> {
static fn new(u: U, p: P) -> FlatPort<T, U, P> {
fn new(u: U, p: P) -> FlatPort<T, U, P> {
FlatPort {
unflattener: u,
byte_port: p
@ -323,7 +323,7 @@ pub impl<T,U:Unflattener<T>,P:BytePort> FlatPort<T, U, P> {
}
pub impl<T,F:Flattener<T>,C:ByteChan> FlatChan<T, F, C> {
static fn new(f: F, c: C) -> FlatChan<T, F, C> {
fn new(f: F, c: C) -> FlatChan<T, F, C> {
FlatChan {
flattener: f,
byte_chan: c
@ -376,7 +376,7 @@ pub mod flatteners {
}
pub impl<T:Copy + Owned> PodUnflattener<T> {
static fn new() -> PodUnflattener<T> {
fn new() -> PodUnflattener<T> {
PodUnflattener {
bogus: ()
}
@ -384,7 +384,7 @@ pub mod flatteners {
}
pub impl<T:Copy + Owned> PodFlattener<T> {
static fn new() -> PodFlattener<T> {
fn new() -> PodFlattener<T> {
PodFlattener {
bogus: ()
}
@ -419,7 +419,7 @@ pub mod flatteners {
}
pub impl<D:Decoder,T:Decodable<D>> DeserializingUnflattener<D, T> {
static fn new(deserialize_buffer: DeserializeBuffer<T>)
fn new(deserialize_buffer: DeserializeBuffer<T>)
-> DeserializingUnflattener<D, T> {
DeserializingUnflattener {
deserialize_buffer: deserialize_buffer
@ -428,7 +428,7 @@ pub mod flatteners {
}
pub impl<S:Encoder,T:Encodable<S>> SerializingFlattener<S, T> {
static fn new(serialize_value: SerializeValue<T>)
fn new(serialize_value: SerializeValue<T>)
-> SerializingFlattener<S, T> {
SerializingFlattener {
serialize_value: serialize_value
@ -459,15 +459,15 @@ pub mod flatteners {
}
pub trait FromReader {
static fn from_reader(r: @Reader) -> Self;
fn from_reader(r: @Reader) -> Self;
}
pub trait FromWriter {
static fn from_writer(w: @Writer) -> Self;
fn from_writer(w: @Writer) -> Self;
}
impl FromReader for json::Decoder/&self {
static fn from_reader(r: @Reader) -> json::Decoder/&self {
fn from_reader(r: @Reader) -> json::Decoder/&self {
match json::from_reader(r) {
Ok(json) => {
json::Decoder(json)
@ -478,13 +478,13 @@ pub mod flatteners {
}
impl FromWriter for json::Encoder {
static fn from_writer(w: @Writer) -> json::Encoder {
fn from_writer(w: @Writer) -> json::Encoder {
json::Encoder(w)
}
}
impl FromReader for ebml::reader::Decoder {
static fn from_reader(r: @Reader) -> ebml::reader::Decoder {
fn from_reader(r: @Reader) -> ebml::reader::Decoder {
let buf = @r.read_whole_stream();
let doc = ebml::reader::Doc(buf);
ebml::reader::Decoder(doc)
@ -492,7 +492,7 @@ pub mod flatteners {
}
impl FromWriter for ebml::writer::Encoder {
static fn from_writer(w: @Writer) -> ebml::writer::Encoder {
fn from_writer(w: @Writer) -> ebml::writer::Encoder {
ebml::writer::Encoder(w)
}
}
@ -543,7 +543,7 @@ pub mod bytepipes {
}
pub impl<R:Reader> ReaderBytePort<R> {
static fn new(r: R) -> ReaderBytePort<R> {
fn new(r: R) -> ReaderBytePort<R> {
ReaderBytePort {
reader: r
}
@ -551,7 +551,7 @@ pub mod bytepipes {
}
pub impl<W:Writer> WriterByteChan<W> {
static fn new(w: W) -> WriterByteChan<W> {
fn new(w: W) -> WriterByteChan<W> {
WriterByteChan {
writer: w
}
@ -606,7 +606,7 @@ pub mod bytepipes {
}
pub impl PipeBytePort {
static fn new(p: Port<~[u8]>) -> PipeBytePort {
fn new(p: Port<~[u8]>) -> PipeBytePort {
PipeBytePort {
port: p,
buf: ~[]
@ -615,7 +615,7 @@ pub mod bytepipes {
}
pub impl PipeByteChan {
static fn new(c: Chan<~[u8]>) -> PipeByteChan {
fn new(c: Chan<~[u8]>) -> PipeByteChan {
PipeByteChan {
chan: c
}

View File

@ -56,7 +56,7 @@ pub impl<A:Copy> Future<A> {
pub impl<A> Future<A> {
pure fn get_ref(&self) -> &'self A {
fn get_ref(&self) -> &'self A {
/*!
* Executes the future's closure and then returns a borrowed
* pointer to the result. The borrowed pointer lasts as long as

View File

@ -17,7 +17,7 @@ pub struct BufReader {
}
pub impl BufReader {
static pub fn new(v: ~[u8]) -> BufReader {
pub fn new(v: ~[u8]) -> BufReader {
BufReader {
buf: v,
pos: 0

Some files were not shown because too many files have changed in this diff Show More