core: Make core.rc more readable. Cleanup
This commit is contained in:
parent
3ed9fbd63c
commit
b52a4b412e
@ -65,6 +65,7 @@ pub fn all_values(blk: fn(v: bool)) {
|
||||
/// converts truth value to an 8 bit byte
|
||||
pub pure fn to_bit(v: bool) -> u8 { if v { 1u8 } else { 0u8 } }
|
||||
|
||||
#[cfg(notest)]
|
||||
impl bool : cmp::Eq {
|
||||
pure fn eq(&self, other: &bool) -> bool { (*self) == (*other) }
|
||||
pure fn ne(&self, other: &bool) -> bool { (*self) != (*other) }
|
||||
|
@ -27,11 +27,13 @@ pub pure fn ptr_eq<T>(a: @T, b: @T) -> bool {
|
||||
unsafe { ptr::addr_of(&(*a)) == ptr::addr_of(&(*b)) }
|
||||
}
|
||||
|
||||
#[cfg(notest)]
|
||||
impl<T:Eq> @const T : Eq {
|
||||
pure fn eq(&self, other: &@const T) -> bool { *(*self) == *(*other) }
|
||||
pure fn ne(&self, other: &@const T) -> bool { *(*self) != *(*other) }
|
||||
}
|
||||
|
||||
#[cfg(notest)]
|
||||
impl<T:Ord> @const T : Ord {
|
||||
pure fn lt(&self, other: &@const T) -> bool { *(*self) < *(*other) }
|
||||
pure fn le(&self, other: &@const T) -> bool { *(*self) <= *(*other) }
|
||||
|
@ -180,6 +180,7 @@ pub pure fn cmp(a: char, b: char) -> int {
|
||||
else { 0 }
|
||||
}
|
||||
|
||||
#[cfg(notest)]
|
||||
impl char : Eq {
|
||||
pure fn eq(&self, other: &char) -> bool { (*self) == (*other) }
|
||||
pure fn ne(&self, other: &char) -> bool { (*self) != (*other) }
|
||||
|
@ -14,70 +14,35 @@ and `Eq` to overload the `==` and `!=` operators.
|
||||
#[forbid(deprecated_mode)];
|
||||
#[forbid(deprecated_pattern)];
|
||||
|
||||
pub use nounittest::*;
|
||||
pub use unittest::*;
|
||||
|
||||
/// Interfaces used for comparison.
|
||||
|
||||
// Awful hack to work around duplicate lang items in core test.
|
||||
#[cfg(notest)]
|
||||
mod nounittest {
|
||||
/**
|
||||
* Trait for values that can be compared for a sort-order.
|
||||
*
|
||||
* Eventually this may be simplified to only require
|
||||
* an `le` method, with the others generated from
|
||||
* default implementations.
|
||||
*/
|
||||
#[lang="ord"]
|
||||
pub trait Ord {
|
||||
pure fn lt(&self, other: &self) -> bool;
|
||||
pure fn le(&self, other: &self) -> bool;
|
||||
pure fn ge(&self, other: &self) -> bool;
|
||||
pure fn gt(&self, other: &self) -> bool;
|
||||
}
|
||||
|
||||
#[lang="eq"]
|
||||
/**
|
||||
* Trait for values that can be compared for equality
|
||||
* and inequality.
|
||||
*
|
||||
* Eventually this may be simplified to only require
|
||||
* an `eq` method, with the other generated from
|
||||
* a default implementation.
|
||||
*/
|
||||
#[lang="eq"]
|
||||
pub trait Eq {
|
||||
pure fn eq(&self, other: &self) -> bool;
|
||||
pure fn ne(&self, other: &self) -> bool;
|
||||
}
|
||||
/**
|
||||
* Trait for values that can be compared for equality
|
||||
* and inequality.
|
||||
*
|
||||
* Eventually this may be simplified to only require
|
||||
* an `eq` method, with the other generated from
|
||||
* a default implementation.
|
||||
*/
|
||||
#[lang="eq"]
|
||||
pub trait Eq {
|
||||
pure fn eq(&self, other: &self) -> bool;
|
||||
pure fn ne(&self, other: &self) -> bool;
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod nounittest {
|
||||
#[legacy_exports];}
|
||||
|
||||
#[cfg(test)]
|
||||
mod unittest {
|
||||
#[legacy_exports];
|
||||
|
||||
pub trait Ord {
|
||||
pure fn lt(&self, other: &self) -> bool;
|
||||
pure fn le(&self, other: &self) -> bool;
|
||||
pure fn ge(&self, other: &self) -> bool;
|
||||
pure fn gt(&self, other: &self) -> bool;
|
||||
}
|
||||
|
||||
pub trait Eq {
|
||||
pure fn eq(&self, other: &self) -> bool;
|
||||
pure fn ne(&self, other: &self) -> bool;
|
||||
}
|
||||
/**
|
||||
* Trait for values that can be compared for a sort-order.
|
||||
*
|
||||
* Eventually this may be simplified to only require
|
||||
* an `le` method, with the others generated from
|
||||
* default implementations.
|
||||
*/
|
||||
#[lang="ord"]
|
||||
pub trait Ord {
|
||||
pure fn lt(&self, other: &self) -> bool;
|
||||
pure fn le(&self, other: &self) -> bool;
|
||||
pure fn ge(&self, other: &self) -> bool;
|
||||
pure fn gt(&self, other: &self) -> bool;
|
||||
}
|
||||
|
||||
#[cfg(notest)]
|
||||
mod unittest {
|
||||
#[legacy_exports];}
|
||||
|
||||
pub pure fn lt<T: Ord>(v1: &T, v2: &T) -> bool {
|
||||
(*v1).lt(v2)
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*!
|
||||
|
||||
The Rust core library.
|
||||
The Rust core library
|
||||
|
||||
The Rust core library provides runtime features required by the language,
|
||||
including the task scheduler and memory allocators, as well as library
|
||||
@ -24,6 +24,7 @@ Implicitly, all crates behave as if they included the following prologue:
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#[link(name = "core",
|
||||
vers = "0.5",
|
||||
uuid = "c70c24a7-5551-4f73-8e37-380b11d80be8",
|
||||
@ -33,125 +34,110 @@ Implicitly, all crates behave as if they included the following prologue:
|
||||
#[license = "MIT"];
|
||||
#[crate_type = "lib"];
|
||||
|
||||
|
||||
// Don't link to core. We are core.
|
||||
#[no_core];
|
||||
|
||||
#[warn(deprecated_mode)];
|
||||
#[warn(deprecated_pattern)];
|
||||
|
||||
#[warn(vecs_implicitly_copyable)];
|
||||
#[deny(non_camel_case_types)];
|
||||
|
||||
// Built-in-type support modules
|
||||
|
||||
/// Operations and constants for `int`
|
||||
#[path = "int-template.rs"]
|
||||
#[merge = "int-template/int.rs"]
|
||||
/* Primitive types */
|
||||
|
||||
#[path = "int-template.rs"] #[merge = "int-template/int.rs"]
|
||||
pub mod int;
|
||||
|
||||
/// Operations and constants for `i8`
|
||||
#[path = "int-template.rs"]
|
||||
#[merge = "int-template/i8.rs"]
|
||||
#[path = "int-template.rs"] #[merge = "int-template/i8.rs"]
|
||||
pub mod i8;
|
||||
|
||||
/// Operations and constants for `i16`
|
||||
#[path = "int-template.rs"]
|
||||
#[merge = "int-template/i16.rs"]
|
||||
#[path = "int-template.rs"] #[merge = "int-template/i16.rs"]
|
||||
pub mod i16;
|
||||
|
||||
/// Operations and constants for `i32`
|
||||
#[path = "int-template.rs"]
|
||||
#[merge = "int-template/i32.rs"]
|
||||
#[path = "int-template.rs"] #[merge = "int-template/i32.rs"]
|
||||
pub mod i32;
|
||||
|
||||
/// Operations and constants for `i64`
|
||||
#[path = "int-template.rs"]
|
||||
#[merge = "int-template/i64.rs"]
|
||||
#[path = "int-template.rs"] #[merge = "int-template/i64.rs"]
|
||||
pub mod i64;
|
||||
|
||||
/// Operations and constants for `uint`
|
||||
#[path = "uint-template.rs"]
|
||||
#[merge = "uint-template/uint.rs"]
|
||||
#[path = "uint-template.rs"] #[merge = "uint-template/uint.rs"]
|
||||
pub mod uint;
|
||||
|
||||
/// Operations and constants for `u8`
|
||||
#[path = "uint-template.rs"]
|
||||
#[merge = "uint-template/u8.rs"]
|
||||
#[path = "uint-template.rs"] #[merge = "uint-template/u8.rs"]
|
||||
pub mod u8;
|
||||
|
||||
/// Operations and constants for `u16`
|
||||
#[path = "uint-template.rs"]
|
||||
#[merge = "uint-template/u16.rs"]
|
||||
#[path = "uint-template.rs"] #[merge = "uint-template/u16.rs"]
|
||||
pub mod u16;
|
||||
|
||||
/// Operations and constants for `u32`
|
||||
#[path = "uint-template.rs"]
|
||||
#[merge = "uint-template/u32.rs"]
|
||||
#[path = "uint-template.rs"] #[merge = "uint-template/u32.rs"]
|
||||
pub mod u32;
|
||||
|
||||
/// Operations and constants for `u64`
|
||||
#[path = "uint-template.rs"]
|
||||
#[merge = "uint-template/u64.rs"]
|
||||
#[path = "uint-template.rs"] #[merge = "uint-template/u64.rs"]
|
||||
pub mod u64;
|
||||
|
||||
|
||||
pub mod box;
|
||||
pub mod char;
|
||||
pub mod float;
|
||||
pub mod f32;
|
||||
pub mod f64;
|
||||
pub mod str;
|
||||
pub mod ptr;
|
||||
|
||||
pub mod unit;
|
||||
pub mod bool;
|
||||
pub mod char;
|
||||
pub mod tuple;
|
||||
|
||||
pub mod vec;
|
||||
pub mod at_vec;
|
||||
pub mod bool;
|
||||
pub mod tuple;
|
||||
pub mod unit;
|
||||
pub mod str;
|
||||
|
||||
pub mod ptr;
|
||||
pub mod box; // FIXME #4079 Rename to 'managed' to match 'owned'
|
||||
pub mod owned;
|
||||
|
||||
// Ubiquitous-utility-type modules
|
||||
|
||||
#[cfg(notest)]
|
||||
pub mod ops;
|
||||
pub mod cmp;
|
||||
/* Core language traits */
|
||||
|
||||
#[cfg(notest)] pub mod kinds;
|
||||
#[cfg(notest)] pub mod ops;
|
||||
#[cfg(notest)] pub mod cmp;
|
||||
|
||||
// Make core testable by not duplicating lang items. See #2912
|
||||
#[cfg(test)] extern mod realcore(name = "core", vers = "0.5");
|
||||
#[cfg(test)] pub use kinds = realcore::kinds;
|
||||
#[cfg(test)] pub use ops = realcore::ops;
|
||||
#[cfg(test)] pub use cmp = realcore::cmp;
|
||||
|
||||
|
||||
/* Common traits */
|
||||
|
||||
pub mod from_str;
|
||||
pub mod num;
|
||||
pub mod hash;
|
||||
pub mod either;
|
||||
pub mod iter;
|
||||
pub mod logging;
|
||||
pub mod option;
|
||||
#[path="iter-trait.rs"]
|
||||
#[merge = "iter-trait/option.rs"]
|
||||
pub mod option_iter;
|
||||
pub mod result;
|
||||
pub mod to_str;
|
||||
pub mod to_bytes;
|
||||
pub mod from_str;
|
||||
pub mod util;
|
||||
pub mod clone;
|
||||
pub mod io;
|
||||
pub mod hash;
|
||||
|
||||
// Data structure modules
|
||||
|
||||
/* Common data structures */
|
||||
|
||||
pub mod option;
|
||||
#[path="iter-trait.rs"] #[merge = "iter-trait/option.rs"]
|
||||
pub mod option_iter;
|
||||
pub mod result;
|
||||
pub mod either;
|
||||
pub mod dvec;
|
||||
#[path="iter-trait.rs"]
|
||||
#[merge = "iter-trait/dvec.rs"]
|
||||
#[path="iter-trait.rs"] #[merge = "iter-trait/dvec.rs"]
|
||||
pub mod dvec_iter;
|
||||
pub mod dlist;
|
||||
#[path="iter-trait.rs"]
|
||||
#[merge = "iter-trait/dlist.rs"]
|
||||
#[path="iter-trait.rs"] #[merge = "iter-trait/dlist.rs"]
|
||||
pub mod dlist_iter;
|
||||
pub mod send_map;
|
||||
|
||||
// Concurrency
|
||||
|
||||
/* Tasks and communication */
|
||||
|
||||
pub mod comm;
|
||||
#[path = "task/mod.rs"]
|
||||
pub mod task;
|
||||
pub mod pipes;
|
||||
|
||||
// Runtime and language-primitive support
|
||||
|
||||
/* Runtime and platform support */
|
||||
|
||||
pub mod gc;
|
||||
pub mod io;
|
||||
pub mod libc;
|
||||
pub mod os;
|
||||
pub mod path;
|
||||
@ -165,36 +151,28 @@ pub mod repr;
|
||||
pub mod cleanup;
|
||||
pub mod reflect;
|
||||
pub mod condition;
|
||||
pub mod logging;
|
||||
pub mod util;
|
||||
|
||||
// Modules supporting compiler-generated code
|
||||
// Exported but not part of the public interface
|
||||
|
||||
pub mod extfmt;
|
||||
// The test harness links against core, so don't include runtime in tests.
|
||||
#[cfg(notest)]
|
||||
#[legacy_exports]
|
||||
pub mod rt;
|
||||
/* Reexported core operators */
|
||||
|
||||
// Ideally not exported, but currently is.
|
||||
pub mod private;
|
||||
pub use kinds::{Const, Copy, Send, Owned};
|
||||
pub use ops::{Drop};
|
||||
pub use ops::{Add, Sub, Mul, Div, Modulo, Neg};
|
||||
pub use ops::{BitAnd, BitOr, BitXor};
|
||||
pub use ops::{Shl, Shr, Index};
|
||||
|
||||
// For internal use, not exported.
|
||||
mod unicode;
|
||||
mod cmath;
|
||||
mod stackwalk;
|
||||
|
||||
// Top-level, visible-everywhere definitions.
|
||||
/* Reexported types and traits */
|
||||
|
||||
// Export various ubiquitous types, constructors, methods.
|
||||
|
||||
pub use option::{Some, None};
|
||||
pub use Option = option::Option;
|
||||
pub use option::{Option, Some, None};
|
||||
pub use result::{Result, Ok, Err};
|
||||
|
||||
pub use Path = path::Path;
|
||||
pub use GenericPath = path::GenericPath;
|
||||
pub use WindowsPath = path::WindowsPath;
|
||||
pub use PosixPath = path::PosixPath;
|
||||
pub use path::Path;
|
||||
pub use path::GenericPath;
|
||||
pub use path::WindowsPath;
|
||||
pub use path::PosixPath;
|
||||
|
||||
pub use tuple::{CopyableTuple, ImmutableTuple, ExtendedTupleOps};
|
||||
pub use str::{StrSlice, Trimmable};
|
||||
@ -203,44 +181,18 @@ pub use vec::{ImmutableEqVector, ImmutableCopyableVector};
|
||||
pub use vec::{MutableVector, MutableCopyableVector};
|
||||
pub use iter::{BaseIter, ExtendedIter, EqIter, CopyableIter};
|
||||
pub use iter::{CopyableOrderedIter, CopyableNonstrictIter, Times};
|
||||
|
||||
pub use num::Num;
|
||||
pub use ptr::Ptr;
|
||||
pub use to_str::ToStr;
|
||||
|
||||
// The following exports are the core operators and kinds
|
||||
// The compiler has special knowlege of these so we must not duplicate them
|
||||
// when compiling for testing
|
||||
#[cfg(notest)]
|
||||
pub use ops::{Const, Copy, Send, Owned};
|
||||
#[cfg(notest)]
|
||||
pub use ops::{Drop};
|
||||
#[cfg(notest)]
|
||||
pub use ops::{Add, Sub, Mul, Div, Modulo, Neg, BitAnd, BitOr, BitXor};
|
||||
#[cfg(notest)]
|
||||
pub use ops::{Shl, Shr, Index};
|
||||
|
||||
#[cfg(test)]
|
||||
extern mod coreops(name = "core", vers = "0.5");
|
||||
|
||||
#[cfg(test)]
|
||||
pub use coreops::ops::{Const, Copy, Send, Owned};
|
||||
#[cfg(test)]
|
||||
pub use coreops::ops::{Drop};
|
||||
#[cfg(test)]
|
||||
pub use coreops::ops::{Add, Sub, Mul, Div, Modulo, Neg, BitAnd, BitOr};
|
||||
#[cfg(test)]
|
||||
pub use coreops::ops::{BitXor};
|
||||
#[cfg(test)]
|
||||
pub use coreops::ops::{Shl, Shr, Index};
|
||||
|
||||
#[cfg(notest)]
|
||||
pub use clone::Clone;
|
||||
#[cfg(test)]
|
||||
pub use coreops::clone::Clone;
|
||||
|
||||
// Export the log levels as global constants. Higher levels mean
|
||||
// more-verbosity. Error is the bottom level, default logging level is
|
||||
// warn-and-below.
|
||||
|
||||
/*
|
||||
* Export the log levels as global constants. Higher levels mean
|
||||
* more-verbosity. Error is the bottom level, default logging level is
|
||||
* warn-and-below.
|
||||
*/
|
||||
|
||||
/// The error log level
|
||||
pub const error : u32 = 1_u32;
|
||||
@ -251,6 +203,24 @@ pub const info : u32 = 3_u32;
|
||||
/// The debug log level
|
||||
pub const debug : u32 = 4_u32;
|
||||
|
||||
|
||||
/* Unsupported interfaces */
|
||||
|
||||
// The runtime interface used by the compiler
|
||||
#[cfg(notest)] pub mod rt;
|
||||
// The runtime and compiler interface to fmt!
|
||||
pub mod extfmt;
|
||||
// Private APIs
|
||||
pub mod private;
|
||||
|
||||
|
||||
/* For internal use, not exported */
|
||||
|
||||
mod unicode;
|
||||
mod cmath;
|
||||
mod stackwalk;
|
||||
|
||||
|
||||
// A curious inner-module that's not exported that contains the binding
|
||||
// 'core' so that macro-expanded references to core::error and such
|
||||
// can be resolved within libcore.
|
||||
@ -262,6 +232,7 @@ mod core {
|
||||
pub const debug : u32 = 4_u32;
|
||||
}
|
||||
|
||||
|
||||
// Similar to above. Some magic to make core testable.
|
||||
#[cfg(test)]
|
||||
mod std {
|
||||
@ -269,6 +240,7 @@ mod std {
|
||||
pub use std::test;
|
||||
}
|
||||
|
||||
|
||||
// Local Variables:
|
||||
// mode: rust;
|
||||
// fill-column: 78;
|
||||
|
@ -138,11 +138,13 @@ pub pure fn logarithm(n: f32, b: f32) -> f32 {
|
||||
return log2(n) / log2(b);
|
||||
}
|
||||
|
||||
#[cfg(notest)]
|
||||
impl f32 : cmp::Eq {
|
||||
pure fn eq(&self, other: &f32) -> bool { (*self) == (*other) }
|
||||
pure fn ne(&self, other: &f32) -> bool { (*self) != (*other) }
|
||||
}
|
||||
|
||||
#[cfg(notest)]
|
||||
impl f32 : cmp::Ord {
|
||||
pure fn lt(&self, other: &f32) -> bool { (*self) < (*other) }
|
||||
pure fn le(&self, other: &f32) -> bool { (*self) <= (*other) }
|
||||
|
@ -157,11 +157,13 @@ pub pure fn logarithm(n: f64, b: f64) -> f64 {
|
||||
return log2(n) / log2(b);
|
||||
}
|
||||
|
||||
#[cfg(notest)]
|
||||
impl f64 : cmp::Eq {
|
||||
pure fn eq(&self, other: &f64) -> bool { (*self) == (*other) }
|
||||
pure fn ne(&self, other: &f64) -> bool { (*self) != (*other) }
|
||||
}
|
||||
|
||||
#[cfg(notest)]
|
||||
impl f64 : cmp::Ord {
|
||||
pure fn lt(&self, other: &f64) -> bool { (*self) < (*other) }
|
||||
pure fn le(&self, other: &f64) -> bool { (*self) <= (*other) }
|
||||
|
@ -399,11 +399,13 @@ pub pure fn sin(x: float) -> float { f64::sin(x as f64) as float }
|
||||
pub pure fn cos(x: float) -> float { f64::cos(x as f64) as float }
|
||||
pub pure fn tan(x: float) -> float { f64::tan(x as f64) as float }
|
||||
|
||||
#[cfg(notest)]
|
||||
impl float : Eq {
|
||||
pure fn eq(&self, other: &float) -> bool { (*self) == (*other) }
|
||||
pure fn ne(&self, other: &float) -> bool { (*self) != (*other) }
|
||||
}
|
||||
|
||||
#[cfg(notest)]
|
||||
impl float : Ord {
|
||||
pure fn lt(&self, other: &float) -> bool { (*self) < (*other) }
|
||||
pure fn le(&self, other: &float) -> bool { (*self) <= (*other) }
|
||||
|
@ -54,6 +54,7 @@ pub pure fn abs(i: T) -> T {
|
||||
if is_negative(i) { -i } else { i }
|
||||
}
|
||||
|
||||
#[cfg(notest)]
|
||||
impl T : Ord {
|
||||
pure fn lt(&self, other: &T) -> bool { return (*self) < (*other); }
|
||||
pure fn le(&self, other: &T) -> bool { return (*self) <= (*other); }
|
||||
@ -61,6 +62,7 @@ impl T : Ord {
|
||||
pure fn gt(&self, other: &T) -> bool { return (*self) > (*other); }
|
||||
}
|
||||
|
||||
#[cfg(notest)]
|
||||
impl T : Eq {
|
||||
pure fn eq(&self, other: &T) -> bool { return (*self) == (*other); }
|
||||
pure fn ne(&self, other: &T) -> bool { return (*self) != (*other); }
|
||||
|
@ -1,3 +1,5 @@
|
||||
//! Operations and constants for `i16`
|
||||
|
||||
mod inst {
|
||||
pub type T = i16;
|
||||
pub const bits: uint = u16::bits;
|
||||
|
@ -1,3 +1,5 @@
|
||||
//! Operations and constants for `i32`
|
||||
|
||||
mod inst {
|
||||
pub type T = i32;
|
||||
pub const bits: uint = u32::bits;
|
||||
|
@ -1,3 +1,5 @@
|
||||
//! Operations and constants for `i64`
|
||||
|
||||
mod inst {
|
||||
pub type T = i64;
|
||||
pub const bits: uint = u64::bits;
|
||||
|
@ -1,3 +1,5 @@
|
||||
//! Operations and constants for `i8`
|
||||
|
||||
mod inst {
|
||||
pub type T = i8;
|
||||
pub const bits: uint = u8::bits;
|
||||
|
@ -1,3 +1,5 @@
|
||||
//! Operations and constants for `int`
|
||||
|
||||
pub use inst::pow;
|
||||
|
||||
mod inst {
|
||||
|
21
src/libcore/kinds.rs
Normal file
21
src/libcore/kinds.rs
Normal file
@ -0,0 +1,21 @@
|
||||
//! The kind traits
|
||||
|
||||
#[lang="const"]
|
||||
pub trait Const {
|
||||
// Empty.
|
||||
}
|
||||
|
||||
#[lang="copy"]
|
||||
pub trait Copy {
|
||||
// Empty.
|
||||
}
|
||||
|
||||
#[lang="send"]
|
||||
pub trait Send {
|
||||
// Empty.
|
||||
}
|
||||
|
||||
#[lang="owned"]
|
||||
pub trait Owned {
|
||||
// Empty.
|
||||
}
|
@ -1,28 +1,8 @@
|
||||
// Core operators and kinds.
|
||||
// Core operators
|
||||
|
||||
#[forbid(deprecated_mode)];
|
||||
#[forbid(deprecated_pattern)];
|
||||
|
||||
#[lang="const"]
|
||||
pub trait Const {
|
||||
// Empty.
|
||||
}
|
||||
|
||||
#[lang="copy"]
|
||||
pub trait Copy {
|
||||
// Empty.
|
||||
}
|
||||
|
||||
#[lang="send"]
|
||||
pub trait Send {
|
||||
// Empty.
|
||||
}
|
||||
|
||||
#[lang="owned"]
|
||||
pub trait Owned {
|
||||
// Empty.
|
||||
}
|
||||
|
||||
#[lang="drop"]
|
||||
pub trait Drop {
|
||||
fn finalize(&self); // XXX: Rename to "drop"? --pcwalton
|
||||
|
@ -6,11 +6,13 @@
|
||||
|
||||
use cmp::{Eq, Ord};
|
||||
|
||||
#[cfg(notest)]
|
||||
impl<T:Eq> ~const T : Eq {
|
||||
pure fn eq(&self, other: &~const T) -> bool { *(*self) == *(*other) }
|
||||
pure fn ne(&self, other: &~const T) -> bool { *(*self) != *(*other) }
|
||||
}
|
||||
|
||||
#[cfg(notest)]
|
||||
impl<T:Ord> ~const T : Ord {
|
||||
pure fn lt(&self, other: &~const T) -> bool { *(*self) < *(*other) }
|
||||
pure fn le(&self, other: &~const T) -> bool { *(*self) <= *(*other) }
|
||||
|
@ -207,6 +207,7 @@ impl<T> *mut T: Ptr<T> {
|
||||
}
|
||||
|
||||
// Equality for pointers
|
||||
#[cfg(notest)]
|
||||
impl<T> *const T : Eq {
|
||||
pure fn eq(&self, other: &*const T) -> bool unsafe {
|
||||
let a: uint = cast::reinterpret_cast(&(*self));
|
||||
@ -217,6 +218,7 @@ impl<T> *const T : Eq {
|
||||
}
|
||||
|
||||
// Comparison for pointers
|
||||
#[cfg(notest)]
|
||||
impl<T> *const T : Ord {
|
||||
pure fn lt(&self, other: &*const T) -> bool unsafe {
|
||||
let a: uint = cast::reinterpret_cast(&(*self));
|
||||
@ -241,6 +243,7 @@ impl<T> *const T : Ord {
|
||||
}
|
||||
|
||||
// Equality for region pointers
|
||||
#[cfg(notest)]
|
||||
impl<T:Eq> &const T : Eq {
|
||||
pure fn eq(&self, other: & &self/const T) -> bool {
|
||||
return *(*self) == *(*other);
|
||||
@ -251,6 +254,7 @@ impl<T:Eq> &const T : Eq {
|
||||
}
|
||||
|
||||
// Comparison for region pointers
|
||||
#[cfg(notest)]
|
||||
impl<T:Ord> &const T : Ord {
|
||||
pure fn lt(&self, other: & &self/const T) -> bool {
|
||||
*(*self) < *(*other)
|
||||
|
@ -1,3 +1,5 @@
|
||||
#[legacy_exports];
|
||||
|
||||
// NB: transitionary, de-mode-ing.
|
||||
#[forbid(deprecated_mode)];
|
||||
#[forbid(deprecated_pattern)];
|
||||
|
@ -735,6 +735,7 @@ pure fn gt(a: &str, b: &str) -> bool {
|
||||
!le(a, b)
|
||||
}
|
||||
|
||||
#[cfg(notest)]
|
||||
impl &str : Eq {
|
||||
#[inline(always)]
|
||||
pure fn eq(&self, other: & &self/str) -> bool {
|
||||
@ -744,6 +745,7 @@ impl &str : Eq {
|
||||
pure fn ne(&self, other: & &self/str) -> bool { !(*self).eq(other) }
|
||||
}
|
||||
|
||||
#[cfg(notest)]
|
||||
impl ~str : Eq {
|
||||
#[inline(always)]
|
||||
pure fn eq(&self, other: &~str) -> bool {
|
||||
@ -753,6 +755,7 @@ impl ~str : Eq {
|
||||
pure fn ne(&self, other: &~str) -> bool { !(*self).eq(other) }
|
||||
}
|
||||
|
||||
#[cfg(notest)]
|
||||
impl @str : Eq {
|
||||
#[inline(always)]
|
||||
pure fn eq(&self, other: &@str) -> bool {
|
||||
@ -762,6 +765,7 @@ impl @str : Eq {
|
||||
pure fn ne(&self, other: &@str) -> bool { !(*self).eq(other) }
|
||||
}
|
||||
|
||||
#[cfg(notest)]
|
||||
impl ~str : Ord {
|
||||
#[inline(always)]
|
||||
pure fn lt(&self, other: &~str) -> bool { lt((*self), (*other)) }
|
||||
@ -773,6 +777,7 @@ impl ~str : Ord {
|
||||
pure fn gt(&self, other: &~str) -> bool { gt((*self), (*other)) }
|
||||
}
|
||||
|
||||
#[cfg(notest)]
|
||||
impl &str : Ord {
|
||||
#[inline(always)]
|
||||
pure fn lt(&self, other: & &self/str) -> bool { lt((*self), (*other)) }
|
||||
@ -784,6 +789,7 @@ impl &str : Ord {
|
||||
pure fn gt(&self, other: & &self/str) -> bool { gt((*self), (*other)) }
|
||||
}
|
||||
|
||||
#[cfg(notest)]
|
||||
impl @str : Ord {
|
||||
#[inline(always)]
|
||||
pure fn lt(&self, other: &@str) -> bool { lt((*self), (*other)) }
|
||||
|
@ -94,6 +94,7 @@ impl<A: Copy, B: Copy> (~[A], ~[B]): ExtendedTupleOps<A,B> {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(notest)]
|
||||
impl<A: Eq, B: Eq> (A, B) : Eq {
|
||||
pure fn eq(&self, other: &(A, B)) -> bool {
|
||||
match (*self) {
|
||||
@ -107,6 +108,7 @@ impl<A: Eq, B: Eq> (A, B) : Eq {
|
||||
pure fn ne(&self, other: &(A, B)) -> bool { !(*self).eq(other) }
|
||||
}
|
||||
|
||||
#[cfg(notest)]
|
||||
impl<A: Ord, B: Ord> (A, B) : Ord {
|
||||
pure fn lt(&self, other: &(A, B)) -> bool {
|
||||
match (*self) {
|
||||
@ -127,6 +129,7 @@ impl<A: Ord, B: Ord> (A, B) : Ord {
|
||||
pure fn gt(&self, other: &(A, B)) -> bool { (*other).lt(&(*self)) }
|
||||
}
|
||||
|
||||
#[cfg(notest)]
|
||||
impl<A: Eq, B: Eq, C: Eq> (A, B, C) : Eq {
|
||||
pure fn eq(&self, other: &(A, B, C)) -> bool {
|
||||
match (*self) {
|
||||
@ -141,6 +144,7 @@ impl<A: Eq, B: Eq, C: Eq> (A, B, C) : Eq {
|
||||
pure fn ne(&self, other: &(A, B, C)) -> bool { !(*self).eq(other) }
|
||||
}
|
||||
|
||||
#[cfg(notest)]
|
||||
impl<A: Ord, B: Ord, C: Ord> (A, B, C) : Ord {
|
||||
pure fn lt(&self, other: &(A, B, C)) -> bool {
|
||||
match (*self) {
|
||||
|
@ -48,6 +48,7 @@ pub pure fn compl(i: T) -> T {
|
||||
max_value ^ i
|
||||
}
|
||||
|
||||
#[cfg(notest)]
|
||||
impl T : Ord {
|
||||
pure fn lt(&self, other: &T) -> bool { (*self) < (*other) }
|
||||
pure fn le(&self, other: &T) -> bool { (*self) <= (*other) }
|
||||
@ -55,6 +56,7 @@ impl T : Ord {
|
||||
pure fn gt(&self, other: &T) -> bool { (*self) > (*other) }
|
||||
}
|
||||
|
||||
#[cfg(notest)]
|
||||
impl T : Eq {
|
||||
pure fn eq(&self, other: &T) -> bool { return (*self) == (*other); }
|
||||
pure fn ne(&self, other: &T) -> bool { return (*self) != (*other); }
|
||||
|
@ -1,3 +1,5 @@
|
||||
//! Operations and constants for `u16`
|
||||
|
||||
mod inst {
|
||||
pub type T = u16;
|
||||
pub const bits: uint = 16;
|
||||
|
@ -1,3 +1,5 @@
|
||||
//! Operations and constants for `u32`
|
||||
|
||||
mod inst {
|
||||
pub type T = u32;
|
||||
pub const bits: uint = 32;
|
||||
|
@ -1,3 +1,5 @@
|
||||
//! Operations and constants for `u64`
|
||||
|
||||
mod inst {
|
||||
pub type T = u64;
|
||||
pub const bits: uint = 64;
|
||||
|
@ -1,3 +1,5 @@
|
||||
//! Operations and constants for `u8`
|
||||
|
||||
pub use inst::is_ascii;
|
||||
|
||||
mod inst {
|
||||
|
@ -1,3 +1,5 @@
|
||||
//! Operations and constants for `uint`
|
||||
|
||||
pub use inst::{
|
||||
div_ceil, div_round, div_floor, iterate,
|
||||
next_power_of_two
|
||||
|
@ -10,11 +10,13 @@ Functions for the unit type.
|
||||
|
||||
use cmp::{Eq, Ord};
|
||||
|
||||
#[cfg(notest)]
|
||||
impl () : Eq {
|
||||
pure fn eq(&self, _other: &()) -> bool { true }
|
||||
pure fn ne(&self, _other: &()) -> bool { false }
|
||||
}
|
||||
|
||||
#[cfg(notest)]
|
||||
impl () : Ord {
|
||||
pure fn lt(&self, _other: &()) -> bool { false }
|
||||
pure fn le(&self, _other: &()) -> bool { true }
|
||||
|
@ -1345,6 +1345,7 @@ pure fn eq<T: Eq>(a: &[T], b: &[T]) -> bool {
|
||||
return true;
|
||||
}
|
||||
|
||||
#[cfg(notest)]
|
||||
impl<T: Eq> &[T] : Eq {
|
||||
#[inline(always)]
|
||||
pure fn eq(&self, other: & &self/[T]) -> bool { eq((*self), (*other)) }
|
||||
@ -1353,6 +1354,7 @@ impl<T: Eq> &[T] : Eq {
|
||||
}
|
||||
|
||||
|
||||
#[cfg(notest)]
|
||||
impl<T: Eq> ~[T] : Eq {
|
||||
#[inline(always)]
|
||||
pure fn eq(&self, other: &~[T]) -> bool { eq((*self), (*other)) }
|
||||
@ -1360,6 +1362,7 @@ impl<T: Eq> ~[T] : Eq {
|
||||
pure fn ne(&self, other: &~[T]) -> bool { !(*self).eq(other) }
|
||||
}
|
||||
|
||||
#[cfg(notest)]
|
||||
impl<T: Eq> @[T] : Eq {
|
||||
#[inline(always)]
|
||||
pure fn eq(&self, other: &@[T]) -> bool { eq((*self), (*other)) }
|
||||
@ -1388,6 +1391,7 @@ pure fn le<T: Ord>(a: &[T], b: &[T]) -> bool { !lt(b, a) }
|
||||
pure fn ge<T: Ord>(a: &[T], b: &[T]) -> bool { !lt(a, b) }
|
||||
pure fn gt<T: Ord>(a: &[T], b: &[T]) -> bool { lt(b, a) }
|
||||
|
||||
#[cfg(notest)]
|
||||
impl<T: Ord> &[T] : Ord {
|
||||
#[inline(always)]
|
||||
pure fn lt(&self, other: & &self/[T]) -> bool { lt((*self), (*other)) }
|
||||
@ -1399,6 +1403,7 @@ impl<T: Ord> &[T] : Ord {
|
||||
pure fn gt(&self, other: & &self/[T]) -> bool { gt((*self), (*other)) }
|
||||
}
|
||||
|
||||
#[cfg(notest)]
|
||||
impl<T: Ord> ~[T] : Ord {
|
||||
#[inline(always)]
|
||||
pure fn lt(&self, other: &~[T]) -> bool { lt((*self), (*other)) }
|
||||
@ -1410,6 +1415,7 @@ impl<T: Ord> ~[T] : Ord {
|
||||
pure fn gt(&self, other: &~[T]) -> bool { gt((*self), (*other)) }
|
||||
}
|
||||
|
||||
#[cfg(notest)]
|
||||
impl<T: Ord> @[T] : Ord {
|
||||
#[inline(always)]
|
||||
pure fn lt(&self, other: &@[T]) -> bool { lt((*self), (*other)) }
|
||||
@ -1422,24 +1428,20 @@ impl<T: Ord> @[T] : Ord {
|
||||
}
|
||||
|
||||
#[cfg(notest)]
|
||||
pub mod traits {
|
||||
impl<T: Copy> ~[T] : Add<&[const T],~[T]> {
|
||||
#[inline(always)]
|
||||
pure fn add(rhs: & &self/[const T]) -> ~[T] {
|
||||
append(copy self, (*rhs))
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Copy> ~[mut T] : Add<&[const T],~[mut T]> {
|
||||
#[inline(always)]
|
||||
pure fn add(rhs: & &self/[const T]) -> ~[mut T] {
|
||||
append_mut(copy self, (*rhs))
|
||||
}
|
||||
impl<T: Copy> ~[T] : Add<&[const T],~[T]> {
|
||||
#[inline(always)]
|
||||
pure fn add(rhs: & &self/[const T]) -> ~[T] {
|
||||
append(copy self, (*rhs))
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
pub mod traits {}
|
||||
#[cfg(notest)]
|
||||
impl<T: Copy> ~[mut T] : Add<&[const T],~[mut T]> {
|
||||
#[inline(always)]
|
||||
pure fn add(rhs: & &self/[const T]) -> ~[mut T] {
|
||||
append_mut(copy self, (*rhs))
|
||||
}
|
||||
}
|
||||
|
||||
pub trait ConstVector {
|
||||
pure fn is_empty() -> bool;
|
||||
|
Loading…
x
Reference in New Issue
Block a user