1
Fork 0

librustc: Remove all uses of static from functions. rs=destatic

This commit is contained in:
Patrick Walton 2013-03-21 19:07:54 -07:00
parent 1616ffd0c2
commit 4634f7edae
79 changed files with 281 additions and 286 deletions

View file

@ -49,7 +49,7 @@ pub pure fn is_false(v: bool) -> bool { !v }
/// Parse logic value from `s` /// Parse logic value from `s`
impl FromStr for bool { impl FromStr for bool {
static pure fn from_str(s: &str) -> Option<bool> { pure fn from_str(s: &str) -> Option<bool> {
if s == "true" { if s == "true" {
Some(true) Some(true)
} else if s == "false" { } else if s == "false" {

View file

@ -126,7 +126,7 @@ pub fn concat<T>(lists: @mut DList<@mut DList<T>>) -> @mut DList<T> {
} }
priv impl<T> DList<T> { priv impl<T> DList<T> {
static pure fn new_link(data: T) -> DListLink<T> { pure fn new_link(data: T) -> DListLink<T> {
Some(@mut DListNode { Some(@mut DListNode {
data: data, data: data,
linked: true, linked: true,

View file

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

View file

@ -373,7 +373,7 @@ pub mod linear {
pub impl<K:Hash + IterBytes + Eq,V> LinearMap<K, V> { pub impl<K:Hash + IterBytes + Eq,V> LinearMap<K, V> {
/// Create an empty LinearMap /// Create an empty LinearMap
static fn new() -> LinearMap<K, V> { fn new() -> LinearMap<K, V> {
linear_map_with_capacity(INITIAL_CAPACITY) linear_map_with_capacity(INITIAL_CAPACITY)
} }
@ -639,7 +639,7 @@ pub mod linear {
pub impl <T:Hash + IterBytes + Eq> LinearSet<T> { pub impl <T:Hash + IterBytes + Eq> LinearSet<T> {
/// Create an empty LinearSet /// 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. /// Reserve space for at least `n` elements in the hash table.
fn reserve_at_least(&mut self, n: uint) { fn reserve_at_least(&mut self, n: uint) {

View file

@ -89,7 +89,7 @@ pub trait Buildable<A> {
* as an argument a function that will push an element * as an argument a function that will push an element
* onto the sequence being constructed. * onto the sequence being constructed.
*/ */
static pure fn build_sized(size: uint, pure fn build_sized(size: uint,
builder: &fn(push: &pure fn(A))) -> Self; builder: &fn(push: &pure fn(A))) -> Self;
} }

View file

@ -277,12 +277,12 @@ impl cmp::Ord for f32 {
impl num::Zero for f32 { impl num::Zero for f32 {
#[inline(always)] #[inline(always)]
static pure fn zero() -> f32 { 0.0 } pure fn zero() -> f32 { 0.0 }
} }
impl num::One for f32 { impl num::One for f32 {
#[inline(always)] #[inline(always)]
static pure fn one() -> f32 { 1.0 } pure fn one() -> f32 { 1.0 }
} }
impl NumCast for f32 { impl NumCast for f32 {
@ -290,7 +290,7 @@ impl NumCast for f32 {
* Cast `n` to an `f32` * Cast `n` to an `f32`
*/ */
#[inline(always)] #[inline(always)]
static pure fn from<N:NumCast>(n: N) -> f32 { n.to_f32() } pure 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_u8(&self) -> u8 { *self as u8 }
#[inline(always)] pure fn to_u16(&self) -> u16 { *self as u16 } #[inline(always)] pure fn to_u16(&self) -> u16 { *self as u16 }
@ -568,12 +568,12 @@ pub pure fn from_str_radix(num: &str, rdx: uint) -> Option<f32> {
impl from_str::FromStr for f32 { impl from_str::FromStr for f32 {
#[inline(always)] #[inline(always)]
static pure fn from_str(val: &str) -> Option<f32> { from_str(val) } pure fn from_str(val: &str) -> Option<f32> { from_str(val) }
} }
impl num::FromStrRadix for f32 { impl num::FromStrRadix for f32 {
#[inline(always)] #[inline(always)]
static pure fn from_str_radix(val: &str, rdx: uint) -> Option<f32> { pure fn from_str_radix(val: &str, rdx: uint) -> Option<f32> {
from_str_radix(val, rdx) from_str_radix(val, rdx)
} }
} }

View file

@ -304,7 +304,7 @@ impl NumCast for f64 {
* Cast `n` to an `f64` * Cast `n` to an `f64`
*/ */
#[inline(always)] #[inline(always)]
static pure fn from<N:NumCast>(n: N) -> f64 { n.to_f64() } pure 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_u8(&self) -> u8 { *self as u8 }
#[inline(always)] pure fn to_u16(&self) -> u16 { *self as u16 } #[inline(always)] pure fn to_u16(&self) -> u16 { *self as u16 }
@ -325,12 +325,12 @@ impl NumCast for f64 {
impl num::Zero for f64 { impl num::Zero for f64 {
#[inline(always)] #[inline(always)]
static pure fn zero() -> f64 { 0.0 } pure fn zero() -> f64 { 0.0 }
} }
impl num::One for f64 { impl num::One for f64 {
#[inline(always)] #[inline(always)]
static pure fn one() -> f64 { 1.0 } pure fn one() -> f64 { 1.0 }
} }
#[cfg(notest)] #[cfg(notest)]
@ -592,12 +592,12 @@ pub pure fn from_str_radix(num: &str, rdx: uint) -> Option<f64> {
impl from_str::FromStr for f64 { impl from_str::FromStr for f64 {
#[inline(always)] #[inline(always)]
static pure fn from_str(val: &str) -> Option<f64> { from_str(val) } pure fn from_str(val: &str) -> Option<f64> { from_str(val) }
} }
impl num::FromStrRadix for f64 { impl num::FromStrRadix for f64 {
#[inline(always)] #[inline(always)]
static pure fn from_str_radix(val: &str, rdx: uint) -> Option<f64> { pure fn from_str_radix(val: &str, rdx: uint) -> Option<f64> {
from_str_radix(val, rdx) from_str_radix(val, rdx)
} }
} }

View file

@ -304,12 +304,12 @@ pub pure fn from_str_radix(num: &str, radix: uint) -> Option<float> {
impl from_str::FromStr for float { impl from_str::FromStr for float {
#[inline(always)] #[inline(always)]
static pure fn from_str(val: &str) -> Option<float> { from_str(val) } pure fn from_str(val: &str) -> Option<float> { from_str(val) }
} }
impl num::FromStrRadix for float { impl num::FromStrRadix for float {
#[inline(always)] #[inline(always)]
static pure fn from_str_radix(val: &str, radix: uint) -> Option<float> { pure fn from_str_radix(val: &str, radix: uint) -> Option<float> {
from_str_radix(val, radix) from_str_radix(val, radix)
} }
} }
@ -408,12 +408,12 @@ impl Ord for float {
impl num::Zero for float { impl num::Zero for float {
#[inline(always)] #[inline(always)]
static pure fn zero() -> float { 0.0 } pure fn zero() -> float { 0.0 }
} }
impl num::One for float { impl num::One for float {
#[inline(always)] #[inline(always)]
static pure fn one() -> float { 1.0 } pure fn one() -> float { 1.0 }
} }
impl NumCast for float { impl NumCast for float {
@ -421,7 +421,7 @@ impl NumCast for float {
* Cast `n` to a `float` * Cast `n` to a `float`
*/ */
#[inline(always)] #[inline(always)]
static pure fn from<N:NumCast>(n: N) -> float { n.to_float() } pure 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_u8(&self) -> u8 { *self as u8 }
#[inline(always)] pure fn to_u16(&self) -> u16 { *self as u16 } #[inline(always)] pure fn to_u16(&self) -> u16 { *self as u16 }

View file

@ -163,12 +163,12 @@ impl Eq for T {
impl num::Zero for T { impl num::Zero for T {
#[inline(always)] #[inline(always)]
static pure fn zero() -> T { 0 } pure fn zero() -> T { 0 }
} }
impl num::One for T { impl num::One for T {
#[inline(always)] #[inline(always)]
static pure fn one() -> T { 1 } pure fn one() -> T { 1 }
} }
#[cfg(notest)] #[cfg(notest)]
@ -221,14 +221,14 @@ pub pure fn parse_bytes(buf: &[u8], radix: uint) -> Option<T> {
impl FromStr for T { impl FromStr for T {
#[inline(always)] #[inline(always)]
static pure fn from_str(s: &str) -> Option<T> { pure fn from_str(s: &str) -> Option<T> {
from_str(s) from_str(s)
} }
} }
impl FromStrRadix for T { impl FromStrRadix for T {
#[inline(always)] #[inline(always)]
static pure fn from_str_radix(&self, s: &str, radix: uint) -> Option<T> { pure fn from_str_radix(s: &str, radix: uint) -> Option<T> {
from_str_radix(s, radix) from_str_radix(s, radix)
} }
} }

View file

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

View file

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

View file

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

View file

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

View file

@ -63,7 +63,7 @@ impl NumCast for int {
* Cast `n` to a `int` * Cast `n` to a `int`
*/ */
#[inline(always)] #[inline(always)]
static pure fn from<N:NumCast>(n: N) -> int { n.to_int() } pure 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_u8(&self) -> u8 { *self as u8 }
#[inline(always)] pure fn to_u16(&self) -> u16 { *self as u16 } #[inline(always)] pure fn to_u16(&self) -> u16 { *self as u16 }

View file

@ -18,15 +18,15 @@ pub mod strconv;
pub trait IntConvertible { pub trait IntConvertible {
pure fn to_int(&self) -> int; pure fn to_int(&self) -> int;
static pure fn from_int(n: int) -> Self; pure fn from_int(n: int) -> Self;
} }
pub trait Zero { pub trait Zero {
static pure fn zero() -> Self; pure fn zero() -> Self;
} }
pub trait One { pub trait One {
static pure fn one() -> Self; pure fn one() -> Self;
} }
pub pure fn abs<T:Ord + Zero + Neg<T>>(v: T) -> T { pub pure fn abs<T:Ord + Zero + Neg<T>>(v: T) -> T {
@ -67,7 +67,7 @@ pub pure fn cast<T:NumCast,U:NumCast>(n: T) -> U {
* An interface for generic numeric type casts * An interface for generic numeric type casts
*/ */
pub trait NumCast { pub trait NumCast {
static pure fn from<T:NumCast>(n: T) -> Self; pure fn from<T:NumCast>(n: T) -> Self;
pure fn to_u8(&self) -> u8; pure fn to_u8(&self) -> u8;
pure fn to_u16(&self) -> u16; pure fn to_u16(&self) -> u16;
@ -91,7 +91,7 @@ pub trait ToStrRadix {
} }
pub trait FromStrRadix { pub trait FromStrRadix {
static pub pure fn from_str_radix(str: &str, radix: uint) -> Option<Self>; pub pure fn from_str_radix(str: &str, radix: uint) -> Option<Self>;
} }
// Generic math functions: // Generic math functions:

View file

@ -66,10 +66,10 @@ pure fn is_neg_zero<T:Eq+One+Zero+NumStrConv+Div<T,T>>(num: &T) -> bool {
} }
pub trait NumStrConv { pub trait NumStrConv {
static pure fn NaN() -> Option<Self>; pure fn NaN() -> Option<Self>;
static pure fn inf() -> Option<Self>; pure fn inf() -> Option<Self>;
static pure fn neg_inf() -> Option<Self>; pure fn neg_inf() -> Option<Self>;
static pure fn neg_zero() -> Option<Self>; pure fn neg_zero() -> Option<Self>;
pure fn round_to_zero(&self) -> Self; pure fn round_to_zero(&self) -> Self;
pure fn fractional_part(&self) -> Self; pure fn fractional_part(&self) -> Self;
@ -78,13 +78,13 @@ pub trait NumStrConv {
macro_rules! impl_NumStrConv_Floating (($t:ty) => ( macro_rules! impl_NumStrConv_Floating (($t:ty) => (
impl NumStrConv for $t { impl NumStrConv for $t {
#[inline(always)] #[inline(always)]
static pure fn NaN() -> Option<$t> { Some( 0.0 / 0.0) } pure fn NaN() -> Option<$t> { Some( 0.0 / 0.0) }
#[inline(always)] #[inline(always)]
static pure fn inf() -> Option<$t> { Some( 1.0 / 0.0) } pure fn inf() -> Option<$t> { Some( 1.0 / 0.0) }
#[inline(always)] #[inline(always)]
static pure fn neg_inf() -> Option<$t> { Some(-1.0 / 0.0) } pure fn neg_inf() -> Option<$t> { Some(-1.0 / 0.0) }
#[inline(always)] #[inline(always)]
static pure fn neg_zero() -> Option<$t> { Some(-0.0 ) } pure fn neg_zero() -> Option<$t> { Some(-0.0 ) }
#[inline(always)] #[inline(always)]
pure fn round_to_zero(&self) -> $t { pure fn round_to_zero(&self) -> $t {
@ -102,10 +102,10 @@ macro_rules! impl_NumStrConv_Floating (($t:ty) => (
macro_rules! impl_NumStrConv_Integer (($t:ty) => ( macro_rules! impl_NumStrConv_Integer (($t:ty) => (
impl NumStrConv for $t { impl NumStrConv for $t {
#[inline(always)] static pure fn NaN() -> Option<$t> { None } #[inline(always)] pure fn NaN() -> Option<$t> { None }
#[inline(always)] static pure fn inf() -> Option<$t> { None } #[inline(always)] pure fn inf() -> Option<$t> { None }
#[inline(always)] static pure fn neg_inf() -> Option<$t> { None } #[inline(always)] pure fn neg_inf() -> Option<$t> { None }
#[inline(always)] static pure fn neg_zero() -> Option<$t> { None } #[inline(always)] pure fn neg_zero() -> Option<$t> { None }
#[inline(always)] pure fn round_to_zero(&self) -> $t { *self } #[inline(always)] pure fn round_to_zero(&self) -> $t { *self }
#[inline(always)] pure fn fractional_part(&self) -> $t { 0 } #[inline(always)] pure fn fractional_part(&self) -> $t { 0 }

View file

@ -129,12 +129,12 @@ impl Eq for T {
impl num::Zero for T { impl num::Zero for T {
#[inline(always)] #[inline(always)]
static pure fn zero() -> T { 0 } pure fn zero() -> T { 0 }
} }
impl num::One for T { impl num::One for T {
#[inline(always)] #[inline(always)]
static pure fn one() -> T { 1 } pure fn one() -> T { 1 }
} }
#[cfg(notest)] #[cfg(notest)]
@ -187,14 +187,14 @@ pub pure fn parse_bytes(buf: &[u8], radix: uint) -> Option<T> {
impl FromStr for T { impl FromStr for T {
#[inline(always)] #[inline(always)]
static pure fn from_str(s: &str) -> Option<T> { pure fn from_str(s: &str) -> Option<T> {
from_str(s) from_str(s)
} }
} }
impl FromStrRadix for T { impl FromStrRadix for T {
#[inline(always)] #[inline(always)]
static pure fn from_str_radix(&self, s: &str, radix: uint) -> Option<T> { pure fn from_str_radix(s: &str, radix: uint) -> Option<T> {
from_str_radix(s, radix) from_str_radix(s, radix)
} }
} }

View file

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

View file

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

View file

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

View file

@ -31,7 +31,7 @@ impl NumCast for u8 {
* Cast `n` to a `u8` * Cast `n` to a `u8`
*/ */
#[inline(always)] #[inline(always)]
static pure fn from<N:NumCast>(n: N) -> u8 { n.to_u8() } pure fn from<N:NumCast>(n: N) -> u8 { n.to_u8() }
#[inline(always)] pure fn to_u8(&self) -> u8 { *self } #[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_u16(&self) -> u16 { *self as u16 }

View file

@ -215,7 +215,7 @@ impl NumCast for uint {
* Cast `n` to a `uint` * Cast `n` to a `uint`
*/ */
#[inline(always)] #[inline(always)]
static pure fn from<N:NumCast>(n: N) -> uint { n.to_uint() } pure 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_u8(&self) -> u8 { *self as u8 }
#[inline(always)] pure fn to_u16(&self) -> u16 { *self as u16 } #[inline(always)] pure fn to_u16(&self) -> u16 { *self as u16 }

View file

@ -43,7 +43,7 @@ pub pure fn PosixPath(s: &str) -> PosixPath {
} }
pub trait GenericPath { pub trait GenericPath {
static pure fn from_str(&str) -> Self; pure fn from_str(&str) -> Self;
pure fn dirname(&self) -> ~str; pure fn dirname(&self) -> ~str;
pure fn filename(&self) -> Option<~str>; pure fn filename(&self) -> Option<~str>;
@ -380,7 +380,7 @@ impl ToStr for PosixPath {
// PosixPath and WindowsPath, most of their methods are common. // PosixPath and WindowsPath, most of their methods are common.
impl GenericPath for PosixPath { impl GenericPath for PosixPath {
static pure fn from_str(s: &str) -> PosixPath { pure fn from_str(s: &str) -> PosixPath {
let mut components = str::split_nonempty(s, |c| c == '/'); let mut components = str::split_nonempty(s, |c| c == '/');
let is_absolute = (s.len() != 0 && s[0] == '/' as u8); let is_absolute = (s.len() != 0 && s[0] == '/' as u8);
return PosixPath { is_absolute: is_absolute, return PosixPath { is_absolute: is_absolute,
@ -563,7 +563,7 @@ impl ToStr for WindowsPath {
impl GenericPath for WindowsPath { impl GenericPath for WindowsPath {
static pure fn from_str(s: &str) -> WindowsPath { pure fn from_str(s: &str) -> WindowsPath {
let host; let host;
let device; let device;
let rest; let rest;

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -139,7 +139,7 @@ impl<T> Map<uint, T> for TrieMap<T> {
pub impl<T> TrieMap<T> { pub impl<T> TrieMap<T> {
/// Create an empty TrieMap /// Create an empty TrieMap
#[inline(always)] #[inline(always)]
static pure fn new() -> TrieMap<T> { pure fn new() -> TrieMap<T> {
TrieMap{root: TrieNode::new(), length: 0} TrieMap{root: TrieNode::new(), length: 0}
} }
@ -192,7 +192,7 @@ impl Mutable for TrieSet {
impl TrieSet { impl TrieSet {
/// Create an empty TrieSet /// Create an empty TrieSet
#[inline(always)] #[inline(always)]
static pure fn new() -> TrieSet { pure fn new() -> TrieSet {
TrieSet{map: TrieMap::new()} TrieSet{map: TrieMap::new()}
} }
@ -220,7 +220,7 @@ struct TrieNode<T> {
impl<T> TrieNode<T> { impl<T> TrieNode<T> {
#[inline(always)] #[inline(always)]
static pure fn new() -> TrieNode<T> { pure fn new() -> TrieNode<T> {
// FIXME: #5244: [Nothing, ..SIZE] should be possible without Copy // FIXME: #5244: [Nothing, ..SIZE] should be possible without Copy
TrieNode{count: 0, TrieNode{count: 0,
children: [Nothing, Nothing, Nothing, Nothing, children: [Nothing, Nothing, Nothing, Nothing,

View file

@ -140,7 +140,7 @@ pub mod ct {
} }
pub impl<T> Parsed<T> { pub impl<T> Parsed<T> {
static pure fn new(&self, val: T, next: uint) -> Parsed<T> { pure fn new(val: T, next: uint) -> Parsed<T> {
Parsed {val: val, next: next} Parsed {val: val, next: next}
} }
} }

View file

@ -82,7 +82,7 @@ pub struct LanguageItems {
} }
pub impl LanguageItems { pub impl LanguageItems {
static pub fn new(&self) -> LanguageItems { pub fn new() -> LanguageItems {
LanguageItems { LanguageItems {
items: [ None, ..35 ] 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 { match index {
0 => "const", 0 => "const",
1 => "copy", 1 => "copy",

View file

@ -311,7 +311,7 @@ impl ToStr for MutabilityCategory {
} }
pub impl MutabilityCategory { pub impl MutabilityCategory {
static fn from_mutbl(&self, m: ast::mutability) -> MutabilityCategory { fn from_mutbl(m: ast::mutability) -> MutabilityCategory {
match m { match m {
m_imm => McImmutable, m_imm => McImmutable,
m_const => McReadOnly, m_const => McReadOnly,

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: // When we translate a static fn defined in a trait like:
// //
// trait<T1...Tn> Trait { // trait<T1...Tn> Trait {
// static fn foo<M1...Mn>(...) {...} // fn foo<M1...Mn>(...) {...}
// } // }
// //
// this winds up being translated as something like: // this winds up being translated as something like:

View file

@ -1720,7 +1720,7 @@ pub impl TypeContents {
!self.intersects(TypeContents::noncopyable(cx)) !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_DTOR + TC_BORROWED_MUT + TC_ONCE_CLOSURE + TC_OWNED_CLOSURE +
TC_EMPTY_ENUM TC_EMPTY_ENUM
} }
@ -1729,7 +1729,7 @@ pub impl TypeContents {
!self.intersects(TypeContents::nondurable(cx)) !self.intersects(TypeContents::nondurable(cx))
} }
static fn nondurable(_cx: ctxt) -> TypeContents { fn nondurable(_cx: ctxt) -> TypeContents {
TC_BORROWED_POINTER TC_BORROWED_POINTER
} }
@ -1737,7 +1737,7 @@ pub impl TypeContents {
!self.intersects(TypeContents::nonowned(cx)) !self.intersects(TypeContents::nonowned(cx))
} }
static fn nonowned(_cx: ctxt) -> TypeContents { fn nonowned(_cx: ctxt) -> TypeContents {
TC_MANAGED + TC_BORROWED_POINTER TC_MANAGED + TC_BORROWED_POINTER
} }
@ -1749,7 +1749,7 @@ pub impl TypeContents {
!self.intersects(TypeContents::nonconst(cx)) !self.intersects(TypeContents::nonconst(cx))
} }
static fn nonconst(_cx: ctxt) -> TypeContents { fn nonconst(_cx: ctxt) -> TypeContents {
TC_MUTABLE TC_MUTABLE
} }
@ -1757,7 +1757,7 @@ pub impl TypeContents {
self.intersects(TypeContents::nonimplicitly_copyable(cx)) 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; let base = TypeContents::noncopyable(cx) + TC_OWNED_POINTER;
if cx.vecs_implicitly_copyable {base} else {base + TC_OWNED_VEC} if cx.vecs_implicitly_copyable {base} else {base + TC_OWNED_VEC}
} }
@ -1766,7 +1766,7 @@ pub impl TypeContents {
!self.intersects(TypeContents::nondefault_mode(cx)) !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); let tc = TypeContents::nonimplicitly_copyable(cx);
tc + TC_BIG + TC_OWNED_VEC // disregard cx.vecs_implicitly_copyable tc + TC_BIG + TC_OWNED_VEC // disregard cx.vecs_implicitly_copyable
} }
@ -1776,7 +1776,7 @@ pub impl TypeContents {
self.intersects(tc) self.intersects(tc)
} }
static fn owned(&self, _cx: ctxt) -> TypeContents { fn owned(_cx: ctxt) -> TypeContents {
//! Any kind of owned contents. //! Any kind of owned contents.
TC_OWNED_CLOSURE + TC_OWNED_POINTER + TC_OWNED_VEC TC_OWNED_CLOSURE + TC_OWNED_POINTER + TC_OWNED_VEC
} }

View file

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

View file

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

View file

@ -94,7 +94,7 @@ impl ToStr for BigUint {
} }
impl from_str::FromStr for BigUint { impl from_str::FromStr for BigUint {
static pure fn from_str(s: &str) -> Option<BigUint> { pure fn from_str(s: &str) -> Option<BigUint> {
BigUint::from_str_radix(s, 10) BigUint::from_str_radix(s, 10)
} }
} }
@ -116,11 +116,11 @@ impl Shr<uint, BigUint> for BigUint {
} }
impl Zero for BigUint { impl Zero for BigUint {
static pure fn zero() -> BigUint { BigUint::new(~[]) } pure fn zero() -> BigUint { BigUint::new(~[]) }
} }
impl One for BigUint { impl One for BigUint {
static pub pure fn one() -> BigUint { BigUint::new(~[1]) } pub pure fn one() -> BigUint { BigUint::new(~[1]) }
} }
impl Add<BigUint, BigUint> for BigUint { impl Add<BigUint, BigUint> for BigUint {
@ -256,14 +256,14 @@ impl IntConvertible for BigUint {
uint::min(self.to_uint(), int::max_value as uint) as int uint::min(self.to_uint(), int::max_value as uint) as int
} }
static pure fn from_int(n: int) -> BigUint { pure fn from_int(n: int) -> BigUint {
if (n < 0) { Zero::zero() } else { BigUint::from_uint(n as uint) } if (n < 0) { Zero::zero() } else { BigUint::from_uint(n as uint) }
} }
} }
pub impl BigUint { pub impl BigUint {
/// Creates and initializes an BigUint. /// Creates and initializes an BigUint.
static pub pure fn new(v: ~[BigDigit]) -> BigUint { pub pure fn new(v: ~[BigDigit]) -> BigUint {
// omit trailing zeros // omit trailing zeros
let new_len = v.rposition(|n| *n != 0).map_default(0, |p| *p + 1); 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. /// Creates and initializes an BigUint.
static pub pure fn from_uint(n: uint) -> BigUint { pub pure fn from_uint(n: uint) -> BigUint {
match BigDigit::from_uint(n) { match BigDigit::from_uint(n) {
(0, 0) => Zero::zero(), (0, 0) => Zero::zero(),
(0, n0) => BigUint::new(~[n0]), (0, n0) => BigUint::new(~[n0]),
@ -283,18 +283,18 @@ pub impl BigUint {
} }
/// Creates and initializes an BigUint. /// Creates and initializes an BigUint.
static pub pure fn from_slice(slice: &[BigDigit]) -> BigUint { pub pure fn from_slice(slice: &[BigDigit]) -> BigUint {
return BigUint::new(vec::from_slice(slice)); return BigUint::new(vec::from_slice(slice));
} }
/// Creates and initializes an BigUint. /// Creates and initializes an BigUint.
static pub pure fn from_str_radix(s: &str, radix: uint) pub pure fn from_str_radix(s: &str, radix: uint)
-> Option<BigUint> { -> Option<BigUint> {
BigUint::parse_bytes(str::to_bytes(s), radix) BigUint::parse_bytes(str::to_bytes(s), radix)
} }
/// Creates and initializes an BigUint. /// Creates and initializes an BigUint.
static pub pure fn parse_bytes(buf: &[u8], radix: uint) pub pure fn parse_bytes(buf: &[u8], radix: uint)
-> Option<BigUint> { -> Option<BigUint> {
let (base, unit_len) = get_radix_base(radix); let (base, unit_len) = get_radix_base(radix);
let base_num: BigUint = BigUint::from_uint(base); let base_num: BigUint = BigUint::from_uint(base);
@ -614,7 +614,7 @@ impl ToStr for BigInt {
} }
impl from_str::FromStr for BigInt { impl from_str::FromStr for BigInt {
static pure fn from_str(s: &str) -> Option<BigInt> { pure fn from_str(s: &str) -> Option<BigInt> {
BigInt::from_str_radix(s, 10) BigInt::from_str_radix(s, 10)
} }
} }
@ -632,13 +632,13 @@ impl Shr<uint, BigInt> for BigInt {
} }
impl Zero for BigInt { impl Zero for BigInt {
static pub pure fn zero() -> BigInt { pub pure fn zero() -> BigInt {
BigInt::from_biguint(Zero, Zero::zero()) BigInt::from_biguint(Zero, Zero::zero())
} }
} }
impl One for BigInt { impl One for BigInt {
static pub pure fn one() -> BigInt { pub pure fn one() -> BigInt {
BigInt::from_biguint(Plus, One::one()) BigInt::from_biguint(Plus, One::one())
} }
} }
@ -721,7 +721,7 @@ impl IntConvertible for BigInt {
} }
} }
static pure fn from_int(n: int) -> BigInt { pure fn from_int(n: int) -> BigInt {
if n > 0 { if n > 0 {
return BigInt::from_biguint(Plus, BigUint::from_uint(n as uint)); return BigInt::from_biguint(Plus, BigUint::from_uint(n as uint));
} }
@ -736,12 +736,12 @@ impl IntConvertible for BigInt {
pub impl BigInt { pub impl BigInt {
/// Creates and initializes an BigInt. /// Creates and initializes an BigInt.
static pub pure fn new(sign: Sign, v: ~[BigDigit]) -> BigInt { pub pure fn new(sign: Sign, v: ~[BigDigit]) -> BigInt {
BigInt::from_biguint(sign, BigUint::new(v)) BigInt::from_biguint(sign, BigUint::new(v))
} }
/// Creates and initializes an BigInt. /// Creates and initializes an BigInt.
static pub pure fn from_biguint(sign: Sign, data: BigUint) -> BigInt { pub pure fn from_biguint(sign: Sign, data: BigUint) -> BigInt {
if sign == Zero || data.is_zero() { if sign == Zero || data.is_zero() {
return BigInt { sign: Zero, data: Zero::zero() }; return BigInt { sign: Zero, data: Zero::zero() };
} }
@ -749,24 +749,24 @@ pub impl BigInt {
} }
/// Creates and initializes an BigInt. /// Creates and initializes an BigInt.
static pub pure fn from_uint(n: uint) -> BigInt { pub pure fn from_uint(n: uint) -> BigInt {
if n == 0 { return Zero::zero(); } if n == 0 { return Zero::zero(); }
return BigInt::from_biguint(Plus, BigUint::from_uint(n)); return BigInt::from_biguint(Plus, BigUint::from_uint(n));
} }
/// Creates and initializes an BigInt. /// Creates and initializes an BigInt.
static pub pure fn from_slice(sign: Sign, slice: &[BigDigit]) -> BigInt { pub pure fn from_slice(sign: Sign, slice: &[BigDigit]) -> BigInt {
BigInt::from_biguint(sign, BigUint::from_slice(slice)) BigInt::from_biguint(sign, BigUint::from_slice(slice))
} }
/// Creates and initializes an BigInt. /// Creates and initializes an BigInt.
static pub pure fn from_str_radix(s: &str, radix: uint) pub pure fn from_str_radix(s: &str, radix: uint)
-> Option<BigInt> { -> Option<BigInt> {
BigInt::parse_bytes(str::to_bytes(s), radix) BigInt::parse_bytes(str::to_bytes(s), radix)
} }
/// Creates and initializes an BigInt. /// Creates and initializes an BigInt.
static pub pure fn parse_bytes(buf: &[u8], radix: uint) pub pure fn parse_bytes(buf: &[u8], radix: uint)
-> Option<BigInt> { -> Option<BigInt> {
if buf.is_empty() { return None; } if buf.is_empty() { return None; }
let mut sign = Plus; let mut sign = Plus;

View file

@ -27,7 +27,7 @@ fn small_mask(nbits: uint) -> uint {
} }
pub impl SmallBitv { pub impl SmallBitv {
static fn new(bits: uint) -> SmallBitv { fn new(bits: uint) -> SmallBitv {
SmallBitv {bits: bits} SmallBitv {bits: bits}
} }
@ -124,7 +124,7 @@ fn big_mask(nbits: uint, elem: uint) -> uint {
} }
pub impl BigBitv { pub impl BigBitv {
static fn new(storage: ~[uint]) -> BigBitv { fn new(storage: ~[uint]) -> BigBitv {
BigBitv {storage: storage} BigBitv {storage: storage}
} }
@ -256,7 +256,7 @@ priv impl Bitv {
} }
pub 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 { let rep = if nbits <= uint::bits {
Small(~SmallBitv::new(if init {!0} else {0})) Small(~SmallBitv::new(if init {!0} else {0}))
} }
@ -592,12 +592,12 @@ pub struct BitvSet {
pub impl BitvSet { pub impl BitvSet {
/// Creates a new bit vector set with initially no contents /// Creates a new bit vector set with initially no contents
static fn new() -> BitvSet { fn new() -> BitvSet {
BitvSet{ size: 0, bitv: BigBitv::new(~[0]) } BitvSet{ size: 0, bitv: BigBitv::new(~[0]) }
} }
/// Creates a new bit vector set from the given bit vector /// 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; let mut size = 0;
for bitv.ones |_| { for bitv.ones |_| {
size += 1; size += 1;

View file

@ -43,7 +43,7 @@ impl<T> Mutable for Deque<T> {
pub impl<T> Deque<T> { pub impl<T> Deque<T> {
/// Create an empty Deque /// Create an empty Deque
static pure fn new() -> Deque<T> { pure fn new() -> Deque<T> {
Deque{nelts: 0, lo: 0, hi: 0, Deque{nelts: 0, lo: 0, hi: 0,
elts: vec::from_fn(initial_capacity, |_| None)} elts: vec::from_fn(initial_capacity, |_| None)}
} }

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

View file

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

View file

@ -45,7 +45,7 @@ struct UserInfo {
pub type Query = ~[(~str, ~str)]; pub type Query = ~[(~str, ~str)];
pub impl Url { pub impl Url {
static pure fn new( pure fn new(
scheme: ~str, scheme: ~str,
user: Option<UserInfo>, user: Option<UserInfo>,
host: ~str, host: ~str,
@ -67,7 +67,7 @@ pub impl Url {
} }
pub impl UserInfo { pub impl UserInfo {
static pure fn new(user: ~str, pass: Option<~str>) -> UserInfo { pure fn new(user: ~str, pass: Option<~str>) -> UserInfo {
UserInfo { user: user, pass: pass } UserInfo { user: user, pass: pass }
} }
} }
@ -666,7 +666,7 @@ pub pure fn from_str(rawurl: &str) -> Result<Url, ~str> {
} }
impl FromStr for Url { impl FromStr for Url {
static pure fn from_str(s: &str) -> Option<Url> { pure fn from_str(s: &str) -> Option<Url> {
match from_str(s) { match from_str(s) {
Ok(url) => Some(url), Ok(url) => Some(url),
Err(_) => None Err(_) => None

View file

@ -118,10 +118,10 @@ pub impl <T:Ord> PriorityQueue<T> {
} }
/// Create an empty PriorityQueue /// Create an empty PriorityQueue
static pure fn new() -> PriorityQueue<T> { PriorityQueue{data: ~[],} } pure fn new() -> PriorityQueue<T> { PriorityQueue{data: ~[],} }
/// Create a PriorityQueue from a vector (heapify) /// Create a PriorityQueue from a vector (heapify)
static pure fn from_vec(xs: ~[T]) -> PriorityQueue<T> { pure fn from_vec(xs: ~[T]) -> PriorityQueue<T> {
let mut q = PriorityQueue{data: xs,}; let mut q = PriorityQueue{data: xs,};
let mut n = q.len() / 2; let mut n = q.len() / 2;
while n > 0 { while n > 0 {

View file

@ -110,7 +110,7 @@ pub trait Encodable<S:Encoder> {
} }
pub trait Decodable<D:Decoder> { pub trait Decodable<D:Decoder> {
static fn decode(&self, d: &D) -> Self; fn decode(d: &D) -> Self;
} }
impl<S:Encoder> Encodable<S> for uint { impl<S:Encoder> Encodable<S> for uint {
@ -118,7 +118,7 @@ impl<S:Encoder> Encodable<S> for uint {
} }
impl<D:Decoder> Decodable<D> for uint { impl<D:Decoder> Decodable<D> for uint {
static fn decode(&self, d: &D) -> uint { fn decode(d: &D) -> uint {
d.read_uint() d.read_uint()
} }
} }
@ -128,7 +128,7 @@ impl<S:Encoder> Encodable<S> for u8 {
} }
impl<D:Decoder> Decodable<D> for u8 { impl<D:Decoder> Decodable<D> for u8 {
static fn decode(&self, d: &D) -> u8 { fn decode(d: &D) -> u8 {
d.read_u8() d.read_u8()
} }
} }
@ -138,7 +138,7 @@ impl<S:Encoder> Encodable<S> for u16 {
} }
impl<D:Decoder> Decodable<D> for u16 { impl<D:Decoder> Decodable<D> for u16 {
static fn decode(&self, d: &D) -> u16 { fn decode(d: &D) -> u16 {
d.read_u16() d.read_u16()
} }
} }
@ -148,7 +148,7 @@ impl<S:Encoder> Encodable<S> for u32 {
} }
impl<D:Decoder> Decodable<D> for u32 { impl<D:Decoder> Decodable<D> for u32 {
static fn decode(&self, d: &D) -> u32 { fn decode(d: &D) -> u32 {
d.read_u32() d.read_u32()
} }
} }
@ -158,7 +158,7 @@ impl<S:Encoder> Encodable<S> for u64 {
} }
impl<D:Decoder> Decodable<D> for u64 { impl<D:Decoder> Decodable<D> for u64 {
static fn decode(&self, d: &D) -> u64 { fn decode(d: &D) -> u64 {
d.read_u64() d.read_u64()
} }
} }
@ -168,7 +168,7 @@ impl<S:Encoder> Encodable<S> for int {
} }
impl<D:Decoder> Decodable<D> for int { impl<D:Decoder> Decodable<D> for int {
static fn decode(&self, d: &D) -> int { fn decode(d: &D) -> int {
d.read_int() d.read_int()
} }
} }
@ -178,7 +178,7 @@ impl<S:Encoder> Encodable<S> for i8 {
} }
impl<D:Decoder> Decodable<D> for i8 { impl<D:Decoder> Decodable<D> for i8 {
static fn decode(&self, d: &D) -> i8 { fn decode(d: &D) -> i8 {
d.read_i8() d.read_i8()
} }
} }
@ -188,7 +188,7 @@ impl<S:Encoder> Encodable<S> for i16 {
} }
impl<D:Decoder> Decodable<D> for i16 { impl<D:Decoder> Decodable<D> for i16 {
static fn decode(&self, d: &D) -> i16 { fn decode(d: &D) -> i16 {
d.read_i16() d.read_i16()
} }
} }
@ -198,7 +198,7 @@ impl<S:Encoder> Encodable<S> for i32 {
} }
impl<D:Decoder> Decodable<D> for i32 { impl<D:Decoder> Decodable<D> for i32 {
static fn decode(&self, d: &D) -> i32 { fn decode(d: &D) -> i32 {
d.read_i32() d.read_i32()
} }
} }
@ -208,7 +208,7 @@ impl<S:Encoder> Encodable<S> for i64 {
} }
impl<D:Decoder> Decodable<D> for i64 { impl<D:Decoder> Decodable<D> for i64 {
static fn decode(&self, d: &D) -> i64 { fn decode(d: &D) -> i64 {
d.read_i64() d.read_i64()
} }
} }
@ -222,7 +222,7 @@ impl<S:Encoder> Encodable<S> for ~str {
} }
impl<D:Decoder> Decodable<D> for ~str { impl<D:Decoder> Decodable<D> for ~str {
static fn decode(&self, d: &D) -> ~str { fn decode(d: &D) -> ~str {
d.read_owned_str() d.read_owned_str()
} }
} }
@ -232,7 +232,7 @@ impl<S:Encoder> Encodable<S> for @str {
} }
impl<D:Decoder> Decodable<D> for @str { impl<D:Decoder> Decodable<D> for @str {
static fn decode(&self, d: &D) -> @str { fn decode(d: &D) -> @str {
d.read_managed_str() d.read_managed_str()
} }
} }
@ -242,7 +242,7 @@ impl<S:Encoder> Encodable<S> for float {
} }
impl<D:Decoder> Decodable<D> for float { impl<D:Decoder> Decodable<D> for float {
static fn decode(&self, d: &D) -> float { fn decode(d: &D) -> float {
d.read_float() d.read_float()
} }
} }
@ -252,7 +252,7 @@ impl<S:Encoder> Encodable<S> for f32 {
} }
impl<D:Decoder> Decodable<D> for f32 { impl<D:Decoder> Decodable<D> for f32 {
static fn decode(&self, d: &D) -> f32 { fn decode(d: &D) -> f32 {
d.read_f32() } d.read_f32() }
} }
@ -261,7 +261,7 @@ impl<S:Encoder> Encodable<S> for f64 {
} }
impl<D:Decoder> Decodable<D> for f64 { impl<D:Decoder> Decodable<D> for f64 {
static fn decode(&self, d: &D) -> f64 { fn decode(d: &D) -> f64 {
d.read_f64() d.read_f64()
} }
} }
@ -271,7 +271,7 @@ impl<S:Encoder> Encodable<S> for bool {
} }
impl<D:Decoder> Decodable<D> for bool { impl<D:Decoder> Decodable<D> for bool {
static fn decode(&self, d: &D) -> bool { fn decode(d: &D) -> bool {
d.read_bool() d.read_bool()
} }
} }
@ -281,7 +281,7 @@ impl<S:Encoder> Encodable<S> for () {
} }
impl<D:Decoder> Decodable<D> for () { impl<D:Decoder> Decodable<D> for () {
static fn decode(&self, d: &D) -> () { fn decode(d: &D) -> () {
d.read_nil() d.read_nil()
} }
} }
@ -299,7 +299,7 @@ impl<S:Encoder,T:Encodable<S>> Encodable<S> for ~T {
} }
impl<D:Decoder,T:Decodable<D>> Decodable<D> for ~T { impl<D:Decoder,T:Decodable<D>> Decodable<D> for ~T {
static fn decode(&self, d: &D) -> ~T { fn decode(d: &D) -> ~T {
d.read_owned(|| ~Decodable::decode(d)) d.read_owned(|| ~Decodable::decode(d))
} }
} }
@ -311,7 +311,7 @@ impl<S:Encoder,T:Encodable<S>> Encodable<S> for @T {
} }
impl<D:Decoder,T:Decodable<D>> Decodable<D> for @T { impl<D:Decoder,T:Decodable<D>> Decodable<D> for @T {
static fn decode(&self, d: &D) -> @T { fn decode(d: &D) -> @T {
d.read_managed(|| @Decodable::decode(d)) d.read_managed(|| @Decodable::decode(d))
} }
} }
@ -337,7 +337,7 @@ impl<S:Encoder,T:Encodable<S>> Encodable<S> for ~[T] {
} }
impl<D:Decoder,T:Decodable<D>> Decodable<D> for ~[T] { impl<D:Decoder,T:Decodable<D>> Decodable<D> for ~[T] {
static fn decode(&self, d: &D) -> ~[T] { fn decode(d: &D) -> ~[T] {
do d.read_owned_vec |len| { do d.read_owned_vec |len| {
do vec::from_fn(len) |i| { do vec::from_fn(len) |i| {
d.read_vec_elt(i, || Decodable::decode(d)) d.read_vec_elt(i, || Decodable::decode(d))
@ -357,7 +357,7 @@ impl<S:Encoder,T:Encodable<S>> Encodable<S> for @[T] {
} }
impl<D:Decoder,T:Decodable<D>> Decodable<D> for @[T] { impl<D:Decoder,T:Decodable<D>> Decodable<D> for @[T] {
static fn decode(&self, d: &D) -> @[T] { fn decode(d: &D) -> @[T] {
do d.read_managed_vec |len| { do d.read_managed_vec |len| {
do at_vec::from_fn(len) |i| { do at_vec::from_fn(len) |i| {
d.read_vec_elt(i, || Decodable::decode(d)) d.read_vec_elt(i, || Decodable::decode(d))
@ -382,7 +382,7 @@ impl<S:Encoder,T:Encodable<S>> Encodable<S> for Option<T> {
} }
impl<D:Decoder,T:Decodable<D>> Decodable<D> for Option<T> { impl<D:Decoder,T:Decodable<D>> Decodable<D> for Option<T> {
static fn decode(&self, d: &D) -> Option<T> { fn decode(d: &D) -> Option<T> {
do d.read_enum(~"option") { do d.read_enum(~"option") {
do d.read_enum_variant |i| { do d.read_enum_variant |i| {
match i { match i {
@ -410,7 +410,7 @@ impl<S:Encoder,T0:Encodable<S>,T1:Encodable<S>> Encodable<S> for (T0, T1) {
} }
impl<D:Decoder,T0:Decodable<D>,T1:Decodable<D>> Decodable<D> for (T0, T1) { impl<D:Decoder,T0:Decodable<D>,T1:Decodable<D>> Decodable<D> for (T0, T1) {
static fn decode(&self, d: &D) -> (T0, T1) { fn decode(d: &D) -> (T0, T1) {
do d.read_tup(2) { do d.read_tup(2) {
( (
d.read_tup_elt(0, || Decodable::decode(d)), d.read_tup_elt(0, || Decodable::decode(d)),
@ -445,7 +445,7 @@ impl<
T1: Decodable<D>, T1: Decodable<D>,
T2: Decodable<D> T2: Decodable<D>
> Decodable<D> for (T0, T1, T2) { > Decodable<D> for (T0, T1, T2) {
static fn decode(&self, d: &D) -> (T0, T1, T2) { fn decode(d: &D) -> (T0, T1, T2) {
do d.read_tup(3) { do d.read_tup(3) {
( (
d.read_tup_elt(0, || Decodable::decode(d)), d.read_tup_elt(0, || Decodable::decode(d)),
@ -484,7 +484,7 @@ impl<
T2: Decodable<D>, T2: Decodable<D>,
T3: Decodable<D> T3: Decodable<D>
> Decodable<D> for (T0, T1, T2, T3) { > Decodable<D> for (T0, T1, T2, T3) {
static fn decode(&self, d: &D) -> (T0, T1, T2, T3) { fn decode(d: &D) -> (T0, T1, T2, T3) {
do d.read_tup(4) { do d.read_tup(4) {
( (
d.read_tup_elt(0, || Decodable::decode(d)), d.read_tup_elt(0, || Decodable::decode(d)),
@ -527,7 +527,7 @@ impl<
T3: Decodable<D>, T3: Decodable<D>,
T4: Decodable<D> T4: Decodable<D>
> Decodable<D> for (T0, T1, T2, T3, T4) { > Decodable<D> for (T0, T1, T2, T3, T4) {
static fn decode(&self, d: &D) fn decode(d: &D)
-> (T0, T1, T2, T3, T4) { -> (T0, T1, T2, T3, T4) {
do d.read_tup(5) { do d.read_tup(5) {
( (

View file

@ -135,7 +135,7 @@ impl<V> Map<uint, V> for SmallIntMap<V> {
pub impl<V> SmallIntMap<V> { pub impl<V> SmallIntMap<V> {
/// Create an empty SmallIntMap /// Create an empty SmallIntMap
static pure fn new() -> SmallIntMap<V> { SmallIntMap{v: ~[]} } pure fn new() -> SmallIntMap<V> { SmallIntMap{v: ~[]} }
pure fn get(&self, key: &uint) -> &'self V { pure fn get(&self, key: &uint) -> &'self V {
self.find(key).expect("key not present") self.find(key).expect("key not present")

View file

@ -43,9 +43,10 @@ pub impl<T> TaskPool<T> {
/// new scheduler with the given mode. The provided `init_fn_factory` /// new scheduler with the given mode. The provided `init_fn_factory`
/// returns a function which, given the index of the task, should return /// returns a function which, given the index of the task, should return
/// local data to be kept around in that task. /// local data to be kept around in that task.
static fn new(n_tasks: uint, fn new(n_tasks: uint,
opt_sched_mode: Option<SchedMode>, opt_sched_mode: Option<SchedMode>,
init_fn_factory: ~fn() -> ~fn(uint) -> T) -> TaskPool<T> { init_fn_factory: ~fn() -> ~fn(uint) -> T)
-> TaskPool<T> {
fail_unless!(n_tasks >= 1); fail_unless!(n_tasks >= 1);
let channels = do vec::from_fn(n_tasks) |i| { let channels = do vec::from_fn(n_tasks) |i| {

View file

@ -51,7 +51,7 @@ pub struct Timespec { sec: i64, nsec: i32 }
* nsec: 800_000_000_i32 }`. * nsec: 800_000_000_i32 }`.
*/ */
pub impl Timespec { pub impl Timespec {
static pure fn new(sec: i64, nsec: i32) -> Timespec { pure fn new(sec: i64, nsec: i32) -> Timespec {
fail_unless!(nsec >= 0 && nsec < NSEC_PER_SEC); fail_unless!(nsec >= 0 && nsec < NSEC_PER_SEC);
Timespec { sec: sec, nsec: nsec } Timespec { sec: sec, nsec: nsec }
} }

View file

@ -176,7 +176,7 @@ impl<K: TotalOrd, V> Map<K, V> for TreeMap<K, V> {
pub impl<K: TotalOrd, V> TreeMap<K, V> { pub impl<K: TotalOrd, V> TreeMap<K, V> {
/// Create an empty TreeMap /// Create an empty TreeMap
static pure fn new() -> TreeMap<K, V> { TreeMap{root: None, length: 0} } pure fn new() -> TreeMap<K, V> { TreeMap{root: None, length: 0} }
/// Visit all keys in reverse order /// Visit all keys in reverse order
pure fn each_key_reverse(&self, f: &fn(&K) -> bool) { pure fn each_key_reverse(&self, f: &fn(&K) -> bool) {
@ -501,7 +501,7 @@ impl<T: TotalOrd> Set<T> for TreeSet<T> {
pub impl <T: TotalOrd> TreeSet<T> { pub impl <T: TotalOrd> TreeSet<T> {
/// Create an empty TreeSet /// Create an empty TreeSet
#[inline(always)] #[inline(always)]
static pure fn new() -> TreeSet<T> { TreeSet{map: TreeMap::new()} } pure fn new() -> TreeSet<T> { TreeSet{map: TreeMap::new()} }
/// Get a lazy iterator over the values in the set. /// Get a lazy iterator over the values in the set.
/// Requires that it be frozen (immutable). /// Requires that it be frozen (immutable).
@ -542,7 +542,7 @@ struct TreeNode<K, V> {
pub impl<K: TotalOrd, V> TreeNode<K, V> { pub impl<K: TotalOrd, V> TreeNode<K, V> {
#[inline(always)] #[inline(always)]
static pure fn new(key: K, value: V) -> TreeNode<K, V> { pure fn new(key: K, value: V) -> TreeNode<K, V> {
TreeNode{key: key, value: value, left: None, right: None, level: 1} TreeNode{key: key, value: value, left: None, right: None, level: 1}
} }
} }

View file

@ -132,7 +132,7 @@ impl cmp::Ord for WorkKey {
} }
pub impl WorkKey { pub impl WorkKey {
static fn new(kind: &str, name: &str) -> WorkKey { fn new(kind: &str, name: &str) -> WorkKey {
WorkKey { kind: kind.to_owned(), name: name.to_owned() } WorkKey { kind: kind.to_owned(), name: name.to_owned() }
} }
} }
@ -151,7 +151,7 @@ impl<S:Encoder> Encodable<S> for WorkMap {
} }
impl<D:Decoder> Decodable<D> for WorkMap { impl<D:Decoder> Decodable<D> for WorkMap {
static fn decode(&self, d: &D) -> WorkMap { fn decode(d: &D) -> WorkMap {
let v : ~[(WorkKey,~str)] = Decodable::decode(d); let v : ~[(WorkKey,~str)] = Decodable::decode(d);
let mut w = LinearMap::new(); let mut w = LinearMap::new();
for v.each |&(k, v)| { for v.each |&(k, v)| {
@ -258,7 +258,7 @@ fn digest_file(path: &Path) -> ~str {
pub impl Context { pub impl Context {
static fn new(db: @Mut<Database>, fn new(db: @Mut<Database>,
lg: @Mut<Logger>, lg: @Mut<Logger>,
cfg: @json::Object) -> Context { cfg: @json::Object) -> Context {
Context{db: db, logger: lg, cfg: cfg, freshness: LinearMap::new()} Context{db: db, logger: lg, cfg: cfg, freshness: LinearMap::new()}
@ -367,7 +367,7 @@ impl TPrep for @Mut<Prep> {
pub impl<T:Owned + pub impl<T:Owned +
Encodable<json::Encoder> + Encodable<json::Encoder> +
Decodable<json::Decoder/&static>> Work<T> { // FIXME(#5121) Decodable<json::Decoder/&static>> Work<T> { // FIXME(#5121)
static fn new(p: @Mut<Prep>, e: Either<T,PortOne<(Exec,T)>>) -> Work<T> { fn new(p: @Mut<Prep>, e: Either<T,PortOne<(Exec,T)>>) -> Work<T> {
Work { prep: p, res: Some(e) } Work { prep: p, res: Some(e) }
} }
} }

View file

@ -75,7 +75,7 @@ impl<S:Encoder> Encodable<S> for ident {
} }
impl<D:Decoder> Decodable<D> for ident { impl<D:Decoder> Decodable<D> for ident {
static fn decode(d: &D) -> ident { fn decode(d: &D) -> ident {
let intr = match unsafe { let intr = match unsafe {
task::local_data::local_data_get(interner_key!()) task::local_data::local_data_get(interner_key!())
} { } {

View file

@ -30,7 +30,7 @@ use core::uint;
use std::serialize::{Encodable, Decodable, Encoder, Decoder}; use std::serialize::{Encodable, Decodable, Encoder, Decoder};
pub trait Pos { pub trait Pos {
static pure fn from_uint(n: uint) -> Self; pure fn from_uint(n: uint) -> Self;
pure fn to_uint(&self) -> uint; pure fn to_uint(&self) -> uint;
} }
@ -45,7 +45,7 @@ pub struct CharPos(uint);
// have been unsuccessful // have been unsuccessful
impl Pos for BytePos { impl Pos for BytePos {
static pure fn from_uint(n: uint) -> BytePos { BytePos(n) } pure fn from_uint(n: uint) -> BytePos { BytePos(n) }
pure fn to_uint(&self) -> uint { **self } pure fn to_uint(&self) -> uint { **self }
} }
@ -80,7 +80,7 @@ impl to_bytes::IterBytes for BytePos {
} }
impl Pos for CharPos { impl Pos for CharPos {
static pure fn from_uint(n: uint) -> CharPos { CharPos(n) } pure fn from_uint(n: uint) -> CharPos { CharPos(n) }
pure fn to_uint(&self) -> uint { **self } pure fn to_uint(&self) -> uint { **self }
} }
@ -144,7 +144,7 @@ impl<S:Encoder> Encodable<S> for span {
} }
impl<D:Decoder> Decodable<D> for span { impl<D:Decoder> Decodable<D> for span {
static fn decode(_d: &D) -> span { fn decode(_d: &D) -> span {
dummy_sp() dummy_sp()
} }
} }
@ -286,7 +286,7 @@ pub struct CodeMap {
} }
pub impl CodeMap { pub impl CodeMap {
static pub fn new() -> CodeMap { pub fn new() -> CodeMap {
CodeMap { CodeMap {
files: @mut ~[], files: @mut ~[],
} }

View file

@ -32,7 +32,7 @@ impl<S:std::serialize::Encoder> Encodable<S> for Node {
} }
impl<D:Decoder> Decodable for node_id { impl<D:Decoder> Decodable for node_id {
static fn decode(d: &D) -> Node { fn decode(d: &D) -> Node {
do d.read_struct("Node", 1) { do d.read_struct("Node", 1) {
Node { Node {
id: d.read_field(~"x", 0, || decode(d)) id: d.read_field(~"x", 0, || decode(d))
@ -66,7 +66,7 @@ would yield functions like:
D: Decoder, D: Decoder,
T: Decodable<D> T: Decodable<D>
> spanned<T>: Decodable<D> { > spanned<T>: Decodable<D> {
static fn decode(d: &D) -> spanned<T> { fn decode(d: &D) -> spanned<T> {
do d.read_rec { do d.read_rec {
{ {
node: d.read_field(~"node", 0, || decode(d)), node: d.read_field(~"node", 0, || decode(d)),

View file

@ -439,7 +439,7 @@ pub enum MapChain<K,V> {
impl <K: Eq + Hash + IterBytes ,V: Copy> MapChain<K,V>{ impl <K: Eq + Hash + IterBytes ,V: Copy> MapChain<K,V>{
// Constructor. I don't think we need a zero-arg one. // Constructor. I don't think we need a zero-arg one.
static fn new(+init: ~LinearMap<K,@V>) -> @mut MapChain<K,V> { fn new(+init: ~LinearMap<K,@V>) -> @mut MapChain<K,V> {
@mut BaseMapChain(init) @mut BaseMapChain(init)
} }

View file

@ -22,14 +22,14 @@ pub struct Interner<T> {
// when traits can extend traits, we should extend index<uint,T> to get [] // when traits can extend traits, we should extend index<uint,T> to get []
pub impl<T:Eq + IterBytes + Hash + Const + Copy> Interner<T> { pub impl<T:Eq + IterBytes + Hash + Const + Copy> Interner<T> {
static fn new() -> Interner<T> { fn new() -> Interner<T> {
Interner { Interner {
map: @mut LinearMap::new(), map: @mut LinearMap::new(),
vect: @mut ~[], vect: @mut ~[],
} }
} }
static fn prefill(init: &[T]) -> Interner<T> { fn prefill(init: &[T]) -> Interner<T> {
let rv = Interner::new(); let rv = Interner::new();
for init.each() |v| { rv.intern(*v); } for init.each() |v| { rv.intern(*v); }
rv rv

View file

@ -13,7 +13,7 @@ pub struct Foo {
} }
pub impl Foo { pub impl Foo {
static fn new() -> Foo { fn new() -> Foo {
Foo { x: 3 } Foo { x: 3 }
} }
} }

View file

@ -14,17 +14,17 @@
#[crate_type = "lib"]; #[crate_type = "lib"];
pub trait read { pub trait read {
static fn readMaybe(s: ~str) -> Option<Self>; fn readMaybe(s: ~str) -> Option<Self>;
} }
impl read for int { impl read for int {
static fn readMaybe(s: ~str) -> Option<int> { fn readMaybe(s: ~str) -> Option<int> {
int::from_str(s) int::from_str(s)
} }
} }
impl read for bool { impl read for bool {
static fn readMaybe(s: ~str) -> Option<bool> { fn readMaybe(s: ~str) -> Option<bool> {
match s { match s {
~"true" => Some(true), ~"true" => Some(true),
~"false" => Some(false), ~"false" => Some(false),

View file

@ -11,14 +11,14 @@
pub mod num { pub mod num {
pub trait Num2 { pub trait Num2 {
static pure fn from_int2(n: int) -> Self; static fn from_int2(n: int) -> Self;
} }
} }
pub mod float { pub mod float {
impl ::num::Num2 for float { impl ::num::Num2 for float {
#[inline] #[inline]
static pure fn from_int2(n: int) -> float { return n as float; } static fn from_int2(n: int) -> float { return n as float; }
} }
} }

View file

@ -1,11 +1,11 @@
pub mod num { pub mod num {
pub trait Num2 { pub trait Num2 {
static pure fn from_int2(n: int) -> Self; pure fn from_int2(n: int) -> Self;
} }
} }
pub mod float { pub mod float {
impl ::num::Num2 for float { impl ::num::Num2 for float {
static pure fn from_int2(n: int) -> float { return n as float; } pure fn from_int2(n: int) -> float { return n as float; }
} }
} }

View file

@ -40,11 +40,11 @@ struct Sudoku {
} }
pub impl Sudoku { pub impl Sudoku {
static pub fn new(g: grid) -> Sudoku { pub fn new(g: grid) -> Sudoku {
return Sudoku { grid: g } return Sudoku { grid: g }
} }
static pub fn from_vec(vec: &[[u8 * 9] * 9]) -> Sudoku { pub fn from_vec(vec: &[[u8 * 9] * 9]) -> Sudoku {
let mut g = do vec::from_fn(9u) |i| { let mut g = do vec::from_fn(9u) |i| {
do vec::from_fn(9u) |j| { vec[i][j] } do vec::from_fn(9u) |j| { vec[i][j] }
}; };
@ -62,7 +62,7 @@ pub impl Sudoku {
return true; return true;
} }
static pub fn read(reader: @io::Reader) -> Sudoku { pub fn read(reader: @io::Reader) -> Sudoku {
fail_unless!(reader.read_line() == ~"9,9"); /* assert first line is exactly "9,9" */ fail_unless!(reader.read_line() == ~"9,9"); /* assert first line is exactly "9,9" */
let mut g = vec::from_fn(10u, { |_i| ~[0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8] }); let mut g = vec::from_fn(10u, { |_i| ~[0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8] });
@ -156,7 +156,7 @@ struct Colors(u16);
const heads: u16 = (1u16 << 10) - 1; /* bits 9..0 */ const heads: u16 = (1u16 << 10) - 1; /* bits 9..0 */
impl Colors { impl Colors {
static fn new(start_color: u8) -> Colors { fn new(start_color: u8) -> Colors {
// Sets bits 9..start_color // Sets bits 9..start_color
let tails = !0u16 << start_color; let tails = !0u16 << start_color;
return Colors(heads & tails); return Colors(heads & tails);

View file

@ -14,7 +14,7 @@ struct Obj {
} }
pub impl Obj { pub impl Obj {
static pure fn boom() -> bool { pure fn boom() -> bool {
return 1+1 == 2 return 1+1 == 2
} }
pure fn chirp() { pure fn chirp() {

View file

@ -17,7 +17,7 @@ trait BikeMethods {
} }
impl BikeMethods for Bike { impl BikeMethods for Bike {
static fn woops(&const self) -> ~str { ~"foo" } fn woops(&const self) -> ~str { ~"foo" }
//~^ ERROR method `woops` is declared as static in its impl, but not in its trait //~^ ERROR method `woops` is declared as static in its impl, but not in its trait
} }

View file

@ -16,7 +16,7 @@ struct Point {
} }
impl ToStr for Point { //~ ERROR implements a method not defined in the trait impl ToStr for Point { //~ ERROR implements a method not defined in the trait
static fn new(x: float, y: float) -> Point { fn new(x: float, y: float) -> Point {
Point { x: x, y: y } Point { x: x, y: y }
} }

View file

@ -1,7 +1,7 @@
mod a { mod a {
pub struct S; pub struct S;
impl S { impl S {
static fn new() -> S { S } fn new() -> S { S }
} }
} }

View file

@ -10,7 +10,7 @@
trait foo { trait foo {
static fn bar(); fn bar();
} }
impl foo for int { impl foo for int {

View file

@ -13,7 +13,7 @@ struct Foo {
} }
pub impl Foo { pub impl Foo {
static fn new() -> Foo { fn new() -> Foo {
Foo { x: 3 } Foo { x: 3 }
} }
} }

View file

@ -115,7 +115,7 @@ pub impl<T> cat<T> {
} }
} }
static pure fn new(in_x: int, in_y: int, in_name: T) -> cat<T> { pure fn new(in_x: int, in_y: int, in_name: T) -> cat<T> {
cat{meows: in_x, how_hungry: in_y, name: in_name } cat{meows: in_x, how_hungry: in_y, name: in_name }
} }
} }

View file

@ -130,9 +130,9 @@ mod test_methods {
impl Fooable for Foo { impl Fooable for Foo {
#[cfg(bogus)] #[cfg(bogus)]
static fn what(&self) { } fn what(&self) { }
static fn what(&self) { } fn what(&self) { }
#[cfg(bogus)] #[cfg(bogus)]
fn the(&self) { } fn the(&self) { }
@ -142,9 +142,9 @@ mod test_methods {
trait Fooable { trait Fooable {
#[cfg(bogus)] #[cfg(bogus)]
static fn what(&self); fn what(&self);
static fn what(&self); fn what(&self);
#[cfg(bogus)] #[cfg(bogus)]
fn the(&self); fn the(&self);

View file

@ -13,11 +13,11 @@ trait Deserializer {
} }
trait Deserializable<D:Deserializer> { trait Deserializable<D:Deserializer> {
static fn deserialize(&self, d: &D) -> Self; fn deserialize(d: &D) -> Self;
} }
impl<D:Deserializer> Deserializable<D> for int { impl<D:Deserializer> Deserializable<D> for int {
static fn deserialize(&self, d: &D) -> int { fn deserialize(d: &D) -> int {
return d.read_int(); return d.read_int();
} }
} }

View file

@ -14,7 +14,7 @@
// A trait for objects that can be used to do an if-then-else // A trait for objects that can be used to do an if-then-else
// (No actual need for this to be static, but it is a simple test.) // (No actual need for this to be static, but it is a simple test.)
trait bool_like { trait bool_like {
static fn select<A>(b: Self, +x1: A, +x2: A) -> A; fn select<A>(b: Self, +x1: A, +x2: A) -> A;
} }
fn andand<T:bool_like + Copy>(x1: T, x2: T) -> T { fn andand<T:bool_like + Copy>(x1: T, x2: T) -> T {
@ -22,34 +22,34 @@ fn andand<T:bool_like + Copy>(x1: T, x2: T) -> T {
} }
impl bool_like for bool { impl bool_like for bool {
static fn select<A>(&&b: bool, +x1: A, +x2: A) -> A { fn select<A>(&&b: bool, +x1: A, +x2: A) -> A {
if b { x1 } else { x2 } if b { x1 } else { x2 }
} }
} }
impl bool_like for int { impl bool_like for int {
static fn select<A>(&&b: int, +x1: A, +x2: A) -> A { fn select<A>(&&b: int, +x1: A, +x2: A) -> A {
if b != 0 { x1 } else { x2 } if b != 0 { x1 } else { x2 }
} }
} }
// A trait for sequences that can be constructed imperatively. // A trait for sequences that can be constructed imperatively.
trait buildable<A> { trait buildable<A> {
static pure fn build_sized(size: uint, pure fn build_sized(size: uint,
builder: &fn(push: &pure fn(+v: A))) -> Self; builder: &fn(push: &pure fn(+v: A))) -> Self;
} }
impl<A> buildable<A> for @[A] { impl<A> buildable<A> for @[A] {
#[inline(always)] #[inline(always)]
static pure fn build_sized(size: uint, pure fn build_sized(size: uint,
builder: &fn(push: &pure fn(+v: A))) -> @[A] { builder: &fn(push: &pure fn(+v: A))) -> @[A] {
at_vec::build_sized(size, builder) at_vec::build_sized(size, builder)
} }
} }
impl<A> buildable<A> for ~[A] { impl<A> buildable<A> for ~[A] {
#[inline(always)] #[inline(always)]
static pure fn build_sized(size: uint, pure fn build_sized(size: uint,
builder: &fn(push: &pure fn(+v: A))) -> ~[A] { builder: &fn(push: &pure fn(+v: A))) -> ~[A] {
vec::build_sized(size, builder) vec::build_sized(size, builder)
} }

View file

@ -10,17 +10,17 @@
mod a { mod a {
pub trait Foo { pub trait Foo {
static pub fn foo() -> Self; pub fn foo() -> Self;
} }
impl Foo for int { impl Foo for int {
static pub fn foo() -> int { pub fn foo() -> int {
3 3
} }
} }
impl Foo for uint { impl Foo for uint {
static pub fn foo() -> uint { pub fn foo() -> uint {
5u 5u
} }
} }

View file

@ -1,9 +1,9 @@
pub trait Number: NumConv { pub trait Number: NumConv {
static pure fn from<T:Number>(n: T) -> Self; pure fn from<T:Number>(n: T) -> Self;
} }
impl Number for float { impl Number for float {
static pure fn from<T:Number>(n: T) -> float { n.to_float() } pure fn from<T:Number>(n: T) -> float { n.to_float() }
} }
pub trait NumConv { pub trait NumConv {

View file

@ -15,7 +15,7 @@
use core::num::NumCast::from; use core::num::NumCast::from;
trait Num { trait Num {
static fn from_int(i: int) -> Self; fn from_int(i: int) -> Self;
fn gt(&self, other: &Self) -> bool; fn gt(&self, other: &Self) -> bool;
} }

View file

@ -9,7 +9,7 @@
// except according to those terms. // except according to those terms.
trait MyNum { trait MyNum {
static fn from_int(int) -> Self; fn from_int(int) -> Self;
} }
pub trait NumExt: MyNum { } pub trait NumExt: MyNum { }
@ -17,7 +17,7 @@ pub trait NumExt: MyNum { }
struct S { v: int } struct S { v: int }
impl MyNum for S { impl MyNum for S {
static fn from_int(i: int) -> S { fn from_int(i: int) -> S {
S { S {
v: i v: i
} }

View file

@ -11,7 +11,7 @@
trait MyEq { } trait MyEq { }
trait MyNum { trait MyNum {
static fn from_int(int) -> Self; fn from_int(int) -> Self;
} }
pub trait NumExt: MyEq + MyNum { } pub trait NumExt: MyEq + MyNum { }
@ -21,7 +21,7 @@ struct S { v: int }
impl MyEq for S { } impl MyEq for S { }
impl MyNum for S { impl MyNum for S {
static fn from_int(i: int) -> S { fn from_int(i: int) -> S {
S { S {
v: i v: i
} }

View file

@ -12,7 +12,7 @@
mod base { mod base {
pub trait HasNew<T> { pub trait HasNew<T> {
static pure fn new() -> T; pure fn new() -> T;
} }
pub struct Foo { pub struct Foo {
@ -20,7 +20,7 @@ mod base {
} }
impl ::base::HasNew<Foo> for Foo { impl ::base::HasNew<Foo> for Foo {
static pure fn new() -> Foo { pure fn new() -> Foo {
unsafe { io::println("Foo"); } unsafe { io::println("Foo"); }
Foo { dummy: () } Foo { dummy: () }
} }
@ -31,7 +31,7 @@ mod base {
} }
impl ::base::HasNew<Bar> for Bar { impl ::base::HasNew<Bar> for Bar {
static pure fn new() -> Bar { pure fn new() -> Bar {
unsafe { io::println("Bar"); } unsafe { io::println("Bar"); }
Bar { dummy: () } Bar { dummy: () }
} }

View file

@ -12,13 +12,13 @@
// methods! // methods!
trait Equal { trait Equal {
static fn isEq(a: Self, b: Self) -> bool; fn isEq(a: Self, b: Self) -> bool;
} }
enum Color { cyan, magenta, yellow, black } enum Color { cyan, magenta, yellow, black }
impl Equal for Color { impl Equal for Color {
static fn isEq(a: Color, b: Color) -> bool { fn isEq(a: Color, b: Color) -> bool {
match (a, b) { match (a, b) {
(cyan, cyan) => { true } (cyan, cyan) => { true }
(magenta, magenta) => { true } (magenta, magenta) => { true }
@ -35,7 +35,7 @@ enum ColorTree {
} }
impl Equal for ColorTree { impl Equal for ColorTree {
static fn isEq(a: ColorTree, b: ColorTree) -> bool { fn isEq(a: ColorTree, b: ColorTree) -> bool {
match (a, b) { match (a, b) {
(leaf(x), leaf(y)) => { Equal::isEq(x, y) } (leaf(x), leaf(y)) => { Equal::isEq(x, y) }
(branch(l1, r1), branch(l2, r2)) => { (branch(l1, r1), branch(l2, r2)) => {