/// Parse logic value from `s`
impl FromStr for bool {
- static pure fn from_str(s: &str) -> Option<bool> {
+ pure fn from_str(s: &str) -> Option<bool> {
if s == "true" {
Some(true)
} else if s == "false" {
}
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 {
data: data,
linked: true,
use option::Option;
pub trait FromStr {
- static pure fn from_str(s: &str) -> Option<Self>;
+ pure fn from_str(s: &str) -> Option<Self>;
}
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)
}
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) {
* 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;
+ pure fn build_sized(size: uint,
+ builder: &fn(push: &pure fn(A))) -> Self;
}
#[inline(always)]
impl num::Zero for f32 {
#[inline(always)]
- static pure fn zero() -> f32 { 0.0 }
+ pure fn zero() -> f32 { 0.0 }
}
impl num::One for f32 {
#[inline(always)]
- static pure fn one() -> f32 { 1.0 }
+ pure fn one() -> f32 { 1.0 }
}
impl NumCast for f32 {
* Cast `n` to an `f32`
*/
#[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_u16(&self) -> u16 { *self as u16 }
impl from_str::FromStr for f32 {
#[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 {
#[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)
}
}
* Cast `n` to an `f64`
*/
#[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_u16(&self) -> u16 { *self as u16 }
impl num::Zero for f64 {
#[inline(always)]
- static pure fn zero() -> f64 { 0.0 }
+ pure fn zero() -> f64 { 0.0 }
}
impl num::One for f64 {
#[inline(always)]
- static pure fn one() -> f64 { 1.0 }
+ pure fn one() -> f64 { 1.0 }
}
#[cfg(notest)]
impl from_str::FromStr for f64 {
#[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 {
#[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)
}
}
impl from_str::FromStr for float {
#[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 {
#[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)
}
}
impl num::Zero for float {
#[inline(always)]
- static pure fn zero() -> float { 0.0 }
+ pure fn zero() -> float { 0.0 }
}
impl num::One for float {
#[inline(always)]
- static pure fn one() -> float { 1.0 }
+ pure fn one() -> float { 1.0 }
}
impl NumCast for float {
* Cast `n` to a `float`
*/
#[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_u16(&self) -> u16 { *self as u16 }
impl num::Zero for T {
#[inline(always)]
- static pure fn zero() -> T { 0 }
+ pure fn zero() -> T { 0 }
}
impl num::One for T {
#[inline(always)]
- static pure fn one() -> T { 1 }
+ pure fn one() -> T { 1 }
}
#[cfg(notest)]
impl FromStr for T {
#[inline(always)]
- static pure fn from_str(s: &str) -> Option<T> {
+ pure 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> {
+ pure fn from_str_radix(s: &str, radix: uint) -> Option<T> {
from_str_radix(s, radix)
}
}
* Cast `n` to a `i16`
*/
#[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_u16(&self) -> u16 { *self as u16 }
* Cast `n` to a `i32`
*/
#[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_u16(&self) -> u16 { *self as u16 }
* Cast `n` to a `i64`
*/
#[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_u16(&self) -> u16 { *self as u16 }
* Cast `n` to a `i8`
*/
#[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_u16(&self) -> u16 { *self as u16 }
* Cast `n` to a `int`
*/
#[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_u16(&self) -> u16 { *self as u16 }
pub trait IntConvertible {
pure fn to_int(&self) -> int;
- static pure fn from_int(n: int) -> Self;
+ pure fn from_int(n: int) -> Self;
}
pub trait Zero {
- static pure fn zero() -> Self;
+ pure fn zero() -> Self;
}
pub trait One {
- static pure fn one() -> Self;
+ pure fn one() -> Self;
}
pub pure fn abs<T:Ord + Zero + Neg<T>>(v: T) -> T {
* An interface for generic numeric type casts
*/
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_u16(&self) -> u16;
}
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:
}
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>;
+ pure fn NaN() -> Option<Self>;
+ pure fn inf() -> Option<Self>;
+ pure fn neg_inf() -> Option<Self>;
+ pure fn neg_zero() -> Option<Self>;
pure fn round_to_zero(&self) -> Self;
pure 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) }
+ pure fn NaN() -> Option<$t> { Some( 0.0 / 0.0) }
#[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)]
- 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)]
- static pure fn neg_zero() -> Option<$t> { Some(-0.0 ) }
+ pure fn neg_zero() -> Option<$t> { Some(-0.0 ) }
#[inline(always)]
pure fn round_to_zero(&self) -> $t {
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)] pure fn NaN() -> Option<$t> { None }
+ #[inline(always)] pure fn inf() -> Option<$t> { None }
+ #[inline(always)] pure fn neg_inf() -> Option<$t> { None }
+ #[inline(always)] pure fn neg_zero() -> Option<$t> { None }
#[inline(always)] pure fn round_to_zero(&self) -> $t { *self }
#[inline(always)] pure fn fractional_part(&self) -> $t { 0 }
impl num::Zero for T {
#[inline(always)]
- static pure fn zero() -> T { 0 }
+ pure fn zero() -> T { 0 }
}
impl num::One for T {
#[inline(always)]
- static pure fn one() -> T { 1 }
+ pure fn one() -> T { 1 }
}
#[cfg(notest)]
impl FromStr for T {
#[inline(always)]
- static pure fn from_str(s: &str) -> Option<T> {
+ pure 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> {
+ pure fn from_str_radix(s: &str, radix: uint) -> Option<T> {
from_str_radix(s, radix)
}
}
* Cast `n` to a `u16`
*/
#[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_u16(&self) -> u16 { *self }
* Cast `n` to a `u32`
*/
#[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_u16(&self) -> u16 { *self as u16 }
* Cast `n` to a `u64`
*/
#[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_u16(&self) -> u16 { *self as u16 }
* Cast `n` to a `u8`
*/
#[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_u16(&self) -> u16 { *self as u16 }
* Cast `n` to a `uint`
*/
#[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_u16(&self) -> u16 { *self as u16 }
}
pub trait GenericPath {
- static pure fn from_str(&str) -> Self;
+ pure fn from_str(&str) -> Self;
pure fn dirname(&self) -> ~str;
pure fn filename(&self) -> Option<~str>;
// PosixPath and WindowsPath, most of their methods are common.
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 is_absolute = (s.len() != 0 && s[0] == '/' as u8);
return PosixPath { is_absolute: is_absolute,
impl GenericPath for WindowsPath {
- static pure fn from_str(s: &str) -> WindowsPath {
+ pure fn from_str(s: &str) -> WindowsPath {
let host;
let device;
let rest;
/// 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 {
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)() }
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
};
// 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) {
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(),
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());
}
}
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
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.
}
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 {
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)
}
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) }
}
/// 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;
}
}
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)
}
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 {
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());
}
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 {
}
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)
}
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;
}
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 {
impl ConnectRequest {
- static fn new() -> ConnectRequest {
+ fn new() -> ConnectRequest {
let connect_handle = unsafe {
malloc(size_of::<uvll::uv_connect_t>() as size_t)
};
}
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)
}
impl WriteRequest {
- static fn new() -> WriteRequest {
+ fn new() -> WriteRequest {
let write_handle = unsafe {
malloc(size_of::<uvll::uv_write_t>() as size_t)
};
}
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 {
}
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())
}
}
pub struct UvStream(StreamWatcher);
impl UvStream {
- static fn new(watcher: StreamWatcher) -> UvStream {
+ fn new(watcher: StreamWatcher) -> UvStream {
UvStream(watcher)
}
}
pub impl<T> WorkQueue<T> {
- static fn new() -> WorkQueue<T> {
+ fn new() -> WorkQueue<T> {
WorkQueue {
queue: ~[]
}
pub impl<T> TrieMap<T> {
/// Create an empty TrieMap
#[inline(always)]
- static pure fn new() -> TrieMap<T> {
+ pure fn new() -> TrieMap<T> {
TrieMap{root: TrieNode::new(), length: 0}
}
impl TrieSet {
/// Create an empty TrieSet
#[inline(always)]
- static pure fn new() -> TrieSet {
+ pure fn new() -> TrieSet {
TrieSet{map: TrieMap::new()}
}
impl<T> TrieNode<T> {
#[inline(always)]
- static pure fn new() -> TrieNode<T> {
+ pure fn new() -> TrieNode<T> {
// FIXME: #5244: [Nothing, ..SIZE] should be possible without Copy
TrieNode{count: 0,
children: [Nothing, Nothing, Nothing, Nothing,
}
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}
}
}
}
pub impl LanguageItems {
- static pub fn new(&self) -> LanguageItems {
+ pub fn new() -> LanguageItems {
LanguageItems {
items: [ None, ..35 ]
}
}
}
- static pub fn item_name(&self, index: uint) -> &'static str {
+ pub fn item_name(index: uint) -> &'static str {
match index {
0 => "const",
1 => "copy",
}
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,
// 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:
!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
}
!self.intersects(TypeContents::nondurable(cx))
}
- static fn nondurable(_cx: ctxt) -> TypeContents {
+ fn nondurable(_cx: ctxt) -> TypeContents {
TC_BORROWED_POINTER
}
!self.intersects(TypeContents::nonowned(cx))
}
- static fn nonowned(_cx: ctxt) -> TypeContents {
+ fn nonowned(_cx: ctxt) -> TypeContents {
TC_MANAGED + TC_BORROWED_POINTER
}
!self.intersects(TypeContents::nonconst(cx))
}
- static fn nonconst(_cx: ctxt) -> TypeContents {
+ fn nonconst(_cx: ctxt) -> TypeContents {
TC_MUTABLE
}
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}
}
!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
}
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
}
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)
}
}
}
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 {
// 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,
// ______________________________________________________________________
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);
}
}
}
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)
}
}
}
impl Zero for BigUint {
- static pure fn zero() -> BigUint { BigUint::new(~[]) }
+ pure fn zero() -> BigUint { BigUint::new(~[]) }
}
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 {
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) }
}
}
pub impl BigUint {
/// Creates and initializes an BigUint.
- static pub pure fn new(v: ~[BigDigit]) -> BigUint {
+ pub pure fn new(v: ~[BigDigit]) -> BigUint {
// omit trailing zeros
let new_len = v.rposition(|n| *n != 0).map_default(0, |p| *p + 1);
}
/// 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) {
(0, 0) => Zero::zero(),
(0, n0) => BigUint::new(~[n0]),
}
/// 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));
}
/// 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> {
BigUint::parse_bytes(str::to_bytes(s), radix)
}
/// 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> {
let (base, unit_len) = get_radix_base(radix);
let base_num: BigUint = BigUint::from_uint(base);
}
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)
}
}
}
impl Zero for BigInt {
- static pub pure fn zero() -> BigInt {
+ pub pure fn zero() -> BigInt {
BigInt::from_biguint(Zero, Zero::zero())
}
}
impl One for BigInt {
- static pub pure fn one() -> BigInt {
+ pub pure fn one() -> BigInt {
BigInt::from_biguint(Plus, One::one())
}
}
}
}
- static pure fn from_int(n: int) -> BigInt {
+ pure fn from_int(n: int) -> BigInt {
if n > 0 {
return BigInt::from_biguint(Plus, BigUint::from_uint(n as uint));
}
pub impl 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))
}
/// 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() {
return BigInt { sign: Zero, data: Zero::zero() };
}
}
/// 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(); }
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 pure 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 pure 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 pure fn parse_bytes(buf: &[u8], radix: uint)
-> Option<BigInt> {
if buf.is_empty() { return None; }
let mut sign = Plus;
}
pub impl SmallBitv {
- static fn new(bits: uint) -> SmallBitv {
+ fn new(bits: uint) -> SmallBitv {
SmallBitv {bits: bits}
}
}
pub impl BigBitv {
- static fn new(storage: ~[uint]) -> BigBitv {
+ fn new(storage: ~[uint]) -> BigBitv {
BigBitv {storage: storage}
}
}
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}))
}
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;
pub impl<T> Deque<T> {
/// Create an empty Deque
- static pure fn new() -> Deque<T> {
+ pure fn new() -> Deque<T> {
Deque{nelts: 0, lo: 0, hi: 0,
elts: vec::from_fn(initial_capacity, |_| None)}
}
}
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
}
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
}
pub impl<T:Copy + Owned> PodUnflattener<T> {
- static fn new() -> PodUnflattener<T> {
+ fn new() -> PodUnflattener<T> {
PodUnflattener {
bogus: ()
}
}
pub impl<T:Copy + Owned> PodFlattener<T> {
- static fn new() -> PodFlattener<T> {
+ fn new() -> PodFlattener<T> {
PodFlattener {
bogus: ()
}
}
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
}
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
}
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)
}
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)
}
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)
}
}
}
pub impl<R:Reader> ReaderBytePort<R> {
- static fn new(r: R) -> ReaderBytePort<R> {
+ fn new(r: R) -> ReaderBytePort<R> {
ReaderBytePort {
reader: r
}
}
pub impl<W:Writer> WriterByteChan<W> {
- static fn new(w: W) -> WriterByteChan<W> {
+ fn new(w: W) -> WriterByteChan<W> {
WriterByteChan {
writer: w
}
}
pub impl PipeBytePort {
- static fn new(p: Port<~[u8]>) -> PipeBytePort {
+ fn new(p: Port<~[u8]>) -> PipeBytePort {
PipeBytePort {
port: p,
buf: ~[]
}
pub impl PipeByteChan {
- static fn new(c: Chan<~[u8]>) -> PipeByteChan {
+ fn new(c: Chan<~[u8]>) -> PipeByteChan {
PipeByteChan {
chan: c
}
}
pub impl BufReader {
- static pub fn new(v: ~[u8]) -> BufReader {
+ pub fn new(v: ~[u8]) -> BufReader {
BufReader {
buf: v,
pos: 0
pub type Query = ~[(~str, ~str)];
pub impl Url {
- static pure fn new(
+ pure fn new(
scheme: ~str,
user: Option<UserInfo>,
host: ~str,
}
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 }
}
}
}
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) {
Ok(url) => Some(url),
Err(_) => None
}
/// 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)
- 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 n = q.len() / 2;
while n > 0 {
}
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<D:Decoder> Decodable<D> for uint {
- static fn decode(&self, d: &D) -> uint {
+ fn decode(d: &D) -> uint {
d.read_uint()
}
}
}
impl<D:Decoder> Decodable<D> for u8 {
- static fn decode(&self, d: &D) -> u8 {
+ fn decode(d: &D) -> u8 {
d.read_u8()
}
}
}
impl<D:Decoder> Decodable<D> for u16 {
- static fn decode(&self, d: &D) -> u16 {
+ fn decode(d: &D) -> u16 {
d.read_u16()
}
}
}
impl<D:Decoder> Decodable<D> for u32 {
- static fn decode(&self, d: &D) -> u32 {
+ fn decode(d: &D) -> u32 {
d.read_u32()
}
}
}
impl<D:Decoder> Decodable<D> for u64 {
- static fn decode(&self, d: &D) -> u64 {
+ fn decode(d: &D) -> u64 {
d.read_u64()
}
}
}
impl<D:Decoder> Decodable<D> for int {
- static fn decode(&self, d: &D) -> int {
+ fn decode(d: &D) -> int {
d.read_int()
}
}
}
impl<D:Decoder> Decodable<D> for i8 {
- static fn decode(&self, d: &D) -> i8 {
+ fn decode(d: &D) -> i8 {
d.read_i8()
}
}
}
impl<D:Decoder> Decodable<D> for i16 {
- static fn decode(&self, d: &D) -> i16 {
+ fn decode(d: &D) -> i16 {
d.read_i16()
}
}
}
impl<D:Decoder> Decodable<D> for i32 {
- static fn decode(&self, d: &D) -> i32 {
+ fn decode(d: &D) -> i32 {
d.read_i32()
}
}
}
impl<D:Decoder> Decodable<D> for i64 {
- static fn decode(&self, d: &D) -> i64 {
+ fn decode(d: &D) -> i64 {
d.read_i64()
}
}
}
impl<D:Decoder> Decodable<D> for ~str {
- static fn decode(&self, d: &D) -> ~str {
+ fn decode(d: &D) -> ~str {
d.read_owned_str()
}
}
}
impl<D:Decoder> Decodable<D> for @str {
- static fn decode(&self, d: &D) -> @str {
+ fn decode(d: &D) -> @str {
d.read_managed_str()
}
}
}
impl<D:Decoder> Decodable<D> for float {
- static fn decode(&self, d: &D) -> float {
+ fn decode(d: &D) -> float {
d.read_float()
}
}
}
impl<D:Decoder> Decodable<D> for f32 {
- static fn decode(&self, d: &D) -> f32 {
+ fn decode(d: &D) -> f32 {
d.read_f32() }
}
}
impl<D:Decoder> Decodable<D> for f64 {
- static fn decode(&self, d: &D) -> f64 {
+ fn decode(d: &D) -> f64 {
d.read_f64()
}
}
}
impl<D:Decoder> Decodable<D> for bool {
- static fn decode(&self, d: &D) -> bool {
+ fn decode(d: &D) -> bool {
d.read_bool()
}
}
}
impl<D:Decoder> Decodable<D> for () {
- static fn decode(&self, d: &D) -> () {
+ fn decode(d: &D) -> () {
d.read_nil()
}
}
}
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))
}
}
}
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))
}
}
}
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 vec::from_fn(len) |i| {
d.read_vec_elt(i, || Decodable::decode(d))
}
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 at_vec::from_fn(len) |i| {
d.read_vec_elt(i, || Decodable::decode(d))
}
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_variant |i| {
match i {
}
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) {
(
d.read_tup_elt(0, || Decodable::decode(d)),
T1: Decodable<D>,
T2: Decodable<D>
> 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) {
(
d.read_tup_elt(0, || Decodable::decode(d)),
T2: Decodable<D>,
T3: Decodable<D>
> 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) {
(
d.read_tup_elt(0, || Decodable::decode(d)),
T3: Decodable<D>,
T4: Decodable<D>
> Decodable<D> for (T0, T1, T2, T3, T4) {
- static fn decode(&self, d: &D)
+ fn decode(d: &D)
-> (T0, T1, T2, T3, T4) {
do d.read_tup(5) {
(
pub impl<V> SmallIntMap<V> {
/// 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 {
self.find(key).expect("key not present")
/// new scheduler with the given mode. The provided `init_fn_factory`
/// returns a function which, given the index of the task, should return
/// local data to be kept around in that task.
- static fn new(n_tasks: uint,
- opt_sched_mode: Option<SchedMode>,
- init_fn_factory: ~fn() -> ~fn(uint) -> T) -> TaskPool<T> {
+ fn new(n_tasks: uint,
+ opt_sched_mode: Option<SchedMode>,
+ init_fn_factory: ~fn() -> ~fn(uint) -> T)
+ -> TaskPool<T> {
fail_unless!(n_tasks >= 1);
let channels = do vec::from_fn(n_tasks) |i| {
* nsec: 800_000_000_i32 }`.
*/
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);
Timespec { sec: sec, nsec: nsec }
}
pub impl<K: TotalOrd, V> TreeMap<K, V> {
/// 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
pure fn each_key_reverse(&self, f: &fn(&K) -> bool) {
pub impl <T: TotalOrd> TreeSet<T> {
/// Create an empty TreeSet
#[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.
/// Requires that it be frozen (immutable).
pub impl<K: TotalOrd, V> TreeNode<K, V> {
#[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}
}
}
}
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() }
}
}
}
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 mut w = LinearMap::new();
for v.each |&(k, v)| {
pub impl Context {
- static fn new(db: @Mut<Database>,
+ fn new(db: @Mut<Database>,
lg: @Mut<Logger>,
cfg: @json::Object) -> Context {
Context{db: db, logger: lg, cfg: cfg, freshness: LinearMap::new()}
pub impl<T:Owned +
Encodable<json::Encoder> +
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) }
}
}
}
impl<D:Decoder> Decodable<D> for ident {
- static fn decode(d: &D) -> ident {
+ fn decode(d: &D) -> ident {
let intr = match unsafe {
task::local_data::local_data_get(interner_key!())
} {
use std::serialize::{Encodable, Decodable, Encoder, Decoder};
pub trait Pos {
- static pure fn from_uint(n: uint) -> Self;
+ pure fn from_uint(n: uint) -> Self;
pure fn to_uint(&self) -> uint;
}
// have been unsuccessful
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 }
}
}
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 }
}
}
impl<D:Decoder> Decodable<D> for span {
- static fn decode(_d: &D) -> span {
+ fn decode(_d: &D) -> span {
dummy_sp()
}
}
}
pub impl CodeMap {
- static pub fn new() -> CodeMap {
+ pub fn new() -> CodeMap {
CodeMap {
files: @mut ~[],
}
}
impl<D:Decoder> Decodable for node_id {
- static fn decode(d: &D) -> Node {
+ fn decode(d: &D) -> Node {
do d.read_struct("Node", 1) {
Node {
id: d.read_field(~"x", 0, || decode(d))
D: Decoder,
T: Decodable<D>
> spanned<T>: Decodable<D> {
- static fn decode(d: &D) -> spanned<T> {
+ fn decode(d: &D) -> spanned<T> {
do d.read_rec {
{
node: d.read_field(~"node", 0, || decode(d)),
impl <K: Eq + Hash + IterBytes ,V: Copy> MapChain<K,V>{
// 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)
}
// when traits can extend traits, we should extend index<uint,T> to get []
pub impl<T:Eq + IterBytes + Hash + Const + Copy> Interner<T> {
- static fn new() -> Interner<T> {
+ fn new() -> Interner<T> {
Interner {
map: @mut LinearMap::new(),
vect: @mut ~[],
}
}
- static fn prefill(init: &[T]) -> Interner<T> {
+ fn prefill(init: &[T]) -> Interner<T> {
let rv = Interner::new();
for init.each() |v| { rv.intern(*v); }
rv
}
pub impl Foo {
- static fn new() -> Foo {
+ fn new() -> Foo {
Foo { x: 3 }
}
}
#[crate_type = "lib"];
pub trait read {
- static fn readMaybe(s: ~str) -> Option<Self>;
+ fn readMaybe(s: ~str) -> Option<Self>;
}
impl read for int {
- static fn readMaybe(s: ~str) -> Option<int> {
+ fn readMaybe(s: ~str) -> Option<int> {
int::from_str(s)
}
}
impl read for bool {
- static fn readMaybe(s: ~str) -> Option<bool> {
+ fn readMaybe(s: ~str) -> Option<bool> {
match s {
~"true" => Some(true),
~"false" => Some(false),
pub mod num {
pub trait Num2 {
- static pure fn from_int2(n: int) -> Self;
+ static fn from_int2(n: int) -> Self;
}
}
pub mod float {
impl ::num::Num2 for float {
#[inline]
- static pure fn from_int2(n: int) -> float { return n as float; }
+ static fn from_int2(n: int) -> float { return n as float; }
}
}
pub mod num {
pub trait Num2 {
- static pure fn from_int2(n: int) -> Self;
+ pure fn from_int2(n: int) -> Self;
}
}
pub mod 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; }
}
}
}
pub impl Sudoku {
- static pub fn new(g: grid) -> Sudoku {
+ pub fn new(g: grid) -> Sudoku {
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| {
do vec::from_fn(9u) |j| { vec[i][j] }
};
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" */
let mut g = vec::from_fn(10u, { |_i| ~[0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8] });
const heads: u16 = (1u16 << 10) - 1; /* bits 9..0 */
impl Colors {
- static fn new(start_color: u8) -> Colors {
+ fn new(start_color: u8) -> Colors {
// Sets bits 9..start_color
let tails = !0u16 << start_color;
return Colors(heads & tails);
}
pub impl Obj {
- static pure fn boom() -> bool {
+ pure fn boom() -> bool {
return 1+1 == 2
}
pure fn chirp() {
}
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
}
}
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 }
}
mod a {
pub struct S;
impl S {
- static fn new() -> S { S }
+ fn new() -> S { S }
}
}
trait foo {
- static fn bar();
+ fn bar();
}
impl foo for int {
}
pub impl Foo {
- static fn new() -> Foo {
+ fn new() -> Foo {
Foo { x: 3 }
}
}
}
}
- 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 }
}
}
impl Fooable for Foo {
#[cfg(bogus)]
- static fn what(&self) { }
+ fn what(&self) { }
- static fn what(&self) { }
+ fn what(&self) { }
#[cfg(bogus)]
fn the(&self) { }
trait Fooable {
#[cfg(bogus)]
- static fn what(&self);
+ fn what(&self);
- static fn what(&self);
+ fn what(&self);
#[cfg(bogus)]
fn the(&self);
}
trait Deserializable<D:Deserializer> {
- static fn deserialize(&self, d: &D) -> Self;
+ fn deserialize(d: &D) -> Self;
}
impl<D:Deserializer> Deserializable<D> for int {
- static fn deserialize(&self, d: &D) -> int {
+ fn deserialize(d: &D) -> int {
return d.read_int();
}
}
// 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.)
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 {
}
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 }
}
}
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 }
}
}
// A trait for sequences that can be constructed imperatively.
trait buildable<A> {
- static pure fn build_sized(size: uint,
- builder: &fn(push: &pure fn(+v: A))) -> Self;
+ pure fn build_sized(size: uint,
+ builder: &fn(push: &pure fn(+v: A))) -> Self;
}
impl<A> buildable<A> for @[A] {
#[inline(always)]
- static pure fn build_sized(size: uint,
- builder: &fn(push: &pure fn(+v: A))) -> @[A] {
+ pure fn build_sized(size: uint,
+ builder: &fn(push: &pure fn(+v: A))) -> @[A] {
at_vec::build_sized(size, builder)
}
}
impl<A> buildable<A> for ~[A] {
#[inline(always)]
- static pure fn build_sized(size: uint,
- builder: &fn(push: &pure fn(+v: A))) -> ~[A] {
+ pure fn build_sized(size: uint,
+ builder: &fn(push: &pure fn(+v: A))) -> ~[A] {
vec::build_sized(size, builder)
}
}
mod a {
pub trait Foo {
- static pub fn foo() -> Self;
+ pub fn foo() -> Self;
}
impl Foo for int {
- static pub fn foo() -> int {
+ pub fn foo() -> int {
3
}
}
impl Foo for uint {
- static pub fn foo() -> uint {
+ pub fn foo() -> uint {
5u
}
}
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 {
- 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 {
use core::num::NumCast::from;
trait Num {
- static fn from_int(i: int) -> Self;
+ fn from_int(i: int) -> Self;
fn gt(&self, other: &Self) -> bool;
}
// except according to those terms.
trait MyNum {
- static fn from_int(int) -> Self;
+ fn from_int(int) -> Self;
}
pub trait NumExt: MyNum { }
struct S { v: int }
impl MyNum for S {
- static fn from_int(i: int) -> S {
+ fn from_int(i: int) -> S {
S {
v: i
}
trait MyEq { }
trait MyNum {
- static fn from_int(int) -> Self;
+ fn from_int(int) -> Self;
}
pub trait NumExt: MyEq + MyNum { }
impl MyEq for S { }
impl MyNum for S {
- static fn from_int(i: int) -> S {
+ fn from_int(i: int) -> S {
S {
v: i
}
mod base {
pub trait HasNew<T> {
- static pure fn new() -> T;
+ pure fn new() -> T;
}
pub struct Foo {
}
impl ::base::HasNew<Foo> for Foo {
- static pure fn new() -> Foo {
+ pure fn new() -> Foo {
unsafe { io::println("Foo"); }
Foo { dummy: () }
}
}
impl ::base::HasNew<Bar> for Bar {
- static pure fn new() -> Bar {
+ pure fn new() -> Bar {
unsafe { io::println("Bar"); }
Bar { dummy: () }
}
// methods!
trait Equal {
- static fn isEq(a: Self, b: Self) -> bool;
+ fn isEq(a: Self, b: Self) -> bool;
}
enum Color { cyan, magenta, yellow, black }
impl Equal for Color {
- static fn isEq(a: Color, b: Color) -> bool {
+ fn isEq(a: Color, b: Color) -> bool {
match (a, b) {
(cyan, cyan) => { true }
(magenta, magenta) => { true }
}
impl Equal for ColorTree {
- static fn isEq(a: ColorTree, b: ColorTree) -> bool {
+ fn isEq(a: ColorTree, b: ColorTree) -> bool {
match (a, b) {
(leaf(x), leaf(y)) => { Equal::isEq(x, y) }
(branch(l1, r1), branch(l2, r2)) => {