1
Fork 0

replace #[inline(always)] with #[inline]. r=burningtree.

This commit is contained in:
Graydon Hoare 2013-06-18 14:45:18 -07:00
parent 303d7bfc87
commit d904c72af8
79 changed files with 1317 additions and 1317 deletions

View file

@ -58,7 +58,7 @@ pub struct Condvar<'self> {
impl<'self> Condvar<'self> {
/// Atomically exit the associated ARC and block until a signal is sent.
#[inline(always)]
#[inline]
pub fn wait(&self) { self.wait_on(0) }
/**
@ -67,7 +67,7 @@ impl<'self> Condvar<'self> {
*
* wait() is equivalent to wait_on(0).
*/
#[inline(always)]
#[inline]
pub fn wait_on(&self, condvar_id: uint) {
assert!(!*self.failed);
self.cond.wait_on(condvar_id);
@ -76,28 +76,28 @@ impl<'self> Condvar<'self> {
}
/// Wake up a blocked task. Returns false if there was no blocked task.
#[inline(always)]
#[inline]
pub fn signal(&self) -> bool { self.signal_on(0) }
/**
* Wake up a blocked task on a specified condvar (as
* sync::cond.signal_on). Returns false if there was no blocked task.
*/
#[inline(always)]
#[inline]
pub fn signal_on(&self, condvar_id: uint) -> bool {
assert!(!*self.failed);
self.cond.signal_on(condvar_id)
}
/// Wake up all blocked tasks. Returns the number of tasks woken.
#[inline(always)]
#[inline]
pub fn broadcast(&self) -> uint { self.broadcast_on(0) }
/**
* Wake up all blocked tasks on a specified condvar (as
* sync::cond.broadcast_on). Returns the number of tasks woken.
*/
#[inline(always)]
#[inline]
pub fn broadcast_on(&self, condvar_id: uint) -> uint {
assert!(!*self.failed);
self.cond.broadcast_on(condvar_id)
@ -198,7 +198,7 @@ impl<T:Owned> MutexARC<T> {
* any tasks that subsequently try to access it (including those already
* blocked on the mutex) will also fail immediately.
*/
#[inline(always)]
#[inline]
pub unsafe fn access<U>(&self, blk: &fn(x: &mut T) -> U) -> U {
unsafe {
let state = self.x.get();
@ -213,7 +213,7 @@ impl<T:Owned> MutexARC<T> {
}
/// As access(), but with a condvar, as sync::mutex.lock_cond().
#[inline(always)]
#[inline]
pub unsafe fn access_cond<'x, 'c, U>(&self,
blk: &fn(x: &'x mut T,
c: &'c Condvar) -> U)
@ -231,7 +231,7 @@ impl<T:Owned> MutexARC<T> {
}
// Common code for {mutex.access,rwlock.write}{,_cond}.
#[inline(always)]
#[inline]
#[doc(hidden)]
fn check_poison(is_mutex: bool, failed: bool) {
if failed {
@ -322,7 +322,7 @@ impl<T:Const + Owned> RWARC<T> {
* that other tasks won't block forever. As MutexARC.access, it will also
* poison the ARC, so subsequent readers and writers will both also fail.
*/
#[inline(always)]
#[inline]
pub fn write<U>(&self, blk: &fn(x: &mut T) -> U) -> U {
unsafe {
let state = self.x.get();
@ -335,7 +335,7 @@ impl<T:Const + Owned> RWARC<T> {
}
/// As write(), but with a condvar, as sync::rwlock.write_cond().
#[inline(always)]
#[inline]
pub fn write_cond<'x, 'c, U>(&self,
blk: &fn(x: &'x mut T, c: &'c Condvar) -> U)
-> U {

View file

@ -119,7 +119,7 @@ pub fn Arena() -> Arena {
arena_with_size(32u)
}
#[inline(always)]
#[inline]
fn round_up_to(base: uint, align: uint) -> uint {
(base + (align - 1)) & !(align - 1)
}
@ -156,12 +156,12 @@ unsafe fn destroy_chunk(chunk: &Chunk) {
// initialized in the arena in the low bit of the tydesc pointer. This
// is necessary in order to properly do cleanup if a failure occurs
// during an initializer.
#[inline(always)]
#[inline]
unsafe fn bitpack_tydesc_ptr(p: *TypeDesc, is_done: bool) -> uint {
let p_bits: uint = transmute(p);
p_bits | (is_done as uint)
}
#[inline(always)]
#[inline]
unsafe fn un_bitpack_tydesc_ptr(p: uint) -> (*TypeDesc, bool) {
(transmute(p & !1), p & 1 == 1)
}
@ -179,7 +179,7 @@ impl Arena {
return self.alloc_pod_inner(n_bytes, align);
}
#[inline(always)]
#[inline]
fn alloc_pod_inner(&mut self, n_bytes: uint, align: uint) -> *u8 {
unsafe {
// XXX: Borrow check
@ -199,7 +199,7 @@ impl Arena {
}
}
#[inline(always)]
#[inline]
fn alloc_pod<'a, T>(&'a mut self, op: &fn() -> T) -> &'a T {
unsafe {
let tydesc = sys::get_type_desc::<T>();
@ -223,7 +223,7 @@ impl Arena {
return self.alloc_nonpod_inner(n_bytes, align);
}
#[inline(always)]
#[inline]
fn alloc_nonpod_inner(&mut self, n_bytes: uint, align: uint)
-> (*u8, *u8) {
unsafe {
@ -246,7 +246,7 @@ impl Arena {
}
}
#[inline(always)]
#[inline]
fn alloc_nonpod<'a, T>(&'a mut self, op: &fn() -> T) -> &'a T {
unsafe {
let tydesc = sys::get_type_desc::<T>();
@ -268,7 +268,7 @@ impl Arena {
}
// The external interface
#[inline(always)]
#[inline]
pub fn alloc<'a, T>(&'a mut self, op: &fn() -> T) -> &'a T {
unsafe {
// XXX: Borrow check

View file

@ -23,7 +23,7 @@ struct SmallBitv {
}
/// a mask that has a 1 for each defined bit in a small_bitv, assuming n bits
#[inline(always)]
#[inline]
fn small_mask(nbits: uint) -> uint {
(1 << nbits) - 1
}
@ -33,7 +33,7 @@ impl SmallBitv {
SmallBitv {bits: bits}
}
#[inline(always)]
#[inline]
pub fn bits_op(&mut self,
right_bits: uint,
nbits: uint,
@ -46,32 +46,32 @@ impl SmallBitv {
mask & old_b != mask & new_b
}
#[inline(always)]
#[inline]
pub fn union(&mut self, s: &SmallBitv, nbits: uint) -> bool {
self.bits_op(s.bits, nbits, |u1, u2| u1 | u2)
}
#[inline(always)]
#[inline]
pub fn intersect(&mut self, s: &SmallBitv, nbits: uint) -> bool {
self.bits_op(s.bits, nbits, |u1, u2| u1 & u2)
}
#[inline(always)]
#[inline]
pub fn become(&mut self, s: &SmallBitv, nbits: uint) -> bool {
self.bits_op(s.bits, nbits, |_u1, u2| u2)
}
#[inline(always)]
#[inline]
pub fn difference(&mut self, s: &SmallBitv, nbits: uint) -> bool {
self.bits_op(s.bits, nbits, |u1, u2| u1 & !u2)
}
#[inline(always)]
#[inline]
pub fn get(&self, i: uint) -> bool {
(self.bits & (1 << i)) != 0
}
#[inline(always)]
#[inline]
pub fn set(&mut self, i: uint, x: bool) {
if x {
self.bits |= 1<<i;
@ -81,29 +81,29 @@ impl SmallBitv {
}
}
#[inline(always)]
#[inline]
pub fn equals(&self, b: &SmallBitv, nbits: uint) -> bool {
let mask = small_mask(nbits);
mask & self.bits == mask & b.bits
}
#[inline(always)]
#[inline]
pub fn clear(&mut self) { self.bits = 0; }
#[inline(always)]
#[inline]
pub fn set_all(&mut self) { self.bits = !0; }
#[inline(always)]
#[inline]
pub fn is_true(&self, nbits: uint) -> bool {
small_mask(nbits) & !self.bits == 0
}
#[inline(always)]
#[inline]
pub fn is_false(&self, nbits: uint) -> bool {
small_mask(nbits) & self.bits == 0
}
#[inline(always)]
#[inline]
pub fn invert(&mut self) { self.bits = !self.bits; }
}
@ -115,7 +115,7 @@ struct BigBitv {
* a mask that has a 1 for each defined bit in the nth element of a big_bitv,
* assuming n bits.
*/
#[inline(always)]
#[inline]
fn big_mask(nbits: uint, elem: uint) -> uint {
let rmd = nbits % uint::bits;
let nelems = nbits/uint::bits + if rmd == 0 {0} else {1};
@ -132,7 +132,7 @@ impl BigBitv {
BigBitv {storage: storage}
}
#[inline(always)]
#[inline]
pub fn process(&mut self,
b: &BigBitv,
nbits: uint,
@ -154,35 +154,35 @@ impl BigBitv {
changed
}
#[inline(always)]
#[inline]
pub fn each_storage(&mut self, op: &fn(v: &mut uint) -> bool) -> bool {
uint::range(0, self.storage.len(), |i| op(&mut self.storage[i]))
}
#[inline(always)]
#[inline]
pub fn invert(&mut self) { for self.each_storage |w| { *w = !*w } }
#[inline(always)]
#[inline]
pub fn union(&mut self, b: &BigBitv, nbits: uint) -> bool {
self.process(b, nbits, |w1, w2| w1 | w2)
}
#[inline(always)]
#[inline]
pub fn intersect(&mut self, b: &BigBitv, nbits: uint) -> bool {
self.process(b, nbits, |w1, w2| w1 & w2)
}
#[inline(always)]
#[inline]
pub fn become(&mut self, b: &BigBitv, nbits: uint) -> bool {
self.process(b, nbits, |_, w| w)
}
#[inline(always)]
#[inline]
pub fn difference(&mut self, b: &BigBitv, nbits: uint) -> bool {
self.process(b, nbits, |w1, w2| w1 & !w2)
}
#[inline(always)]
#[inline]
pub fn get(&self, i: uint) -> bool {
let w = i / uint::bits;
let b = i % uint::bits;
@ -190,7 +190,7 @@ impl BigBitv {
x == 1
}
#[inline(always)]
#[inline]
pub fn set(&mut self, i: uint, x: bool) {
let w = i / uint::bits;
let b = i % uint::bits;
@ -199,7 +199,7 @@ impl BigBitv {
else { self.storage[w] & !flag };
}
#[inline(always)]
#[inline]
pub fn equals(&self, b: &BigBitv, nbits: uint) -> bool {
let len = b.storage.len();
for uint::iterate(0, len) |i| {
@ -229,7 +229,7 @@ fn die() -> ! {
}
impl Bitv {
#[inline(always)]
#[inline]
fn do_op(&mut self, op: Op, other: &Bitv) -> bool {
if self.nbits != other.nbits {
die();
@ -279,7 +279,7 @@ impl Bitv {
* Sets `self` to the union of `self` and `v1`. Both bitvectors must be
* the same length. Returns 'true' if `self` changed.
*/
#[inline(always)]
#[inline]
pub fn union(&mut self, v1: &Bitv) -> bool { self.do_op(Union, v1) }
/**
@ -288,7 +288,7 @@ impl Bitv {
* Sets `self` to the intersection of `self` and `v1`. Both bitvectors
* must be the same length. Returns 'true' if `self` changed.
*/
#[inline(always)]
#[inline]
pub fn intersect(&mut self, v1: &Bitv) -> bool {
self.do_op(Intersect, v1)
}
@ -299,11 +299,11 @@ impl Bitv {
* Both bitvectors must be the same length. Returns `true` if `self` was
* changed
*/
#[inline(always)]
#[inline]
pub fn assign(&mut self, v: &Bitv) -> bool { self.do_op(Assign, v) }
/// Retrieve the value at index `i`
#[inline(always)]
#[inline]
pub fn get(&self, i: uint) -> bool {
assert!((i < self.nbits));
match self.rep {
@ -317,7 +317,7 @@ impl Bitv {
*
* `i` must be less than the length of the bitvector.
*/
#[inline(always)]
#[inline]
pub fn set(&mut self, i: uint, x: bool) {
assert!((i < self.nbits));
match self.rep {
@ -332,7 +332,7 @@ impl Bitv {
* Both bitvectors must be the same length. Returns `true` if both
* bitvectors contain identical elements.
*/
#[inline(always)]
#[inline]
pub fn equal(&self, v1: &Bitv) -> bool {
if self.nbits != v1.nbits { return false; }
match self.rep {
@ -348,7 +348,7 @@ impl Bitv {
}
/// Set all bits to 0
#[inline(always)]
#[inline]
pub fn clear(&mut self) {
match self.rep {
Small(ref mut b) => b.clear(),
@ -357,7 +357,7 @@ impl Bitv {
}
/// Set all bits to 1
#[inline(always)]
#[inline]
pub fn set_all(&mut self) {
match self.rep {
Small(ref mut b) => b.set_all(),
@ -365,7 +365,7 @@ impl Bitv {
}
/// Invert all bits
#[inline(always)]
#[inline]
pub fn invert(&mut self) {
match self.rep {
Small(ref mut b) => b.invert(),
@ -381,13 +381,13 @@ impl Bitv {
*
* Returns `true` if `v0` was changed.
*/
#[inline(always)]
#[inline]
pub fn difference(&mut self, v: &Bitv) -> bool {
self.do_op(Difference, v)
}
/// Returns true if all bits are 1
#[inline(always)]
#[inline]
pub fn is_true(&self) -> bool {
match self.rep {
Small(ref b) => b.is_true(self.nbits),
@ -398,7 +398,7 @@ impl Bitv {
}
}
#[inline(always)]
#[inline]
pub fn each(&self, f: &fn(bool) -> bool) -> bool {
let mut i = 0;
while i < self.nbits {
@ -508,7 +508,7 @@ impl Bitv {
impl Clone for Bitv {
/// Makes a copy of a bitvector
#[inline(always)]
#[inline]
fn clone(&self) -> Bitv {
match self.rep {
Small(ref b) => {
@ -562,7 +562,7 @@ impl ops::Index<uint,bool> for Bitv {
}
}
#[inline(always)]
#[inline]
fn iterate_bits(base: uint, bits: uint, f: &fn(uint) -> bool) -> bool {
if bits == 0 {
return true;
@ -623,7 +623,7 @@ impl BitvSet {
return Bitv{ nbits:cap, rep: Big(~bitv) };
}
#[inline(always)]
#[inline]
fn other_op(&mut self, other: &BitvSet, f: &fn(uint, uint) -> uint) {
fn nbits(mut w: uint) -> uint {
let mut bits = 0;

View file

@ -160,7 +160,7 @@ impl<T> DList<T> {
}
// Link two nodes together. If either of them are 'none', also sets
// the head and/or tail pointers appropriately.
#[inline(always)]
#[inline]
fn link(&mut self, before: DListLink<T>, after: DListLink<T>) {
match before {
Some(neighbour) => neighbour.next = after,
@ -532,7 +532,7 @@ impl<T> BaseIter<T> for @mut DList<T> {
return true;
}
#[inline(always)]
#[inline]
fn size_hint(&self) -> Option<uint> { Some(self.len()) }
}

View file

@ -83,7 +83,7 @@ impl<T: Clone + Num> Cmplx<T> {
#[cfg(not(stage0))] // Fixed by #4228
impl<T: Clone + Algebraic + Num> Cmplx<T> {
/// Calculate |self|
#[inline(always)]
#[inline]
pub fn norm(&self) -> T {
self.re.hypot(&self.im)
}
@ -92,7 +92,7 @@ impl<T: Clone + Algebraic + Num> Cmplx<T> {
#[cfg(not(stage0))] // Fixed by #4228
impl<T: Clone + Trigonometric + Algebraic + Num> Cmplx<T> {
/// Calculate the principal Arg of self.
#[inline(always)]
#[inline]
pub fn arg(&self) -> T {
self.im.atan2(&self.re)
}

View file

@ -36,19 +36,19 @@ pub type BigRational = Ratio<BigInt>;
impl<T: Clone + Integer + Ord>
Ratio<T> {
/// Create a ratio representing the integer `t`.
#[inline(always)]
#[inline]
pub fn from_integer(t: T) -> Ratio<T> {
Ratio::new_raw(t, One::one())
}
/// Create a ratio without checking for `denom == 0` or reducing.
#[inline(always)]
#[inline]
pub fn new_raw(numer: T, denom: T) -> Ratio<T> {
Ratio { numer: numer, denom: denom }
}
/// Create a new Ratio. Fails if `denom == 0`.
#[inline(always)]
#[inline]
pub fn new(numer: T, denom: T) -> Ratio<T> {
if denom == Zero::zero() {
fail!("denominator == 0");
@ -206,7 +206,7 @@ impl<T: Clone + Integer + Ord>
}
}
#[inline(always)]
#[inline]
fn round(&self) -> Ratio<T> {
if *self < Zero::zero() {
Ratio::from_integer((self.numer - self.denom + One::one()) / self.denom)
@ -215,7 +215,7 @@ impl<T: Clone + Integer + Ord>
}
}
#[inline(always)]
#[inline]
fn trunc(&self) -> Ratio<T> {
Ratio::from_integer(self.numer / self.denom)
}

View file

@ -60,7 +60,7 @@ pub fn rc_from_const<T: Const>(value: T) -> Rc<T> {
}
impl<T> Rc<T> {
#[inline(always)]
#[inline]
pub fn borrow<'r>(&'r self) -> &'r T {
unsafe { cast::copy_lifetime(self, &(*self.ptr).value) }
}

View file

@ -29,7 +29,7 @@ pub enum Identifier {
}
impl cmp::Ord for Identifier {
#[inline(always)]
#[inline]
fn lt(&self, other: &Identifier) -> bool {
match (self, other) {
(&Numeric(a), &Numeric(b)) => a < b,
@ -38,22 +38,22 @@ impl cmp::Ord for Identifier {
(&AlphaNumeric(_), _) => false
}
}
#[inline(always)]
#[inline]
fn le(&self, other: &Identifier) -> bool {
! (other < self)
}
#[inline(always)]
#[inline]
fn gt(&self, other: &Identifier) -> bool {
other < self
}
#[inline(always)]
#[inline]
fn ge(&self, other: &Identifier) -> bool {
! (self < other)
}
}
impl ToStr for Identifier {
#[inline(always)]
#[inline]
fn to_str(&self) -> ~str {
match self {
&Numeric(n) => n.to_str(),
@ -73,7 +73,7 @@ pub struct Version {
}
impl ToStr for Version {
#[inline(always)]
#[inline]
fn to_str(&self) -> ~str {
let s = fmt!("%u.%u.%u", self.major, self.minor, self.patch);
let s = if self.pre.is_empty() {
@ -90,7 +90,7 @@ impl ToStr for Version {
}
impl cmp::Ord for Version {
#[inline(always)]
#[inline]
fn lt(&self, other: &Version) -> bool {
self.major < other.major ||
@ -123,15 +123,15 @@ impl cmp::Ord for Version {
self.build < other.build)
}
#[inline(always)]
#[inline]
fn le(&self, other: &Version) -> bool {
! (other < self)
}
#[inline(always)]
#[inline]
fn gt(&self, other: &Version) -> bool {
other < self
}
#[inline(always)]
#[inline]
fn ge(&self, other: &Version) -> bool {
! (self < other)
}

View file

@ -725,7 +725,7 @@ impl<T:Copy + Ord> MergeState<T> {
}
}
#[inline(always)]
#[inline]
fn copy_vec<T:Copy>(dest: &mut [T],
s1: uint,
from: &[T]) {
@ -736,7 +736,7 @@ fn copy_vec<T:Copy>(dest: &mut [T],
}
}
#[inline(always)]
#[inline]
fn shift_vec<T:Copy>(dest: &mut [T],
s1: uint,
s2: uint,

View file

@ -363,7 +363,7 @@ impl<'self> Condvar<'self> {
// Checks whether a condvar ID was out of bounds, and fails if so, or does
// something else next on success.
#[inline(always)]
#[inline]
#[doc(hidden)]
fn check_cvar_bounds<U>(out_of_bounds: Option<uint>, id: uint, act: &str,
blk: &fn() -> U) -> U {

View file

@ -75,13 +75,13 @@ fn lt<K: Ord + TotalOrd, V>(a: &TreeMap<K, V>,
}
impl<K: Ord + TotalOrd, V> Ord for TreeMap<K, V> {
#[inline(always)]
#[inline]
fn lt(&self, other: &TreeMap<K, V>) -> bool { lt(self, other) }
#[inline(always)]
#[inline]
fn le(&self, other: &TreeMap<K, V>) -> bool { !lt(other, self) }
#[inline(always)]
#[inline]
fn ge(&self, other: &TreeMap<K, V>) -> bool { !lt(self, other) }
#[inline(always)]
#[inline]
fn gt(&self, other: &TreeMap<K, V>) -> bool { lt(other, self) }
}
@ -145,7 +145,7 @@ impl<K: TotalOrd, V> Map<K, V> for TreeMap<K, V> {
}
/// Return a mutable reference to the value corresponding to the key
#[inline(always)]
#[inline]
fn find_mut<'a>(&'a mut self, key: &K) -> Option<&'a mut V> {
find_mut(&mut self.root, key)
}
@ -236,7 +236,7 @@ impl<'self, K, V> Iterator<(&'self K, &'self V)> for TreeMapIterator<'self, K, V
impl<'self, T> Iterator<&'self T> for TreeSetIterator<'self, T> {
/// Advance the iterator to the next node (in order). If there are no more nodes, return `None`.
#[inline(always)]
#[inline]
fn next(&mut self) -> Option<&'self T> {
do self.iter.next().map |&(value, _)| { value }
}
@ -251,69 +251,69 @@ pub struct TreeSet<T> {
impl<T: TotalOrd> BaseIter<T> for TreeSet<T> {
/// Visit all values in order
#[inline(always)]
#[inline]
fn each(&self, f: &fn(&T) -> bool) -> bool { self.map.each_key(f) }
#[inline(always)]
#[inline]
fn size_hint(&self) -> Option<uint> { Some(self.len()) }
}
impl<T: TotalOrd> ReverseIter<T> for TreeSet<T> {
/// Visit all values in reverse order
#[inline(always)]
#[inline]
fn each_reverse(&self, f: &fn(&T) -> bool) -> bool {
self.map.each_key_reverse(f)
}
}
impl<T: Eq + TotalOrd> Eq for TreeSet<T> {
#[inline(always)]
#[inline]
fn eq(&self, other: &TreeSet<T>) -> bool { self.map == other.map }
#[inline(always)]
#[inline]
fn ne(&self, other: &TreeSet<T>) -> bool { self.map != other.map }
}
impl<T: Ord + TotalOrd> Ord for TreeSet<T> {
#[inline(always)]
#[inline]
fn lt(&self, other: &TreeSet<T>) -> bool { self.map < other.map }
#[inline(always)]
#[inline]
fn le(&self, other: &TreeSet<T>) -> bool { self.map <= other.map }
#[inline(always)]
#[inline]
fn ge(&self, other: &TreeSet<T>) -> bool { self.map >= other.map }
#[inline(always)]
#[inline]
fn gt(&self, other: &TreeSet<T>) -> bool { self.map > other.map }
}
impl<T: TotalOrd> Container for TreeSet<T> {
/// Return the number of elements in the set
#[inline(always)]
#[inline]
fn len(&const self) -> uint { self.map.len() }
/// Return true if the set contains no elements
#[inline(always)]
#[inline]
fn is_empty(&const self) -> bool { self.map.is_empty() }
}
impl<T: TotalOrd> Mutable for TreeSet<T> {
/// Clear the set, removing all values.
#[inline(always)]
#[inline]
fn clear(&mut self) { self.map.clear() }
}
impl<T: TotalOrd> Set<T> for TreeSet<T> {
/// Return true if the set contains a value
#[inline(always)]
#[inline]
fn contains(&self, value: &T) -> bool {
self.map.contains_key(value)
}
/// Add a value to the set. Return true if the value was not already
/// present in the set.
#[inline(always)]
#[inline]
fn insert(&mut self, value: T) -> bool { self.map.insert(value, ()) }
/// Remove a value from the set. Return true if the value was
/// present in the set.
#[inline(always)]
#[inline]
fn remove(&mut self, value: &T) -> bool { self.map.remove(value) }
/// Return true if the set has no elements in common with `other`.
@ -336,7 +336,7 @@ impl<T: TotalOrd> Set<T> for TreeSet<T> {
}
/// Return true if the set is a subset of another
#[inline(always)]
#[inline]
fn is_subset(&self, other: &TreeSet<T>) -> bool {
other.is_superset(self)
}
@ -490,12 +490,12 @@ impl<T: TotalOrd> Set<T> for TreeSet<T> {
impl<T: TotalOrd> TreeSet<T> {
/// Create an empty TreeSet
#[inline(always)]
#[inline]
pub fn new() -> TreeSet<T> { TreeSet{map: TreeMap::new()} }
/// Get a lazy iterator over the values in the set.
/// Requires that it be frozen (immutable).
#[inline(always)]
#[inline]
pub fn iter<'a>(&'a self) -> TreeSetIterator<'a, T> {
TreeSetIterator{iter: self.map.iter()}
}
@ -518,7 +518,7 @@ struct TreeNode<K, V> {
impl<K: TotalOrd, V> TreeNode<K, V> {
/// Creates a new tree node.
#[inline(always)]
#[inline]
pub fn new(key: K, value: V) -> TreeNode<K, V> {
TreeNode{key: key, value: value, left: None, right: None, level: 1}
}

View file

@ -104,7 +104,7 @@ struct WorkKey {
}
impl to_bytes::IterBytes for WorkKey {
#[inline(always)]
#[inline]
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
self.kind.iter_bytes(lsb0, f) && self.name.iter_bytes(lsb0, f)
}

View file

@ -221,7 +221,7 @@ pub static analysis_passes : &'static [(&'static str, &'static str)] = &'static
/** Transformation Passes */
pub static transform_passes : &'static [(&'static str, &'static str)] = &'static [
("adce", "Aggressive Dead Code Elimination"),
("always-inline", "Inliner for #[inline(always)] functions"),
("always-inline", "Inliner for #[inline] functions"),
("argpromotion", "Promote 'by reference' arguments to scalars"),
("bb-vectorize", "Basic-Block Vectorization"),
("block-placement", "Profile Guided Basic Block Placement"),

View file

@ -775,17 +775,17 @@ impl BorrowckCtxt {
}
impl DataFlowOperator for LoanDataFlowOperator {
#[inline(always)]
#[inline]
fn initial_value(&self) -> bool {
false // no loans in scope by default
}
#[inline(always)]
#[inline]
fn join(&self, succ: uint, pred: uint) -> uint {
succ | pred // loans from both preds are in scope
}
#[inline(always)]
#[inline]
fn walk_closures(&self) -> bool {
true
}

View file

@ -571,34 +571,34 @@ impl FlowedMoveData {
}
impl DataFlowOperator for MoveDataFlowOperator {
#[inline(always)]
#[inline]
fn initial_value(&self) -> bool {
false // no loans in scope by default
}
#[inline(always)]
#[inline]
fn join(&self, succ: uint, pred: uint) -> uint {
succ | pred // moves from both preds are in scope
}
#[inline(always)]
#[inline]
fn walk_closures(&self) -> bool {
true
}
}
impl DataFlowOperator for AssignDataFlowOperator {
#[inline(always)]
#[inline]
fn initial_value(&self) -> bool {
false // no assignments in scope by default
}
#[inline(always)]
#[inline]
fn join(&self, succ: uint, pred: uint) -> uint {
succ | pred // moves from both preds are in scope
}
#[inline(always)]
#[inline]
fn walk_closures(&self) -> bool {
true
}

View file

@ -1016,7 +1016,7 @@ fn join_bits<O:DataFlowOperator>(oper: &O,
bitwise(out_vec, in_vec, |a, b| oper.join(a, b))
}
#[inline(always)]
#[inline]
fn bitwise(out_vec: &mut [uint],
in_vec: &[uint],
op: &fn(uint, uint) -> uint) -> bool {

View file

@ -576,7 +576,7 @@ fn padding(size: u64) -> ValueRef {
}
// XXX this utility routine should be somewhere more general
#[inline(always)]
#[inline]
fn roundup(x: u64, a: u64) -> u64 { ((x + (a - 1)) / a) * a }
/// Get the discriminant of a constant value. (Not currently used.)

View file

@ -1094,62 +1094,62 @@ fn mk_t(cx: ctxt, st: sty) -> t {
}
}
#[inline(always)]
#[inline]
pub fn mk_prim_t(primitive: &'static t_box_) -> t {
unsafe {
cast::transmute::<&'static t_box_, t>(primitive)
}
}
#[inline(always)]
#[inline]
pub fn mk_nil() -> t { mk_prim_t(&primitives::TY_NIL) }
#[inline(always)]
#[inline]
pub fn mk_err() -> t { mk_prim_t(&primitives::TY_ERR) }
#[inline(always)]
#[inline]
pub fn mk_bot() -> t { mk_prim_t(&primitives::TY_BOT) }
#[inline(always)]
#[inline]
pub fn mk_bool() -> t { mk_prim_t(&primitives::TY_BOOL) }
#[inline(always)]
#[inline]
pub fn mk_int() -> t { mk_prim_t(&primitives::TY_INT) }
#[inline(always)]
#[inline]
pub fn mk_i8() -> t { mk_prim_t(&primitives::TY_I8) }
#[inline(always)]
#[inline]
pub fn mk_i16() -> t { mk_prim_t(&primitives::TY_I16) }
#[inline(always)]
#[inline]
pub fn mk_i32() -> t { mk_prim_t(&primitives::TY_I32) }
#[inline(always)]
#[inline]
pub fn mk_i64() -> t { mk_prim_t(&primitives::TY_I64) }
#[inline(always)]
#[inline]
pub fn mk_float() -> t { mk_prim_t(&primitives::TY_FLOAT) }
#[inline(always)]
#[inline]
pub fn mk_f32() -> t { mk_prim_t(&primitives::TY_F32) }
#[inline(always)]
#[inline]
pub fn mk_f64() -> t { mk_prim_t(&primitives::TY_F64) }
#[inline(always)]
#[inline]
pub fn mk_uint() -> t { mk_prim_t(&primitives::TY_UINT) }
#[inline(always)]
#[inline]
pub fn mk_u8() -> t { mk_prim_t(&primitives::TY_U8) }
#[inline(always)]
#[inline]
pub fn mk_u16() -> t { mk_prim_t(&primitives::TY_U16) }
#[inline(always)]
#[inline]
pub fn mk_u32() -> t { mk_prim_t(&primitives::TY_U32) }
#[inline(always)]
#[inline]
pub fn mk_u64() -> t { mk_prim_t(&primitives::TY_U64) }
pub fn mk_mach_int(tm: ast::int_ty) -> t {
@ -1181,7 +1181,7 @@ pub fn mk_mach_float(tm: ast::float_ty) -> t {
}
}
#[inline(always)]
#[inline]
pub fn mk_char() -> t { mk_prim_t(&primitives::TY_CHAR) }
pub fn mk_estr(cx: ctxt, t: vstore) -> t {

View file

@ -725,7 +725,7 @@ impl FnCtxt {
ty::re_scope(self.region_lb)
}
#[inline(always)]
#[inline]
pub fn write_ty(&self, node_id: ast::node_id, ty: ty::t) {
debug!("write_ty(%d, %s) in fcx %s",
node_id, ppaux::ty_to_str(self.tcx(), ty), self.tag());

View file

@ -38,7 +38,7 @@ pub mod rustrt {
}
/// Returns the number of elements the vector can hold without reallocating
#[inline(always)]
#[inline]
pub fn capacity<T>(v: @[T]) -> uint {
unsafe {
let repr: **raw::VecRepr = transmute(&v);
@ -58,7 +58,7 @@ pub fn capacity<T>(v: @[T]) -> uint {
* as an argument a function that will push an element
* onto the vector being constructed.
*/
#[inline(always)]
#[inline]
pub fn build_sized<A>(size: uint, builder: &fn(push: &fn(v: A))) -> @[A] {
let mut vec: @[A] = @[];
unsafe { raw::reserve(&mut vec, size); }
@ -76,7 +76,7 @@ pub fn build_sized<A>(size: uint, builder: &fn(push: &fn(v: A))) -> @[A] {
* as an argument a function that will push an element
* onto the vector being constructed.
*/
#[inline(always)]
#[inline]
pub fn build<A>(builder: &fn(push: &fn(v: A))) -> @[A] {
build_sized(4, builder)
}
@ -93,7 +93,7 @@ pub fn build<A>(builder: &fn(push: &fn(v: A))) -> @[A] {
* as an argument a function that will push an element
* onto the vector being constructed.
*/
#[inline(always)]
#[inline]
pub fn build_sized_opt<A>(size: Option<uint>,
builder: &fn(push: &fn(v: A)))
-> @[A] {
@ -104,7 +104,7 @@ pub fn build_sized_opt<A>(size: Option<uint>,
/// Iterates over the `rhs` vector, copying each element and appending it to the
/// `lhs`. Afterwards, the `lhs` is then returned for use again.
#[inline(always)]
#[inline]
pub fn append<T:Copy>(lhs: @[T], rhs: &const [T]) -> @[T] {
do build_sized(lhs.len() + rhs.len()) |push| {
for lhs.each |x| { push(copy *x); }
@ -178,7 +178,7 @@ pub mod traits {
use ops::Add;
impl<'self,T:Copy> Add<&'self const [T],@[T]> for @[T] {
#[inline(always)]
#[inline]
fn add(&self, rhs: & &'self const [T]) -> @[T] {
append(*self, (*rhs))
}
@ -208,7 +208,7 @@ pub mod raw {
* modifing its buffers, so it is up to the caller to ensure that
* the vector is actually the specified size.
*/
#[inline(always)]
#[inline]
pub unsafe fn set_len<T>(v: @[T], new_len: uint) {
let repr: **mut VecRepr = transmute(&v);
(**repr).unboxed.fill = new_len * sys::size_of::<T>();
@ -217,7 +217,7 @@ pub mod raw {
/**
* Pushes a new value onto this vector.
*/
#[inline(always)]
#[inline]
pub unsafe fn push<T>(v: &mut @[T], initval: T) {
let repr: **VecRepr = transmute_copy(&v);
let fill = (**repr).unboxed.fill;
@ -228,7 +228,7 @@ pub mod raw {
}
}
#[inline(always)] // really pretty please
#[inline] // really pretty please
unsafe fn push_fast<T>(v: &mut @[T], initval: T) {
let repr: **mut VecRepr = ::cast::transmute(v);
let fill = (**repr).unboxed.fill;

View file

@ -212,7 +212,7 @@ impl FromStr for bool {
* ~~~
*/
impl ToStr for bool {
#[inline(always)]
#[inline]
fn to_str(&self) -> ~str {
if *self { ~"true" } else { ~"false" }
}
@ -250,24 +250,24 @@ pub fn all_values(blk: &fn(v: bool)) {
* 0
* ~~~
*/
#[inline(always)]
#[inline]
pub fn to_bit(v: bool) -> u8 { if v { 1u8 } else { 0u8 } }
#[cfg(not(test))]
impl Ord for bool {
#[inline(always)]
#[inline]
fn lt(&self, other: &bool) -> bool { to_bit(*self) < to_bit(*other) }
#[inline(always)]
#[inline]
fn le(&self, other: &bool) -> bool { to_bit(*self) <= to_bit(*other) }
#[inline(always)]
#[inline]
fn gt(&self, other: &bool) -> bool { to_bit(*self) > to_bit(*other) }
#[inline(always)]
#[inline]
fn ge(&self, other: &bool) -> bool { to_bit(*self) >= to_bit(*other) }
}
#[cfg(not(test))]
impl TotalOrd for bool {
#[inline(always)]
#[inline]
fn cmp(&self, other: &bool) -> Ordering { to_bit(*self).cmp(&to_bit(*other)) }
}
@ -298,9 +298,9 @@ impl TotalOrd for bool {
*/
#[cfg(not(test))]
impl Eq for bool {
#[inline(always)]
#[inline]
fn eq(&self, other: &bool) -> bool { (*self) == (*other) }
#[inline(always)]
#[inline]
fn ne(&self, other: &bool) -> bool { (*self) != (*other) }
}

View file

@ -14,13 +14,13 @@
use prelude::*;
/// Cast a region pointer - &T - to a uint.
#[inline(always)]
#[inline]
pub fn to_uint<T>(thing: &T) -> uint {
thing as *T as uint
}
/// Determine if two borrowed pointers point to the same thing.
#[inline(always)]
#[inline]
pub fn ref_eq<'a, 'b, T>(thing: &'a T, other: &'b T) -> bool {
to_uint(thing) == to_uint(other)
}
@ -28,11 +28,11 @@ pub fn ref_eq<'a, 'b, T>(thing: &'a T, other: &'b T) -> bool {
// Equality for region pointers
#[cfg(not(test))]
impl<'self, T: Eq> Eq for &'self T {
#[inline(always)]
#[inline]
fn eq(&self, other: & &'self T) -> bool {
*(*self) == *(*other)
}
#[inline(always)]
#[inline]
fn ne(&self, other: & &'self T) -> bool {
*(*self) != *(*other)
}
@ -41,19 +41,19 @@ impl<'self, T: Eq> Eq for &'self T {
// Comparison for region pointers
#[cfg(not(test))]
impl<'self, T: Ord> Ord for &'self T {
#[inline(always)]
#[inline]
fn lt(&self, other: & &'self T) -> bool {
*(*self) < *(*other)
}
#[inline(always)]
#[inline]
fn le(&self, other: & &'self T) -> bool {
*(*self) <= *(*other)
}
#[inline(always)]
#[inline]
fn ge(&self, other: & &'self T) -> bool {
*(*self) >= *(*other)
}
#[inline(always)]
#[inline]
fn gt(&self, other: & &'self T) -> bool {
*(*self) > *(*other)
}

View file

@ -29,7 +29,7 @@ pub unsafe fn transmute_copy<T, U>(src: &T) -> U {
/// Casts the value at `src` to U. The two types must have the same length.
#[cfg(target_word_size = "32", not(stage0))]
#[inline(always)]
#[inline]
pub unsafe fn transmute_copy<T, U>(src: &T) -> U {
let mut dest: U = intrinsics::uninit();
let dest_ptr: *mut u8 = transmute(&mut dest);
@ -40,7 +40,7 @@ pub unsafe fn transmute_copy<T, U>(src: &T) -> U {
/// Casts the value at `src` to U. The two types must have the same length.
#[cfg(target_word_size = "64", not(stage0))]
#[inline(always)]
#[inline]
pub unsafe fn transmute_copy<T, U>(src: &T) -> U {
let mut dest: U = intrinsics::uninit();
let dest_ptr: *mut u8 = transmute(&mut dest);
@ -56,14 +56,14 @@ pub unsafe fn transmute_copy<T, U>(src: &T) -> U {
* to run any required cleanup or memory-management operations on it. This
* can be used for various acts of magick.
*/
#[inline(always)]
#[inline]
pub unsafe fn forget<T>(thing: T) { intrinsics::forget(thing); }
/**
* Force-increment the reference count on a shared box. If used
* carelessly, this can leak the box.
*/
#[inline(always)]
#[inline]
pub unsafe fn bump_box_refcount<T>(t: @T) { forget(t); }
/**
@ -74,59 +74,59 @@ pub unsafe fn bump_box_refcount<T>(t: @T) { forget(t); }
*
* assert!(transmute("L") == ~[76u8, 0u8]);
*/
#[inline(always)]
#[inline]
pub unsafe fn transmute<L, G>(thing: L) -> G {
intrinsics::transmute(thing)
}
/// Coerce an immutable reference to be mutable.
#[inline(always)]
#[inline]
pub unsafe fn transmute_mut<'a,T>(ptr: &'a T) -> &'a mut T { transmute(ptr) }
/// Coerce a mutable reference to be immutable.
#[inline(always)]
#[inline]
pub unsafe fn transmute_immut<'a,T>(ptr: &'a mut T) -> &'a T {
transmute(ptr)
}
/// Coerce a borrowed pointer to have an arbitrary associated region.
#[inline(always)]
#[inline]
pub unsafe fn transmute_region<'a,'b,T>(ptr: &'a T) -> &'b T {
transmute(ptr)
}
/// Coerce an immutable reference to be mutable.
#[inline(always)]
#[inline]
pub unsafe fn transmute_mut_unsafe<T>(ptr: *const T) -> *mut T {
transmute(ptr)
}
/// Coerce an immutable reference to be mutable.
#[inline(always)]
#[inline]
pub unsafe fn transmute_immut_unsafe<T>(ptr: *const T) -> *T {
transmute(ptr)
}
/// Coerce a borrowed mutable pointer to have an arbitrary associated region.
#[inline(always)]
#[inline]
pub unsafe fn transmute_mut_region<'a,'b,T>(ptr: &'a mut T) -> &'b mut T {
transmute(ptr)
}
/// Transforms lifetime of the second pointer to match the first.
#[inline(always)]
#[inline]
pub unsafe fn copy_lifetime<'a,S,T>(_ptr: &'a S, ptr: &T) -> &'a T {
transmute_region(ptr)
}
/// Transforms lifetime of the second pointer to match the first.
#[inline(always)]
#[inline]
pub unsafe fn copy_mut_lifetime<'a,S,T>(_ptr: &'a mut S, ptr: &mut T) -> &'a mut T {
transmute_mut_region(ptr)
}
/// Transforms lifetime of the second pointer to match the first.
#[inline(always)]
#[inline]
pub unsafe fn copy_lifetime_vec<'a,S,T>(_ptr: &'a [S], ptr: &T) -> &'a T {
transmute_region(ptr)
}

View file

@ -65,14 +65,14 @@ pub fn is_XID_continue(c: char) -> bool { derived_property::XID_Continue(c) }
/// Indicates whether a character is in lower case, defined
/// in terms of the Unicode General Category 'Ll'
///
#[inline(always)]
#[inline]
pub fn is_lowercase(c: char) -> bool { general_category::Ll(c) }
///
/// Indicates whether a character is in upper case, defined
/// in terms of the Unicode General Category 'Lu'.
///
#[inline(always)]
#[inline]
pub fn is_uppercase(c: char) -> bool { general_category::Lu(c) }
///
@ -80,7 +80,7 @@ pub fn is_uppercase(c: char) -> bool { general_category::Lu(c) }
/// terms of the Unicode General Categories 'Zs', 'Zl', 'Zp'
/// additional 'Cc'-category control codes in the range [0x09, 0x0d]
///
#[inline(always)]
#[inline]
pub fn is_whitespace(c: char) -> bool {
('\x09' <= c && c <= '\x0d')
|| general_category::Zs(c)
@ -93,7 +93,7 @@ pub fn is_whitespace(c: char) -> bool {
/// defined in terms of the Unicode General Categories 'Nd', 'Nl', 'No'
/// and the Derived Core Property 'Alphabetic'.
///
#[inline(always)]
#[inline]
pub fn is_alphanumeric(c: char) -> bool {
derived_property::Alphabetic(c)
|| general_category::Nd(c)
@ -102,7 +102,7 @@ pub fn is_alphanumeric(c: char) -> bool {
}
/// Indicates whether the character is numeric (Nd, Nl, or No)
#[inline(always)]
#[inline]
pub fn is_digit(c: char) -> bool {
general_category::Nd(c)
|| general_category::Nl(c)
@ -127,7 +127,7 @@ pub fn is_digit(c: char) -> bool {
///
/// This just wraps `to_digit()`.
///
#[inline(always)]
#[inline]
pub fn is_digit_radix(c: char, radix: uint) -> bool {
match to_digit(c, radix) {
Some(_) => true,
@ -310,21 +310,21 @@ impl Char for char {
#[cfg(not(test))]
impl Eq for char {
#[inline(always)]
#[inline]
fn eq(&self, other: &char) -> bool { (*self) == (*other) }
#[inline(always)]
#[inline]
fn ne(&self, other: &char) -> bool { (*self) != (*other) }
}
#[cfg(not(test))]
impl Ord for char {
#[inline(always)]
#[inline]
fn lt(&self, other: &char) -> bool { *self < *other }
#[inline(always)]
#[inline]
fn le(&self, other: &char) -> bool { *self <= *other }
#[inline(always)]
#[inline]
fn gt(&self, other: &char) -> bool { *self > *other }
#[inline(always)]
#[inline]
fn ge(&self, other: &char) -> bool { *self >= *other }
}

View file

@ -34,25 +34,25 @@ pub trait Clone {
impl<T: Clone> Clone for ~T {
/// Return a deep copy of the owned box.
#[inline(always)]
#[inline]
fn clone(&self) -> ~T { ~(**self).clone() }
}
impl<T> Clone for @T {
/// Return a shallow copy of the managed box.
#[inline(always)]
#[inline]
fn clone(&self) -> @T { *self }
}
impl<T> Clone for @mut T {
/// Return a shallow copy of the managed box.
#[inline(always)]
#[inline]
fn clone(&self) -> @mut T { *self }
}
impl<'self, T> Clone for &'self T {
/// Return a shallow copy of the borrowed pointer.
#[inline(always)]
#[inline]
fn clone(&self) -> &'self T { *self }
}
@ -60,7 +60,7 @@ macro_rules! clone_impl(
($t:ty) => {
impl Clone for $t {
/// Return a deep copy of the value.
#[inline(always)]
#[inline]
fn clone(&self) -> $t { *self }
}
}
@ -96,7 +96,7 @@ pub trait DeepClone {
impl<T: DeepClone> DeepClone for ~T {
/// Return a deep copy of the owned box.
#[inline(always)]
#[inline]
fn deep_clone(&self) -> ~T { ~(**self).deep_clone() }
}
@ -104,7 +104,7 @@ impl<T: DeepClone> DeepClone for ~T {
impl<T: Const + DeepClone> DeepClone for @T {
/// Return a deep copy of the managed box. The `Const` trait is required to prevent performing
/// a deep clone of a potentially cyclical type.
#[inline(always)]
#[inline]
fn deep_clone(&self) -> @T { @(**self).deep_clone() }
}
@ -112,7 +112,7 @@ impl<T: Const + DeepClone> DeepClone for @T {
impl<T: Const + DeepClone> DeepClone for @mut T {
/// Return a deep copy of the managed box. The `Const` trait is required to prevent performing
/// a deep clone of a potentially cyclical type.
#[inline(always)]
#[inline]
fn deep_clone(&self) -> @mut T { @mut (**self).deep_clone() }
}
@ -120,7 +120,7 @@ macro_rules! deep_clone_impl(
($t:ty) => {
impl DeepClone for $t {
/// Return a deep copy of the value.
#[inline(always)]
#[inline]
fn deep_clone(&self) -> $t { *self }
}
}

View file

@ -45,7 +45,7 @@ pub trait TotalEq {
macro_rules! totaleq_impl(
($t:ty) => {
impl TotalEq for $t {
#[inline(always)]
#[inline]
fn equals(&self, other: &$t) -> bool { *self == *other }
}
}
@ -84,27 +84,27 @@ pub trait TotalOrd: TotalEq {
}
impl TotalOrd for Ordering {
#[inline(always)]
#[inline]
fn cmp(&self, other: &Ordering) -> Ordering {
(*self as int).cmp(&(*other as int))
}
}
impl Ord for Ordering {
#[inline(always)]
#[inline]
fn lt(&self, other: &Ordering) -> bool { (*self as int) < (*other as int) }
#[inline(always)]
#[inline]
fn le(&self, other: &Ordering) -> bool { (*self as int) <= (*other as int) }
#[inline(always)]
#[inline]
fn gt(&self, other: &Ordering) -> bool { (*self as int) > (*other as int) }
#[inline(always)]
#[inline]
fn ge(&self, other: &Ordering) -> bool { (*self as int) >= (*other as int) }
}
macro_rules! totalord_impl(
($t:ty) => {
impl TotalOrd for $t {
#[inline(always)]
#[inline]
fn cmp(&self, other: &$t) -> Ordering {
if *self < *other { Less }
else if *self > *other { Greater }
@ -146,7 +146,7 @@ Return `o1` if it is not `Equal`, otherwise `o2`. Simulates the
lexical ordering on a type `(int, int)`.
*/
// used in deriving code in libsyntax
#[inline(always)]
#[inline]
pub fn lexical_ordering(o1: Ordering, o2: Ordering) -> Ordering {
match o1 {
Equal => o2,
@ -180,12 +180,12 @@ pub trait Equiv<T> {
fn equiv(&self, other: &T) -> bool;
}
#[inline(always)]
#[inline]
pub fn min<T:Ord>(v1: T, v2: T) -> T {
if v1 < v2 { v1 } else { v2 }
}
#[inline(always)]
#[inline]
pub fn max<T:Ord>(v1: T, v2: T) -> T {
if v1 > v2 { v1 } else { v2 }
}

View file

@ -625,7 +625,7 @@ mod pipesy {
}
impl<T: Owned> GenericChan<T> for Chan<T> {
#[inline(always)]
#[inline]
fn send(&self, x: T) {
unsafe {
let self_endp = transmute_mut(&self.endp);
@ -636,7 +636,7 @@ mod pipesy {
}
impl<T: Owned> GenericSmartChan<T> for Chan<T> {
#[inline(always)]
#[inline]
fn try_send(&self, x: T) -> bool {
unsafe {
let self_endp = transmute_mut(&self.endp);
@ -653,7 +653,7 @@ mod pipesy {
}
impl<T: Owned> GenericPort<T> for Port<T> {
#[inline(always)]
#[inline]
fn recv(&self) -> T {
unsafe {
let self_endp = transmute_mut(&self.endp);
@ -664,7 +664,7 @@ mod pipesy {
}
}
#[inline(always)]
#[inline]
fn try_recv(&self) -> Option<T> {
unsafe {
let self_endp = transmute_mut(&self.endp);
@ -681,7 +681,7 @@ mod pipesy {
}
impl<T: Owned> Peekable<T> for Port<T> {
#[inline(always)]
#[inline]
fn peek(&self) -> bool {
unsafe {
let self_endp = transmute_mut(&self.endp);

View file

@ -33,7 +33,7 @@ pub enum Either<T, U> {
/// If `value` is left(T) then `f_left` is applied to its contents, if
/// `value` is right(U) then `f_right` is applied to its contents, and the
/// result is returned.
#[inline(always)]
#[inline]
pub fn either<T, U, V>(f_left: &fn(&T) -> V,
f_right: &fn(&U) -> V, value: &Either<T, U>) -> V {
match *value {
@ -83,7 +83,7 @@ pub fn partition<T, U>(eithers: ~[Either<T, U>]) -> (~[T], ~[U]) {
}
/// Flips between left and right of a given either
#[inline(always)]
#[inline]
pub fn flip<T, U>(eith: Either<T, U>) -> Either<U, T> {
match eith {
Right(r) => Left(r),
@ -95,7 +95,7 @@ pub fn flip<T, U>(eith: Either<T, U>) -> Either<U, T> {
///
/// Converts an `either` type to a `result` type, making the "right" choice
/// an ok result, and the "left" choice a fail
#[inline(always)]
#[inline]
pub fn to_result<T, U>(eith: Either<T, U>) -> Result<U, T> {
match eith {
Right(r) => result::Ok(r),
@ -104,7 +104,7 @@ pub fn to_result<T, U>(eith: Either<T, U>) -> Result<U, T> {
}
/// Checks whether the given value is a left
#[inline(always)]
#[inline]
pub fn is_left<T, U>(eith: &Either<T, U>) -> bool {
match *eith {
Left(_) => true,
@ -113,7 +113,7 @@ pub fn is_left<T, U>(eith: &Either<T, U>) -> bool {
}
/// Checks whether the given value is a right
#[inline(always)]
#[inline]
pub fn is_right<T, U>(eith: &Either<T, U>) -> bool {
match *eith {
Right(_) => true,
@ -122,7 +122,7 @@ pub fn is_right<T, U>(eith: &Either<T, U>) -> bool {
}
/// Retrieves the value in the left branch. Fails if the either is Right.
#[inline(always)]
#[inline]
pub fn unwrap_left<T,U>(eith: Either<T,U>) -> T {
match eith {
Left(x) => x,
@ -131,7 +131,7 @@ pub fn unwrap_left<T,U>(eith: Either<T,U>) -> T {
}
/// Retrieves the value in the right branch. Fails if the either is Left.
#[inline(always)]
#[inline]
pub fn unwrap_right<T,U>(eith: Either<T,U>) -> U {
match eith {
Right(x) => x,
@ -140,27 +140,27 @@ pub fn unwrap_right<T,U>(eith: Either<T,U>) -> U {
}
impl<T, U> Either<T, U> {
#[inline(always)]
#[inline]
pub fn either<V>(&self, f_left: &fn(&T) -> V, f_right: &fn(&U) -> V) -> V {
either(f_left, f_right, self)
}
#[inline(always)]
#[inline]
pub fn flip(self) -> Either<U, T> { flip(self) }
#[inline(always)]
#[inline]
pub fn to_result(self) -> Result<U, T> { to_result(self) }
#[inline(always)]
#[inline]
pub fn is_left(&self) -> bool { is_left(self) }
#[inline(always)]
#[inline]
pub fn is_right(&self) -> bool { is_right(self) }
#[inline(always)]
#[inline]
pub fn unwrap_left(self) -> T { unwrap_left(self) }
#[inline(always)]
#[inline]
pub fn unwrap_right(self) -> U { unwrap_right(self) }
}

View file

@ -64,7 +64,7 @@ pub trait HashUtil {
}
impl<A:Hash> HashUtil for A {
#[inline(always)]
#[inline]
fn hash(&self) -> u64 { self.hash_keyed(0,0) }
}
@ -79,7 +79,7 @@ pub trait Streaming {
}
impl<A:IterBytes> Hash for A {
#[inline(always)]
#[inline]
fn hash_keyed(&self, k0: u64, k1: u64) -> u64 {
let mut s = State::new(k0, k1);
for self.iter_bytes(true) |bytes| {
@ -176,7 +176,7 @@ fn hash_keyed_5<A: IterBytes,
s.result_u64()
}
#[inline(always)]
#[inline]
pub fn default_state() -> State {
State::new(0, 0)
}
@ -194,7 +194,7 @@ struct SipState {
}
impl SipState {
#[inline(always)]
#[inline]
fn new(key0: u64, key1: u64) -> SipState {
let mut state = SipState {
k0: key0,
@ -248,7 +248,7 @@ macro_rules! compress (
impl Writer for SipState {
// Methods for io::writer
#[inline(always)]
#[inline]
fn write(&mut self, msg: &[u8]) {
let length = msg.len();
self.length += length;
@ -315,12 +315,12 @@ impl Writer for SipState {
}
impl Streaming for SipState {
#[inline(always)]
#[inline]
fn input(&mut self, buf: &[u8]) {
self.write(buf);
}
#[inline(always)]
#[inline]
fn result_u64(&mut self) -> u64 {
let mut v0 = self.v0;
let mut v1 = self.v1;
@ -373,7 +373,7 @@ impl Streaming for SipState {
s
}
#[inline(always)]
#[inline]
fn reset(&mut self) {
self.length = 0;
self.v0 = self.k0 ^ 0x736f6d6570736575;

View file

@ -59,7 +59,7 @@ enum SearchResult {
FoundEntry(uint), FoundHole(uint), TableFull
}
#[inline(always)]
#[inline]
fn resize_at(capacity: uint) -> uint {
((capacity as float) * 3. / 4.) as uint
}
@ -85,19 +85,19 @@ fn linear_map_with_capacity_and_keys<K:Eq + Hash,V>(
}
impl<K:Hash + Eq,V> HashMap<K, V> {
#[inline(always)]
#[inline]
fn to_bucket(&self, h: uint) -> uint {
// A good hash function with entropy spread over all of the
// bits is assumed. SipHash is more than good enough.
h % self.buckets.len()
}
#[inline(always)]
#[inline]
fn next_bucket(&self, idx: uint, len_buckets: uint) -> uint {
(idx + 1) % len_buckets
}
#[inline(always)]
#[inline]
fn bucket_sequence(&self, hash: uint,
op: &fn(uint) -> bool) -> bool {
let start_idx = self.to_bucket(hash);
@ -112,20 +112,20 @@ impl<K:Hash + Eq,V> HashMap<K, V> {
}
}
#[inline(always)]
#[inline]
fn bucket_for_key(&self, k: &K) -> SearchResult {
let hash = k.hash_keyed(self.k0, self.k1) as uint;
self.bucket_for_key_with_hash(hash, k)
}
#[inline(always)]
#[inline]
fn bucket_for_key_equiv<Q:Hash + Equiv<K>>(&self, k: &Q)
-> SearchResult {
let hash = k.hash_keyed(self.k0, self.k1) as uint;
self.bucket_for_key_with_hash_equiv(hash, k)
}
#[inline(always)]
#[inline]
fn bucket_for_key_with_hash(&self,
hash: uint,
k: &K)
@ -141,7 +141,7 @@ impl<K:Hash + Eq,V> HashMap<K, V> {
TableFull
}
#[inline(always)]
#[inline]
fn bucket_for_key_with_hash_equiv<Q:Equiv<K>>(&self,
hash: uint,
k: &Q)
@ -161,7 +161,7 @@ impl<K:Hash + Eq,V> HashMap<K, V> {
/// Expand the capacity of the array to the next power of two
/// and re-insert each of the existing buckets.
#[inline(always)]
#[inline]
fn expand(&mut self) {
let new_capacity = self.buckets.len() * 2;
self.resize(new_capacity);
@ -190,7 +190,7 @@ impl<K:Hash + Eq,V> HashMap<K, V> {
}
}
#[inline(always)]
#[inline]
fn value_for_bucket<'a>(&'a self, idx: uint) -> &'a V {
match self.buckets[idx] {
Some(ref bkt) => &bkt.value,
@ -198,7 +198,7 @@ impl<K:Hash + Eq,V> HashMap<K, V> {
}
}
#[inline(always)]
#[inline]
fn mut_value_for_bucket<'a>(&'a mut self, idx: uint) -> &'a mut V {
match self.buckets[idx] {
Some(ref mut bkt) => &mut bkt.value,

View file

@ -73,7 +73,7 @@ pub trait FromIter<T> {
* assert!(!any(|&x: &uint| x > 5, |f| xs.each(f)));
* ~~~
*/
#[inline(always)]
#[inline]
pub fn any<T>(predicate: &fn(T) -> bool,
iter: &fn(f: &fn(T) -> bool) -> bool) -> bool {
for iter |x| {
@ -94,7 +94,7 @@ pub fn any<T>(predicate: &fn(T) -> bool,
* assert!(!all(|&x: &uint| x < 5, |f| uint::range(1, 6, f)));
* ~~~
*/
#[inline(always)]
#[inline]
pub fn all<T>(predicate: &fn(T) -> bool,
iter: &fn(f: &fn(T) -> bool) -> bool) -> bool {
// If we ever break, iter will return false, so this will only return true
@ -112,7 +112,7 @@ pub fn all<T>(predicate: &fn(T) -> bool,
* assert_eq!(*find(|& &x: & &uint| x > 3, |f| xs.each(f)).unwrap(), 4);
* ~~~
*/
#[inline(always)]
#[inline]
pub fn find<T>(predicate: &fn(&T) -> bool,
iter: &fn(f: &fn(T) -> bool) -> bool) -> Option<T> {
for iter |x| {
@ -226,7 +226,7 @@ pub fn fold_ref<T, U>(start: T, iter: &fn(f: &fn(&U) -> bool) -> bool, f: &fn(&m
* assert_eq!(do sum |f| { xs.each(f) }, 10);
* ~~~
*/
#[inline(always)]
#[inline]
pub fn sum<T: Zero + Add<T, T>>(iter: &fn(f: &fn(&T) -> bool) -> bool) -> T {
fold_ref(Zero::zero::<T>(), iter, |a, x| *a = a.add(x))
}
@ -241,7 +241,7 @@ pub fn sum<T: Zero + Add<T, T>>(iter: &fn(f: &fn(&T) -> bool) -> bool) -> T {
* assert_eq!(do product |f| { xs.each(f) }, 24);
* ~~~
*/
#[inline(always)]
#[inline]
pub fn product<T: One + Mul<T, T>>(iter: &fn(f: &fn(&T) -> bool) -> bool) -> T {
fold_ref(One::one::<T>(), iter, |a, x| *a = a.mul(x))
}

View file

@ -321,59 +321,59 @@ pub trait IteratorUtil<A> {
///
/// In the future these will be default methods instead of a utility trait.
impl<A, T: Iterator<A>> IteratorUtil<A> for T {
#[inline(always)]
#[inline]
fn chain_<U: Iterator<A>>(self, other: U) -> ChainIterator<A, T, U> {
ChainIterator{a: self, b: other, flag: false}
}
#[inline(always)]
#[inline]
fn zip<B, U: Iterator<B>>(self, other: U) -> ZipIterator<A, T, B, U> {
ZipIterator{a: self, b: other}
}
// FIXME: #5898: should be called map
#[inline(always)]
#[inline]
fn transform<'r, B>(self, f: &'r fn(A) -> B) -> MapIterator<'r, A, B, T> {
MapIterator{iter: self, f: f}
}
#[inline(always)]
#[inline]
fn filter<'r>(self, predicate: &'r fn(&A) -> bool) -> FilterIterator<'r, A, T> {
FilterIterator{iter: self, predicate: predicate}
}
#[inline(always)]
#[inline]
fn filter_map<'r, B>(self, f: &'r fn(A) -> Option<B>) -> FilterMapIterator<'r, A, B, T> {
FilterMapIterator { iter: self, f: f }
}
#[inline(always)]
#[inline]
fn enumerate(self) -> EnumerateIterator<A, T> {
EnumerateIterator{iter: self, count: 0}
}
#[inline(always)]
#[inline]
fn skip_while<'r>(self, predicate: &'r fn(&A) -> bool) -> SkipWhileIterator<'r, A, T> {
SkipWhileIterator{iter: self, flag: false, predicate: predicate}
}
#[inline(always)]
#[inline]
fn take_while<'r>(self, predicate: &'r fn(&A) -> bool) -> TakeWhileIterator<'r, A, T> {
TakeWhileIterator{iter: self, flag: false, predicate: predicate}
}
#[inline(always)]
#[inline]
fn skip(self, n: uint) -> SkipIterator<A, T> {
SkipIterator{iter: self, n: n}
}
// FIXME: #5898: should be called take
#[inline(always)]
#[inline]
fn take_(self, n: uint) -> TakeIterator<A, T> {
TakeIterator{iter: self, n: n}
}
#[inline(always)]
#[inline]
fn scan<'r, St, B>(self, initial_state: St, f: &'r fn(&mut St, A) -> Option<B>)
-> ScanIterator<'r, A, B, T, St> {
ScanIterator{iter: self, f: f, state: initial_state}
@ -392,13 +392,13 @@ impl<A, T: Iterator<A>> IteratorUtil<A> for T {
}
}
#[inline(always)]
#[inline]
fn collect<B: FromIter<A>>(&mut self) -> B {
FromIter::from_iter::<A, B>(|f| self.advance(f))
}
/// Return the `n`th item yielded by an iterator.
#[inline(always)]
#[inline]
fn nth(&mut self, mut n: uint) -> Option<A> {
loop {
match self.next() {
@ -410,7 +410,7 @@ impl<A, T: Iterator<A>> IteratorUtil<A> for T {
}
/// Return the last item yielded by an iterator.
#[inline(always)]
#[inline]
fn last_(&mut self) -> Option<A> {
let mut last = None;
for self.advance |x| { last = Some(x); }
@ -431,23 +431,23 @@ impl<A, T: Iterator<A>> IteratorUtil<A> for T {
}
/// Count the number of items yielded by an iterator
#[inline(always)]
#[inline]
fn count(&mut self) -> uint { self.fold(0, |cnt, _x| cnt + 1) }
#[inline(always)]
#[inline]
fn all(&mut self, f: &fn(A) -> bool) -> bool {
for self.advance |x| { if !f(x) { return false; } }
true
}
#[inline(always)]
#[inline]
fn any_(&mut self, f: &fn(A) -> bool) -> bool {
for self.advance |x| { if f(x) { return true; } }
false
}
/// Return the first element satisfying the specified predicate
#[inline(always)]
#[inline]
fn find_(&mut self, predicate: &fn(&A) -> bool) -> Option<A> {
for self.advance |x| {
if predicate(&x) { return Some(x) }
@ -484,7 +484,7 @@ pub trait AdditiveIterator<A> {
}
impl<A: Add<A, A> + Zero, T: Iterator<A>> AdditiveIterator<A> for T {
#[inline(always)]
#[inline]
fn sum(&mut self) -> A { self.fold(Zero::zero::<A>(), |s, x| s + x) }
}
@ -509,7 +509,7 @@ pub trait MultiplicativeIterator<A> {
}
impl<A: Mul<A, A> + One, T: Iterator<A>> MultiplicativeIterator<A> for T {
#[inline(always)]
#[inline]
fn product(&mut self) -> A { self.fold(One::one::<A>(), |p, x| p * x) }
}
@ -538,7 +538,7 @@ pub trait OrdIterator<A> {
}
impl<A: Ord, T: Iterator<A>> OrdIterator<A> for T {
#[inline(always)]
#[inline]
fn max(&mut self) -> Option<A> {
self.fold(None, |max, x| {
match max {
@ -548,7 +548,7 @@ impl<A: Ord, T: Iterator<A>> OrdIterator<A> for T {
})
}
#[inline(always)]
#[inline]
fn min(&mut self) -> Option<A> {
self.fold(None, |min, x| {
match min {
@ -843,14 +843,14 @@ pub struct Counter<A> {
impl<A> Counter<A> {
/// Creates a new counter with the specified start/step
#[inline(always)]
#[inline]
pub fn new(start: A, step: A) -> Counter<A> {
Counter{state: start, step: step}
}
}
impl<A: Add<A, A> + Clone> Iterator<A> for Counter<A> {
#[inline(always)]
#[inline]
fn next(&mut self) -> Option<A> {
let result = self.state.clone();
self.state = self.state.add(&self.step); // FIXME: #6050

View file

@ -1457,11 +1457,11 @@ pub mod funcs {
// These are fine to execute on the Rust stack. They must be,
// in fact, because LLVM generates calls to them!
#[rust_stack]
#[inline(always)]
#[inline]
unsafe fn memcmp(cx: *c_void, ct: *c_void, n: size_t)
-> c_int;
#[rust_stack]
#[inline(always)]
#[inline]
unsafe fn memchr(cx: *c_void, c: c_int, n: size_t) -> *c_void;
}
}

View file

@ -38,14 +38,14 @@ pub mod raw {
}
/// Determine if two shared boxes point to the same object
#[inline(always)]
#[inline]
pub fn ptr_eq<T>(a: @T, b: @T) -> bool {
let (a_ptr, b_ptr): (*T, *T) = (to_unsafe_ptr(&*a), to_unsafe_ptr(&*b));
a_ptr == b_ptr
}
/// Determine if two mutable shared boxes point to the same object
#[inline(always)]
#[inline]
pub fn mut_ptr_eq<T>(a: @mut T, b: @mut T) -> bool {
let (a_ptr, b_ptr): (*T, *T) = (to_unsafe_ptr(&*a), to_unsafe_ptr(&*b));
a_ptr == b_ptr
@ -53,41 +53,41 @@ pub fn mut_ptr_eq<T>(a: @mut T, b: @mut T) -> bool {
#[cfg(not(test))]
impl<T:Eq> Eq for @T {
#[inline(always)]
#[inline]
fn eq(&self, other: &@T) -> bool { *(*self) == *(*other) }
#[inline(always)]
#[inline]
fn ne(&self, other: &@T) -> bool { *(*self) != *(*other) }
}
#[cfg(not(test))]
impl<T:Eq> Eq for @mut T {
#[inline(always)]
#[inline]
fn eq(&self, other: &@mut T) -> bool { *(*self) == *(*other) }
#[inline(always)]
#[inline]
fn ne(&self, other: &@mut T) -> bool { *(*self) != *(*other) }
}
#[cfg(not(test))]
impl<T:Ord> Ord for @T {
#[inline(always)]
#[inline]
fn lt(&self, other: &@T) -> bool { *(*self) < *(*other) }
#[inline(always)]
#[inline]
fn le(&self, other: &@T) -> bool { *(*self) <= *(*other) }
#[inline(always)]
#[inline]
fn ge(&self, other: &@T) -> bool { *(*self) >= *(*other) }
#[inline(always)]
#[inline]
fn gt(&self, other: &@T) -> bool { *(*self) > *(*other) }
}
#[cfg(not(test))]
impl<T:Ord> Ord for @mut T {
#[inline(always)]
#[inline]
fn lt(&self, other: &@mut T) -> bool { *(*self) < *(*other) }
#[inline(always)]
#[inline]
fn le(&self, other: &@mut T) -> bool { *(*self) <= *(*other) }
#[inline(always)]
#[inline]
fn ge(&self, other: &@mut T) -> bool { *(*self) >= *(*other) }
#[inline(always)]
#[inline]
fn gt(&self, other: &@mut T) -> bool { *(*self) > *(*other) }
}

View file

@ -19,32 +19,32 @@ use prelude::*;
#[cfg(not(test))]
impl Eq for () {
#[inline(always)]
#[inline]
fn eq(&self, _other: &()) -> bool { true }
#[inline(always)]
#[inline]
fn ne(&self, _other: &()) -> bool { false }
}
#[cfg(not(test))]
impl Ord for () {
#[inline(always)]
#[inline]
fn lt(&self, _other: &()) -> bool { false }
#[inline(always)]
#[inline]
fn le(&self, _other: &()) -> bool { true }
#[inline(always)]
#[inline]
fn ge(&self, _other: &()) -> bool { true }
#[inline(always)]
#[inline]
fn gt(&self, _other: &()) -> bool { false }
}
#[cfg(not(test))]
impl TotalOrd for () {
#[inline(always)]
#[inline]
fn cmp(&self, _other: &()) -> Ordering { Equal }
}
#[cfg(not(test))]
impl TotalEq for () {
#[inline(always)]
#[inline]
fn equals(&self, _other: &()) -> bool { true }
}

View file

@ -20,7 +20,7 @@ use to_str;
pub use cmath::c_float_targ_consts::*;
// An inner module is required to get the #[inline(always)] attribute on the
// An inner module is required to get the #[inline] attribute on the
// functions.
pub use self::delegated::*;
@ -40,7 +40,7 @@ macro_rules! delegate(
use unstable::intrinsics;
$(
#[inline(always)]
#[inline]
pub fn $name($( $arg : $arg_ty ),*) -> $rv {
unsafe {
$bound_name($( $arg ),*)
@ -115,45 +115,45 @@ pub static infinity: f32 = 1.0_f32/0.0_f32;
pub static neg_infinity: f32 = -1.0_f32/0.0_f32;
#[inline(always)]
#[inline]
pub fn add(x: f32, y: f32) -> f32 { return x + y; }
#[inline(always)]
#[inline]
pub fn sub(x: f32, y: f32) -> f32 { return x - y; }
#[inline(always)]
#[inline]
pub fn mul(x: f32, y: f32) -> f32 { return x * y; }
#[inline(always)]
#[inline]
pub fn div(x: f32, y: f32) -> f32 { return x / y; }
#[inline(always)]
#[inline]
pub fn rem(x: f32, y: f32) -> f32 { return x % y; }
#[inline(always)]
#[inline]
pub fn lt(x: f32, y: f32) -> bool { return x < y; }
#[inline(always)]
#[inline]
pub fn le(x: f32, y: f32) -> bool { return x <= y; }
#[inline(always)]
#[inline]
pub fn eq(x: f32, y: f32) -> bool { return x == y; }
#[inline(always)]
#[inline]
pub fn ne(x: f32, y: f32) -> bool { return x != y; }
#[inline(always)]
#[inline]
pub fn ge(x: f32, y: f32) -> bool { return x >= y; }
#[inline(always)]
#[inline]
pub fn gt(x: f32, y: f32) -> bool { return x > y; }
#[inline(always)]
#[inline]
pub fn fmax(x: f32, y: f32) -> f32 {
if x >= y || y.is_NaN() { x } else { y }
}
#[inline(always)]
#[inline]
pub fn fmin(x: f32, y: f32) -> f32 {
if x <= y || y.is_NaN() { x } else { y }
}
@ -212,23 +212,23 @@ impl Num for f32 {}
#[cfg(not(test))]
impl Eq for f32 {
#[inline(always)]
#[inline]
fn eq(&self, other: &f32) -> bool { (*self) == (*other) }
#[inline(always)]
#[inline]
fn ne(&self, other: &f32) -> bool { (*self) != (*other) }
}
#[cfg(not(test))]
impl ApproxEq<f32> for f32 {
#[inline(always)]
#[inline]
fn approx_epsilon() -> f32 { 1.0e-6 }
#[inline(always)]
#[inline]
fn approx_eq(&self, other: &f32) -> bool {
self.approx_eq_eps(other, &ApproxEq::approx_epsilon::<f32, f32>())
}
#[inline(always)]
#[inline]
fn approx_eq_eps(&self, other: &f32, approx_epsilon: &f32) -> bool {
(*self - *other).abs() < *approx_epsilon
}
@ -236,32 +236,32 @@ impl ApproxEq<f32> for f32 {
#[cfg(not(test))]
impl Ord for f32 {
#[inline(always)]
#[inline]
fn lt(&self, other: &f32) -> bool { (*self) < (*other) }
#[inline(always)]
#[inline]
fn le(&self, other: &f32) -> bool { (*self) <= (*other) }
#[inline(always)]
#[inline]
fn ge(&self, other: &f32) -> bool { (*self) >= (*other) }
#[inline(always)]
#[inline]
fn gt(&self, other: &f32) -> bool { (*self) > (*other) }
}
impl Orderable for f32 {
/// Returns `NaN` if either of the numbers are `NaN`.
#[inline(always)]
#[inline]
fn min(&self, other: &f32) -> f32 {
if self.is_NaN() || other.is_NaN() { Float::NaN() } else { fmin(*self, *other) }
}
/// Returns `NaN` if either of the numbers are `NaN`.
#[inline(always)]
#[inline]
fn max(&self, other: &f32) -> f32 {
if self.is_NaN() || other.is_NaN() { Float::NaN() } else { fmax(*self, *other) }
}
/// Returns the number constrained within the range `mn <= self <= mx`.
/// If any of the numbers are `NaN` then `NaN` is returned.
#[inline(always)]
#[inline]
fn clamp(&self, mn: &f32, mx: &f32) -> f32 {
cond!(
(self.is_NaN()) { *self }
@ -273,65 +273,65 @@ impl Orderable for f32 {
}
impl Zero for f32 {
#[inline(always)]
#[inline]
fn zero() -> f32 { 0.0 }
/// Returns true if the number is equal to either `0.0` or `-0.0`
#[inline(always)]
#[inline]
fn is_zero(&self) -> bool { *self == 0.0 || *self == -0.0 }
}
impl One for f32 {
#[inline(always)]
#[inline]
fn one() -> f32 { 1.0 }
}
#[cfg(not(test))]
impl Add<f32,f32> for f32 {
#[inline(always)]
#[inline]
fn add(&self, other: &f32) -> f32 { *self + *other }
}
#[cfg(not(test))]
impl Sub<f32,f32> for f32 {
#[inline(always)]
#[inline]
fn sub(&self, other: &f32) -> f32 { *self - *other }
}
#[cfg(not(test))]
impl Mul<f32,f32> for f32 {
#[inline(always)]
#[inline]
fn mul(&self, other: &f32) -> f32 { *self * *other }
}
#[cfg(not(test))]
impl Div<f32,f32> for f32 {
#[inline(always)]
#[inline]
fn div(&self, other: &f32) -> f32 { *self / *other }
}
#[cfg(not(test))]
impl Rem<f32,f32> for f32 {
#[inline(always)]
#[inline]
fn rem(&self, other: &f32) -> f32 { *self % *other }
}
#[cfg(not(test))]
impl Neg<f32> for f32 {
#[inline(always)]
#[inline]
fn neg(&self) -> f32 { -*self }
}
impl Signed for f32 {
/// Computes the absolute value. Returns `NaN` if the number is `NaN`.
#[inline(always)]
#[inline]
fn abs(&self) -> f32 { abs(*self) }
///
/// The positive difference of two numbers. Returns `0.0` if the number is less than or
/// equal to `other`, otherwise the difference between`self` and `other` is returned.
///
#[inline(always)]
#[inline]
fn abs_sub(&self, other: &f32) -> f32 { abs_sub(*self, *other) }
///
@ -341,35 +341,35 @@ impl Signed for f32 {
/// - `-1.0` if the number is negative, `-0.0` or `neg_infinity`
/// - `NaN` if the number is NaN
///
#[inline(always)]
#[inline]
fn signum(&self) -> f32 {
if self.is_NaN() { NaN } else { copysign(1.0, *self) }
}
/// Returns `true` if the number is positive, including `+0.0` and `infinity`
#[inline(always)]
#[inline]
fn is_positive(&self) -> bool { *self > 0.0 || (1.0 / *self) == infinity }
/// Returns `true` if the number is negative, including `-0.0` and `neg_infinity`
#[inline(always)]
#[inline]
fn is_negative(&self) -> bool { *self < 0.0 || (1.0 / *self) == neg_infinity }
}
impl Round for f32 {
/// Round half-way cases toward `neg_infinity`
#[inline(always)]
#[inline]
fn floor(&self) -> f32 { floor(*self) }
/// Round half-way cases toward `infinity`
#[inline(always)]
#[inline]
fn ceil(&self) -> f32 { ceil(*self) }
/// Round half-way cases away from `0.0`
#[inline(always)]
#[inline]
fn round(&self) -> f32 { round(*self) }
/// The integer part of the number (rounds towards `0.0`)
#[inline(always)]
#[inline]
fn trunc(&self) -> f32 { trunc(*self) }
///
@ -379,57 +379,57 @@ impl Round for f32 {
/// assert!(x == trunc(x) + fract(x))
/// ~~~
///
#[inline(always)]
#[inline]
fn fract(&self) -> f32 { *self - self.trunc() }
}
impl Fractional for f32 {
/// The reciprocal (multiplicative inverse) of the number
#[inline(always)]
#[inline]
fn recip(&self) -> f32 { 1.0 / *self }
}
impl Algebraic for f32 {
#[inline(always)]
#[inline]
fn pow(&self, n: &f32) -> f32 { pow(*self, *n) }
#[inline(always)]
#[inline]
fn sqrt(&self) -> f32 { sqrt(*self) }
#[inline(always)]
#[inline]
fn rsqrt(&self) -> f32 { self.sqrt().recip() }
#[inline(always)]
#[inline]
fn cbrt(&self) -> f32 { cbrt(*self) }
#[inline(always)]
#[inline]
fn hypot(&self, other: &f32) -> f32 { hypot(*self, *other) }
}
impl Trigonometric for f32 {
#[inline(always)]
#[inline]
fn sin(&self) -> f32 { sin(*self) }
#[inline(always)]
#[inline]
fn cos(&self) -> f32 { cos(*self) }
#[inline(always)]
#[inline]
fn tan(&self) -> f32 { tan(*self) }
#[inline(always)]
#[inline]
fn asin(&self) -> f32 { asin(*self) }
#[inline(always)]
#[inline]
fn acos(&self) -> f32 { acos(*self) }
#[inline(always)]
#[inline]
fn atan(&self) -> f32 { atan(*self) }
#[inline(always)]
#[inline]
fn atan2(&self, other: &f32) -> f32 { atan2(*self, *other) }
/// Simultaneously computes the sine and cosine of the number
#[inline(always)]
#[inline]
fn sin_cos(&self) -> (f32, f32) {
(self.sin(), self.cos())
}
@ -437,38 +437,38 @@ impl Trigonometric for f32 {
impl Exponential for f32 {
/// Returns the exponential of the number
#[inline(always)]
#[inline]
fn exp(&self) -> f32 { exp(*self) }
/// Returns 2 raised to the power of the number
#[inline(always)]
#[inline]
fn exp2(&self) -> f32 { exp2(*self) }
/// Returns the natural logarithm of the number
#[inline(always)]
#[inline]
fn ln(&self) -> f32 { ln(*self) }
/// Returns the logarithm of the number with respect to an arbitrary base
#[inline(always)]
#[inline]
fn log(&self, base: &f32) -> f32 { self.ln() / base.ln() }
/// Returns the base 2 logarithm of the number
#[inline(always)]
#[inline]
fn log2(&self) -> f32 { log2(*self) }
/// Returns the base 10 logarithm of the number
#[inline(always)]
#[inline]
fn log10(&self) -> f32 { log10(*self) }
}
impl Hyperbolic for f32 {
#[inline(always)]
#[inline]
fn sinh(&self) -> f32 { sinh(*self) }
#[inline(always)]
#[inline]
fn cosh(&self) -> f32 { cosh(*self) }
#[inline(always)]
#[inline]
fn tanh(&self) -> f32 { tanh(*self) }
///
@ -480,7 +480,7 @@ impl Hyperbolic for f32 {
/// - `self` if `self` is `0.0`, `-0.0`, `infinity`, or `neg_infinity`
/// - `NaN` if `self` is `NaN`
///
#[inline(always)]
#[inline]
fn asinh(&self) -> f32 {
match *self {
neg_infinity => neg_infinity,
@ -497,7 +497,7 @@ impl Hyperbolic for f32 {
/// - `infinity` if `self` is `infinity`
/// - `NaN` if `self` is `NaN` or `self < 1.0` (including `neg_infinity`)
///
#[inline(always)]
#[inline]
fn acosh(&self) -> f32 {
match *self {
x if x < 1.0 => Float::NaN(),
@ -517,7 +517,7 @@ impl Hyperbolic for f32 {
/// - `NaN` if the `self` is `NaN` or outside the domain of `-1.0 <= self <= 1.0`
/// (including `infinity` and `neg_infinity`)
///
#[inline(always)]
#[inline]
fn atanh(&self) -> f32 {
0.5 * ((2.0 * *self) / (1.0 - *self)).ln_1p()
}
@ -525,129 +525,129 @@ impl Hyperbolic for f32 {
impl Real for f32 {
/// Archimedes' constant
#[inline(always)]
#[inline]
fn pi() -> f32 { 3.14159265358979323846264338327950288 }
/// 2.0 * pi
#[inline(always)]
#[inline]
fn two_pi() -> f32 { 6.28318530717958647692528676655900576 }
/// pi / 2.0
#[inline(always)]
#[inline]
fn frac_pi_2() -> f32 { 1.57079632679489661923132169163975144 }
/// pi / 3.0
#[inline(always)]
#[inline]
fn frac_pi_3() -> f32 { 1.04719755119659774615421446109316763 }
/// pi / 4.0
#[inline(always)]
#[inline]
fn frac_pi_4() -> f32 { 0.785398163397448309615660845819875721 }
/// pi / 6.0
#[inline(always)]
#[inline]
fn frac_pi_6() -> f32 { 0.52359877559829887307710723054658381 }
/// pi / 8.0
#[inline(always)]
#[inline]
fn frac_pi_8() -> f32 { 0.39269908169872415480783042290993786 }
/// 1 .0/ pi
#[inline(always)]
#[inline]
fn frac_1_pi() -> f32 { 0.318309886183790671537767526745028724 }
/// 2.0 / pi
#[inline(always)]
#[inline]
fn frac_2_pi() -> f32 { 0.636619772367581343075535053490057448 }
/// 2.0 / sqrt(pi)
#[inline(always)]
#[inline]
fn frac_2_sqrtpi() -> f32 { 1.12837916709551257389615890312154517 }
/// sqrt(2.0)
#[inline(always)]
#[inline]
fn sqrt2() -> f32 { 1.41421356237309504880168872420969808 }
/// 1.0 / sqrt(2.0)
#[inline(always)]
#[inline]
fn frac_1_sqrt2() -> f32 { 0.707106781186547524400844362104849039 }
/// Euler's number
#[inline(always)]
#[inline]
fn e() -> f32 { 2.71828182845904523536028747135266250 }
/// log2(e)
#[inline(always)]
#[inline]
fn log2_e() -> f32 { 1.44269504088896340735992468100189214 }
/// log10(e)
#[inline(always)]
#[inline]
fn log10_e() -> f32 { 0.434294481903251827651128918916605082 }
/// ln(2.0)
#[inline(always)]
#[inline]
fn ln_2() -> f32 { 0.693147180559945309417232121458176568 }
/// ln(10.0)
#[inline(always)]
#[inline]
fn ln_10() -> f32 { 2.30258509299404568401799145468436421 }
/// Converts to degrees, assuming the number is in radians
#[inline(always)]
#[inline]
fn to_degrees(&self) -> f32 { *self * (180.0 / Real::pi::<f32>()) }
/// Converts to radians, assuming the number is in degrees
#[inline(always)]
#[inline]
fn to_radians(&self) -> f32 { *self * (Real::pi::<f32>() / 180.0) }
}
impl Bounded for f32 {
#[inline(always)]
#[inline]
fn min_value() -> f32 { 1.17549435e-38 }
#[inline(always)]
#[inline]
fn max_value() -> f32 { 3.40282347e+38 }
}
impl Primitive for f32 {
#[inline(always)]
#[inline]
fn bits() -> uint { 32 }
#[inline(always)]
#[inline]
fn bytes() -> uint { Primitive::bits::<f32>() / 8 }
}
impl Float for f32 {
#[inline(always)]
#[inline]
fn NaN() -> f32 { 0.0 / 0.0 }
#[inline(always)]
#[inline]
fn infinity() -> f32 { 1.0 / 0.0 }
#[inline(always)]
#[inline]
fn neg_infinity() -> f32 { -1.0 / 0.0 }
#[inline(always)]
#[inline]
fn neg_zero() -> f32 { -0.0 }
/// Returns `true` if the number is NaN
#[inline(always)]
#[inline]
fn is_NaN(&self) -> bool { *self != *self }
/// Returns `true` if the number is infinite
#[inline(always)]
#[inline]
fn is_infinite(&self) -> bool {
*self == Float::infinity() || *self == Float::neg_infinity()
}
/// Returns `true` if the number is neither infinite or NaN
#[inline(always)]
#[inline]
fn is_finite(&self) -> bool {
!(self.is_NaN() || self.is_infinite())
}
/// Returns `true` if the number is neither zero, infinite, subnormal or NaN
#[inline(always)]
#[inline]
fn is_normal(&self) -> bool {
self.classify() == FPNormal
}
@ -670,29 +670,29 @@ impl Float for f32 {
}
}
#[inline(always)]
#[inline]
fn mantissa_digits() -> uint { 24 }
#[inline(always)]
#[inline]
fn digits() -> uint { 6 }
#[inline(always)]
#[inline]
fn epsilon() -> f32 { 1.19209290e-07 }
#[inline(always)]
#[inline]
fn min_exp() -> int { -125 }
#[inline(always)]
#[inline]
fn max_exp() -> int { 128 }
#[inline(always)]
#[inline]
fn min_10_exp() -> int { -37 }
#[inline(always)]
#[inline]
fn max_10_exp() -> int { 38 }
/// Constructs a floating point number by multiplying `x` by 2 raised to the power of `exp`
#[inline(always)]
#[inline]
fn ldexp(x: f32, exp: int) -> f32 {
ldexp(x, exp as c_int)
}
@ -703,7 +703,7 @@ impl Float for f32 {
/// - `self = x * pow(2, exp)`
/// - `0.5 <= abs(x) < 1.0`
///
#[inline(always)]
#[inline]
fn frexp(&self) -> (f32, int) {
let mut exp = 0;
let x = frexp(*self, &mut exp);
@ -714,14 +714,14 @@ impl Float for f32 {
/// Returns the exponential of the number, minus `1`, in a way that is accurate
/// even if the number is close to zero
///
#[inline(always)]
#[inline]
fn exp_m1(&self) -> f32 { exp_m1(*self) }
///
/// Returns the natural logarithm of the number plus `1` (`ln(1+n)`) more accurately
/// than if the operations were performed separately
///
#[inline(always)]
#[inline]
fn ln_1p(&self) -> f32 { ln_1p(*self) }
///
@ -729,13 +729,13 @@ impl Float for f32 {
/// produces a more accurate result with better performance than a separate multiplication
/// operation followed by an add.
///
#[inline(always)]
#[inline]
fn mul_add(&self, a: f32, b: f32) -> f32 {
mul_add(*self, a, b)
}
/// Returns the next representable floating-point value in the direction of `other`
#[inline(always)]
#[inline]
fn next_after(&self, other: f32) -> f32 {
next_after(*self, other)
}
@ -752,7 +752,7 @@ impl Float for f32 {
///
/// * num - The float value
///
#[inline(always)]
#[inline]
pub fn to_str(num: f32) -> ~str {
let (r, _) = strconv::to_str_common(
&num, 10u, true, strconv::SignNeg, strconv::DigAll);
@ -766,7 +766,7 @@ pub fn to_str(num: f32) -> ~str {
///
/// * num - The float value
///
#[inline(always)]
#[inline]
pub fn to_str_hex(num: f32) -> ~str {
let (r, _) = strconv::to_str_common(
&num, 16u, true, strconv::SignNeg, strconv::DigAll);
@ -787,7 +787,7 @@ pub fn to_str_hex(num: f32) -> ~str {
/// possible misinterpretation of the result at higher bases. If those values
/// are expected, use `to_str_radix_special()` instead.
///
#[inline(always)]
#[inline]
pub fn to_str_radix(num: f32, rdx: uint) -> ~str {
let (r, special) = strconv::to_str_common(
&num, rdx, true, strconv::SignNeg, strconv::DigAll);
@ -805,7 +805,7 @@ pub fn to_str_radix(num: f32, rdx: uint) -> ~str {
/// * num - The float value
/// * radix - The base to use
///
#[inline(always)]
#[inline]
pub fn to_str_radix_special(num: f32, rdx: uint) -> (~str, bool) {
strconv::to_str_common(&num, rdx, true,
strconv::SignNeg, strconv::DigAll)
@ -820,7 +820,7 @@ pub fn to_str_radix_special(num: f32, rdx: uint) -> (~str, bool) {
/// * num - The float value
/// * digits - The number of significant digits
///
#[inline(always)]
#[inline]
pub fn to_str_exact(num: f32, dig: uint) -> ~str {
let (r, _) = strconv::to_str_common(
&num, 10u, true, strconv::SignNeg, strconv::DigExact(dig));
@ -836,7 +836,7 @@ pub fn to_str_exact(num: f32, dig: uint) -> ~str {
/// * num - The float value
/// * digits - The number of significant digits
///
#[inline(always)]
#[inline]
pub fn to_str_digits(num: f32, dig: uint) -> ~str {
let (r, _) = strconv::to_str_common(
&num, 10u, true, strconv::SignNeg, strconv::DigMax(dig));
@ -844,12 +844,12 @@ pub fn to_str_digits(num: f32, dig: uint) -> ~str {
}
impl to_str::ToStr for f32 {
#[inline(always)]
#[inline]
fn to_str(&self) -> ~str { to_str_digits(*self, 8) }
}
impl num::ToStrRadix for f32 {
#[inline(always)]
#[inline]
fn to_str_radix(&self, rdx: uint) -> ~str {
to_str_radix(*self, rdx)
}
@ -882,7 +882,7 @@ impl num::ToStrRadix for f32 {
/// `none` if the string did not represent a valid number. Otherwise,
/// `Some(n)` where `n` is the floating-point number represented by `num`.
///
#[inline(always)]
#[inline]
pub fn from_str(num: &str) -> Option<f32> {
strconv::from_str_common(num, 10u, true, true, true,
strconv::ExpDec, false, false)
@ -915,7 +915,7 @@ pub fn from_str(num: &str) -> Option<f32> {
/// `none` if the string did not represent a valid number. Otherwise,
/// `Some(n)` where `n` is the floating-point number represented by `[num]`.
///
#[inline(always)]
#[inline]
pub fn from_str_hex(num: &str) -> Option<f32> {
strconv::from_str_common(num, 16u, true, true, true,
strconv::ExpBin, false, false)
@ -940,19 +940,19 @@ pub fn from_str_hex(num: &str) -> Option<f32> {
/// `none` if the string did not represent a valid number. Otherwise,
/// `Some(n)` where `n` is the floating-point number represented by `num`.
///
#[inline(always)]
#[inline]
pub fn from_str_radix(num: &str, rdx: uint) -> Option<f32> {
strconv::from_str_common(num, rdx, true, true, false,
strconv::ExpNone, false, false)
}
impl FromStr for f32 {
#[inline(always)]
#[inline]
fn from_str(val: &str) -> Option<f32> { from_str(val) }
}
impl num::FromStrRadix for f32 {
#[inline(always)]
#[inline]
fn from_str_radix(val: &str, rdx: uint) -> Option<f32> {
from_str_radix(val, rdx)
}

View file

@ -22,7 +22,7 @@ use to_str;
pub use cmath::c_double_targ_consts::*;
pub use cmp::{min, max};
// An inner module is required to get the #[inline(always)] attribute on the
// An inner module is required to get the #[inline] attribute on the
// functions.
pub use self::delegated::*;
@ -42,7 +42,7 @@ macro_rules! delegate(
use unstable::intrinsics;
$(
#[inline(always)]
#[inline]
pub fn $name($( $arg : $arg_ty ),*) -> $rv {
unsafe {
$bound_name($( $arg ),*)
@ -141,45 +141,45 @@ pub static infinity: f64 = 1.0_f64/0.0_f64;
pub static neg_infinity: f64 = -1.0_f64/0.0_f64;
#[inline(always)]
#[inline]
pub fn add(x: f64, y: f64) -> f64 { return x + y; }
#[inline(always)]
#[inline]
pub fn sub(x: f64, y: f64) -> f64 { return x - y; }
#[inline(always)]
#[inline]
pub fn mul(x: f64, y: f64) -> f64 { return x * y; }
#[inline(always)]
#[inline]
pub fn div(x: f64, y: f64) -> f64 { return x / y; }
#[inline(always)]
#[inline]
pub fn rem(x: f64, y: f64) -> f64 { return x % y; }
#[inline(always)]
#[inline]
pub fn lt(x: f64, y: f64) -> bool { return x < y; }
#[inline(always)]
#[inline]
pub fn le(x: f64, y: f64) -> bool { return x <= y; }
#[inline(always)]
#[inline]
pub fn eq(x: f64, y: f64) -> bool { return x == y; }
#[inline(always)]
#[inline]
pub fn ne(x: f64, y: f64) -> bool { return x != y; }
#[inline(always)]
#[inline]
pub fn ge(x: f64, y: f64) -> bool { return x >= y; }
#[inline(always)]
#[inline]
pub fn gt(x: f64, y: f64) -> bool { return x > y; }
#[inline(always)]
#[inline]
pub fn fmax(x: f64, y: f64) -> f64 {
if x >= y || y.is_NaN() { x } else { y }
}
#[inline(always)]
#[inline]
pub fn fmin(x: f64, y: f64) -> f64 {
if x <= y || y.is_NaN() { x } else { y }
}
@ -234,23 +234,23 @@ impl Num for f64 {}
#[cfg(not(test))]
impl Eq for f64 {
#[inline(always)]
#[inline]
fn eq(&self, other: &f64) -> bool { (*self) == (*other) }
#[inline(always)]
#[inline]
fn ne(&self, other: &f64) -> bool { (*self) != (*other) }
}
#[cfg(not(test))]
impl ApproxEq<f64> for f64 {
#[inline(always)]
#[inline]
fn approx_epsilon() -> f64 { 1.0e-6 }
#[inline(always)]
#[inline]
fn approx_eq(&self, other: &f64) -> bool {
self.approx_eq_eps(other, &ApproxEq::approx_epsilon::<f64, f64>())
}
#[inline(always)]
#[inline]
fn approx_eq_eps(&self, other: &f64, approx_epsilon: &f64) -> bool {
(*self - *other).abs() < *approx_epsilon
}
@ -258,32 +258,32 @@ impl ApproxEq<f64> for f64 {
#[cfg(not(test))]
impl Ord for f64 {
#[inline(always)]
#[inline]
fn lt(&self, other: &f64) -> bool { (*self) < (*other) }
#[inline(always)]
#[inline]
fn le(&self, other: &f64) -> bool { (*self) <= (*other) }
#[inline(always)]
#[inline]
fn ge(&self, other: &f64) -> bool { (*self) >= (*other) }
#[inline(always)]
#[inline]
fn gt(&self, other: &f64) -> bool { (*self) > (*other) }
}
impl Orderable for f64 {
/// Returns `NaN` if either of the numbers are `NaN`.
#[inline(always)]
#[inline]
fn min(&self, other: &f64) -> f64 {
if self.is_NaN() || other.is_NaN() { Float::NaN() } else { fmin(*self, *other) }
}
/// Returns `NaN` if either of the numbers are `NaN`.
#[inline(always)]
#[inline]
fn max(&self, other: &f64) -> f64 {
if self.is_NaN() || other.is_NaN() { Float::NaN() } else { fmax(*self, *other) }
}
/// Returns the number constrained within the range `mn <= self <= mx`.
/// If any of the numbers are `NaN` then `NaN` is returned.
#[inline(always)]
#[inline]
fn clamp(&self, mn: &f64, mx: &f64) -> f64 {
cond!(
(self.is_NaN()) { *self }
@ -295,16 +295,16 @@ impl Orderable for f64 {
}
impl Zero for f64 {
#[inline(always)]
#[inline]
fn zero() -> f64 { 0.0 }
/// Returns true if the number is equal to either `0.0` or `-0.0`
#[inline(always)]
#[inline]
fn is_zero(&self) -> bool { *self == 0.0 || *self == -0.0 }
}
impl One for f64 {
#[inline(always)]
#[inline]
fn one() -> f64 { 1.0 }
}
@ -326,7 +326,7 @@ impl Div<f64,f64> for f64 {
}
#[cfg(not(test))]
impl Rem<f64,f64> for f64 {
#[inline(always)]
#[inline]
fn rem(&self, other: &f64) -> f64 { *self % *other }
}
#[cfg(not(test))]
@ -336,14 +336,14 @@ impl Neg<f64> for f64 {
impl Signed for f64 {
/// Computes the absolute value. Returns `NaN` if the number is `NaN`.
#[inline(always)]
#[inline]
fn abs(&self) -> f64 { abs(*self) }
///
/// The positive difference of two numbers. Returns `0.0` if the number is less than or
/// equal to `other`, otherwise the difference between`self` and `other` is returned.
///
#[inline(always)]
#[inline]
fn abs_sub(&self, other: &f64) -> f64 { abs_sub(*self, *other) }
///
@ -353,35 +353,35 @@ impl Signed for f64 {
/// - `-1.0` if the number is negative, `-0.0` or `neg_infinity`
/// - `NaN` if the number is NaN
///
#[inline(always)]
#[inline]
fn signum(&self) -> f64 {
if self.is_NaN() { NaN } else { copysign(1.0, *self) }
}
/// Returns `true` if the number is positive, including `+0.0` and `infinity`
#[inline(always)]
#[inline]
fn is_positive(&self) -> bool { *self > 0.0 || (1.0 / *self) == infinity }
/// Returns `true` if the number is negative, including `-0.0` and `neg_infinity`
#[inline(always)]
#[inline]
fn is_negative(&self) -> bool { *self < 0.0 || (1.0 / *self) == neg_infinity }
}
impl Round for f64 {
/// Round half-way cases toward `neg_infinity`
#[inline(always)]
#[inline]
fn floor(&self) -> f64 { floor(*self) }
/// Round half-way cases toward `infinity`
#[inline(always)]
#[inline]
fn ceil(&self) -> f64 { ceil(*self) }
/// Round half-way cases away from `0.0`
#[inline(always)]
#[inline]
fn round(&self) -> f64 { round(*self) }
/// The integer part of the number (rounds towards `0.0`)
#[inline(always)]
#[inline]
fn trunc(&self) -> f64 { trunc(*self) }
///
@ -391,57 +391,57 @@ impl Round for f64 {
/// assert!(x == trunc(x) + fract(x))
/// ~~~
///
#[inline(always)]
#[inline]
fn fract(&self) -> f64 { *self - self.trunc() }
}
impl Fractional for f64 {
/// The reciprocal (multiplicative inverse) of the number
#[inline(always)]
#[inline]
fn recip(&self) -> f64 { 1.0 / *self }
}
impl Algebraic for f64 {
#[inline(always)]
#[inline]
fn pow(&self, n: &f64) -> f64 { pow(*self, *n) }
#[inline(always)]
#[inline]
fn sqrt(&self) -> f64 { sqrt(*self) }
#[inline(always)]
#[inline]
fn rsqrt(&self) -> f64 { self.sqrt().recip() }
#[inline(always)]
#[inline]
fn cbrt(&self) -> f64 { cbrt(*self) }
#[inline(always)]
#[inline]
fn hypot(&self, other: &f64) -> f64 { hypot(*self, *other) }
}
impl Trigonometric for f64 {
#[inline(always)]
#[inline]
fn sin(&self) -> f64 { sin(*self) }
#[inline(always)]
#[inline]
fn cos(&self) -> f64 { cos(*self) }
#[inline(always)]
#[inline]
fn tan(&self) -> f64 { tan(*self) }
#[inline(always)]
#[inline]
fn asin(&self) -> f64 { asin(*self) }
#[inline(always)]
#[inline]
fn acos(&self) -> f64 { acos(*self) }
#[inline(always)]
#[inline]
fn atan(&self) -> f64 { atan(*self) }
#[inline(always)]
#[inline]
fn atan2(&self, other: &f64) -> f64 { atan2(*self, *other) }
/// Simultaneously computes the sine and cosine of the number
#[inline(always)]
#[inline]
fn sin_cos(&self) -> (f64, f64) {
(self.sin(), self.cos())
}
@ -449,38 +449,38 @@ impl Trigonometric for f64 {
impl Exponential for f64 {
/// Returns the exponential of the number
#[inline(always)]
#[inline]
fn exp(&self) -> f64 { exp(*self) }
/// Returns 2 raised to the power of the number
#[inline(always)]
#[inline]
fn exp2(&self) -> f64 { exp2(*self) }
/// Returns the natural logarithm of the number
#[inline(always)]
#[inline]
fn ln(&self) -> f64 { ln(*self) }
/// Returns the logarithm of the number with respect to an arbitrary base
#[inline(always)]
#[inline]
fn log(&self, base: &f64) -> f64 { self.ln() / base.ln() }
/// Returns the base 2 logarithm of the number
#[inline(always)]
#[inline]
fn log2(&self) -> f64 { log2(*self) }
/// Returns the base 10 logarithm of the number
#[inline(always)]
#[inline]
fn log10(&self) -> f64 { log10(*self) }
}
impl Hyperbolic for f64 {
#[inline(always)]
#[inline]
fn sinh(&self) -> f64 { sinh(*self) }
#[inline(always)]
#[inline]
fn cosh(&self) -> f64 { cosh(*self) }
#[inline(always)]
#[inline]
fn tanh(&self) -> f64 { tanh(*self) }
///
@ -492,7 +492,7 @@ impl Hyperbolic for f64 {
/// - `self` if `self` is `0.0`, `-0.0`, `infinity`, or `neg_infinity`
/// - `NaN` if `self` is `NaN`
///
#[inline(always)]
#[inline]
fn asinh(&self) -> f64 {
match *self {
neg_infinity => neg_infinity,
@ -509,7 +509,7 @@ impl Hyperbolic for f64 {
/// - `infinity` if `self` is `infinity`
/// - `NaN` if `self` is `NaN` or `self < 1.0` (including `neg_infinity`)
///
#[inline(always)]
#[inline]
fn acosh(&self) -> f64 {
match *self {
x if x < 1.0 => Float::NaN(),
@ -529,7 +529,7 @@ impl Hyperbolic for f64 {
/// - `NaN` if the `self` is `NaN` or outside the domain of `-1.0 <= self <= 1.0`
/// (including `infinity` and `neg_infinity`)
///
#[inline(always)]
#[inline]
fn atanh(&self) -> f64 {
0.5 * ((2.0 * *self) / (1.0 - *self)).ln_1p()
}
@ -537,159 +537,159 @@ impl Hyperbolic for f64 {
impl Real for f64 {
/// Archimedes' constant
#[inline(always)]
#[inline]
fn pi() -> f64 { 3.14159265358979323846264338327950288 }
/// 2.0 * pi
#[inline(always)]
#[inline]
fn two_pi() -> f64 { 6.28318530717958647692528676655900576 }
/// pi / 2.0
#[inline(always)]
#[inline]
fn frac_pi_2() -> f64 { 1.57079632679489661923132169163975144 }
/// pi / 3.0
#[inline(always)]
#[inline]
fn frac_pi_3() -> f64 { 1.04719755119659774615421446109316763 }
/// pi / 4.0
#[inline(always)]
#[inline]
fn frac_pi_4() -> f64 { 0.785398163397448309615660845819875721 }
/// pi / 6.0
#[inline(always)]
#[inline]
fn frac_pi_6() -> f64 { 0.52359877559829887307710723054658381 }
/// pi / 8.0
#[inline(always)]
#[inline]
fn frac_pi_8() -> f64 { 0.39269908169872415480783042290993786 }
/// 1.0 / pi
#[inline(always)]
#[inline]
fn frac_1_pi() -> f64 { 0.318309886183790671537767526745028724 }
/// 2.0 / pi
#[inline(always)]
#[inline]
fn frac_2_pi() -> f64 { 0.636619772367581343075535053490057448 }
/// 2.0 / sqrt(pi)
#[inline(always)]
#[inline]
fn frac_2_sqrtpi() -> f64 { 1.12837916709551257389615890312154517 }
/// sqrt(2.0)
#[inline(always)]
#[inline]
fn sqrt2() -> f64 { 1.41421356237309504880168872420969808 }
/// 1.0 / sqrt(2.0)
#[inline(always)]
#[inline]
fn frac_1_sqrt2() -> f64 { 0.707106781186547524400844362104849039 }
/// Euler's number
#[inline(always)]
#[inline]
fn e() -> f64 { 2.71828182845904523536028747135266250 }
/// log2(e)
#[inline(always)]
#[inline]
fn log2_e() -> f64 { 1.44269504088896340735992468100189214 }
/// log10(e)
#[inline(always)]
#[inline]
fn log10_e() -> f64 { 0.434294481903251827651128918916605082 }
/// ln(2.0)
#[inline(always)]
#[inline]
fn ln_2() -> f64 { 0.693147180559945309417232121458176568 }
/// ln(10.0)
#[inline(always)]
#[inline]
fn ln_10() -> f64 { 2.30258509299404568401799145468436421 }
/// Converts to degrees, assuming the number is in radians
#[inline(always)]
#[inline]
fn to_degrees(&self) -> f64 { *self * (180.0 / Real::pi::<f64>()) }
/// Converts to radians, assuming the number is in degrees
#[inline(always)]
#[inline]
fn to_radians(&self) -> f64 { *self * (Real::pi::<f64>() / 180.0) }
}
impl RealExt for f64 {
#[inline(always)]
#[inline]
fn lgamma(&self) -> (int, f64) {
let mut sign = 0;
let result = lgamma(*self, &mut sign);
(sign as int, result)
}
#[inline(always)]
#[inline]
fn tgamma(&self) -> f64 { tgamma(*self) }
#[inline(always)]
#[inline]
fn j0(&self) -> f64 { j0(*self) }
#[inline(always)]
#[inline]
fn j1(&self) -> f64 { j1(*self) }
#[inline(always)]
#[inline]
fn jn(&self, n: int) -> f64 { jn(n as c_int, *self) }
#[inline(always)]
#[inline]
fn y0(&self) -> f64 { y0(*self) }
#[inline(always)]
#[inline]
fn y1(&self) -> f64 { y1(*self) }
#[inline(always)]
#[inline]
fn yn(&self, n: int) -> f64 { yn(n as c_int, *self) }
}
impl Bounded for f64 {
#[inline(always)]
#[inline]
fn min_value() -> f64 { 2.2250738585072014e-308 }
#[inline(always)]
#[inline]
fn max_value() -> f64 { 1.7976931348623157e+308 }
}
impl Primitive for f64 {
#[inline(always)]
#[inline]
fn bits() -> uint { 64 }
#[inline(always)]
#[inline]
fn bytes() -> uint { Primitive::bits::<f64>() / 8 }
}
impl Float for f64 {
#[inline(always)]
#[inline]
fn NaN() -> f64 { 0.0 / 0.0 }
#[inline(always)]
#[inline]
fn infinity() -> f64 { 1.0 / 0.0 }
#[inline(always)]
#[inline]
fn neg_infinity() -> f64 { -1.0 / 0.0 }
#[inline(always)]
#[inline]
fn neg_zero() -> f64 { -0.0 }
/// Returns `true` if the number is NaN
#[inline(always)]
#[inline]
fn is_NaN(&self) -> bool { *self != *self }
/// Returns `true` if the number is infinite
#[inline(always)]
#[inline]
fn is_infinite(&self) -> bool {
*self == Float::infinity() || *self == Float::neg_infinity()
}
/// Returns `true` if the number is neither infinite or NaN
#[inline(always)]
#[inline]
fn is_finite(&self) -> bool {
!(self.is_NaN() || self.is_infinite())
}
/// Returns `true` if the number is neither zero, infinite, subnormal or NaN
#[inline(always)]
#[inline]
fn is_normal(&self) -> bool {
self.classify() == FPNormal
}
@ -712,29 +712,29 @@ impl Float for f64 {
}
}
#[inline(always)]
#[inline]
fn mantissa_digits() -> uint { 53 }
#[inline(always)]
#[inline]
fn digits() -> uint { 15 }
#[inline(always)]
#[inline]
fn epsilon() -> f64 { 2.2204460492503131e-16 }
#[inline(always)]
#[inline]
fn min_exp() -> int { -1021 }
#[inline(always)]
#[inline]
fn max_exp() -> int { 1024 }
#[inline(always)]
#[inline]
fn min_10_exp() -> int { -307 }
#[inline(always)]
#[inline]
fn max_10_exp() -> int { 308 }
/// Constructs a floating point number by multiplying `x` by 2 raised to the power of `exp`
#[inline(always)]
#[inline]
fn ldexp(x: f64, exp: int) -> f64 {
ldexp(x, exp as c_int)
}
@ -745,7 +745,7 @@ impl Float for f64 {
/// - `self = x * pow(2, exp)`
/// - `0.5 <= abs(x) < 1.0`
///
#[inline(always)]
#[inline]
fn frexp(&self) -> (f64, int) {
let mut exp = 0;
let x = frexp(*self, &mut exp);
@ -756,14 +756,14 @@ impl Float for f64 {
/// Returns the exponential of the number, minus `1`, in a way that is accurate
/// even if the number is close to zero
///
#[inline(always)]
#[inline]
fn exp_m1(&self) -> f64 { exp_m1(*self) }
///
/// Returns the natural logarithm of the number plus `1` (`ln(1+n)`) more accurately
/// than if the operations were performed separately
///
#[inline(always)]
#[inline]
fn ln_1p(&self) -> f64 { ln_1p(*self) }
///
@ -771,13 +771,13 @@ impl Float for f64 {
/// produces a more accurate result with better performance than a separate multiplication
/// operation followed by an add.
///
#[inline(always)]
#[inline]
fn mul_add(&self, a: f64, b: f64) -> f64 {
mul_add(*self, a, b)
}
/// Returns the next representable floating-point value in the direction of `other`
#[inline(always)]
#[inline]
fn next_after(&self, other: f64) -> f64 {
next_after(*self, other)
}
@ -794,7 +794,7 @@ impl Float for f64 {
///
/// * num - The float value
///
#[inline(always)]
#[inline]
pub fn to_str(num: f64) -> ~str {
let (r, _) = strconv::to_str_common(
&num, 10u, true, strconv::SignNeg, strconv::DigAll);
@ -808,7 +808,7 @@ pub fn to_str(num: f64) -> ~str {
///
/// * num - The float value
///
#[inline(always)]
#[inline]
pub fn to_str_hex(num: f64) -> ~str {
let (r, _) = strconv::to_str_common(
&num, 16u, true, strconv::SignNeg, strconv::DigAll);
@ -829,7 +829,7 @@ pub fn to_str_hex(num: f64) -> ~str {
/// possible misinterpretation of the result at higher bases. If those values
/// are expected, use `to_str_radix_special()` instead.
///
#[inline(always)]
#[inline]
pub fn to_str_radix(num: f64, rdx: uint) -> ~str {
let (r, special) = strconv::to_str_common(
&num, rdx, true, strconv::SignNeg, strconv::DigAll);
@ -847,7 +847,7 @@ pub fn to_str_radix(num: f64, rdx: uint) -> ~str {
/// * num - The float value
/// * radix - The base to use
///
#[inline(always)]
#[inline]
pub fn to_str_radix_special(num: f64, rdx: uint) -> (~str, bool) {
strconv::to_str_common(&num, rdx, true,
strconv::SignNeg, strconv::DigAll)
@ -862,7 +862,7 @@ pub fn to_str_radix_special(num: f64, rdx: uint) -> (~str, bool) {
/// * num - The float value
/// * digits - The number of significant digits
///
#[inline(always)]
#[inline]
pub fn to_str_exact(num: f64, dig: uint) -> ~str {
let (r, _) = strconv::to_str_common(
&num, 10u, true, strconv::SignNeg, strconv::DigExact(dig));
@ -878,7 +878,7 @@ pub fn to_str_exact(num: f64, dig: uint) -> ~str {
/// * num - The float value
/// * digits - The number of significant digits
///
#[inline(always)]
#[inline]
pub fn to_str_digits(num: f64, dig: uint) -> ~str {
let (r, _) = strconv::to_str_common(
&num, 10u, true, strconv::SignNeg, strconv::DigMax(dig));
@ -886,12 +886,12 @@ pub fn to_str_digits(num: f64, dig: uint) -> ~str {
}
impl to_str::ToStr for f64 {
#[inline(always)]
#[inline]
fn to_str(&self) -> ~str { to_str_digits(*self, 8) }
}
impl num::ToStrRadix for f64 {
#[inline(always)]
#[inline]
fn to_str_radix(&self, rdx: uint) -> ~str {
to_str_radix(*self, rdx)
}
@ -924,7 +924,7 @@ impl num::ToStrRadix for f64 {
/// `none` if the string did not represent a valid number. Otherwise,
/// `Some(n)` where `n` is the floating-point number represented by `num`.
///
#[inline(always)]
#[inline]
pub fn from_str(num: &str) -> Option<f64> {
strconv::from_str_common(num, 10u, true, true, true,
strconv::ExpDec, false, false)
@ -957,7 +957,7 @@ pub fn from_str(num: &str) -> Option<f64> {
/// `none` if the string did not represent a valid number. Otherwise,
/// `Some(n)` where `n` is the floating-point number represented by `[num]`.
///
#[inline(always)]
#[inline]
pub fn from_str_hex(num: &str) -> Option<f64> {
strconv::from_str_common(num, 16u, true, true, true,
strconv::ExpBin, false, false)
@ -982,19 +982,19 @@ pub fn from_str_hex(num: &str) -> Option<f64> {
/// `none` if the string did not represent a valid number. Otherwise,
/// `Some(n)` where `n` is the floating-point number represented by `num`.
///
#[inline(always)]
#[inline]
pub fn from_str_radix(num: &str, rdx: uint) -> Option<f64> {
strconv::from_str_common(num, rdx, true, true, false,
strconv::ExpNone, false, false)
}
impl FromStr for f64 {
#[inline(always)]
#[inline]
fn from_str(val: &str) -> Option<f64> { from_str(val) }
}
impl num::FromStrRadix for f64 {
#[inline(always)]
#[inline]
fn from_str_radix(val: &str, rdx: uint) -> Option<f64> {
from_str_radix(val, rdx)
}

View file

@ -99,7 +99,7 @@ pub mod consts {
///
/// * num - The float value
///
#[inline(always)]
#[inline]
pub fn to_str(num: float) -> ~str {
let (r, _) = strconv::to_str_common(
&num, 10u, true, strconv::SignNeg, strconv::DigAll);
@ -113,7 +113,7 @@ pub fn to_str(num: float) -> ~str {
///
/// * num - The float value
///
#[inline(always)]
#[inline]
pub fn to_str_hex(num: float) -> ~str {
let (r, _) = strconv::to_str_common(
&num, 16u, true, strconv::SignNeg, strconv::DigAll);
@ -134,7 +134,7 @@ pub fn to_str_hex(num: float) -> ~str {
/// possible misinterpretation of the result at higher bases. If those values
/// are expected, use `to_str_radix_special()` instead.
///
#[inline(always)]
#[inline]
pub fn to_str_radix(num: float, radix: uint) -> ~str {
let (r, special) = strconv::to_str_common(
&num, radix, true, strconv::SignNeg, strconv::DigAll);
@ -152,7 +152,7 @@ pub fn to_str_radix(num: float, radix: uint) -> ~str {
/// * num - The float value
/// * radix - The base to use
///
#[inline(always)]
#[inline]
pub fn to_str_radix_special(num: float, radix: uint) -> (~str, bool) {
strconv::to_str_common(&num, radix, true,
strconv::SignNeg, strconv::DigAll)
@ -167,7 +167,7 @@ pub fn to_str_radix_special(num: float, radix: uint) -> (~str, bool) {
/// * num - The float value
/// * digits - The number of significant digits
///
#[inline(always)]
#[inline]
pub fn to_str_exact(num: float, digits: uint) -> ~str {
let (r, _) = strconv::to_str_common(
&num, 10u, true, strconv::SignNeg, strconv::DigExact(digits));
@ -183,7 +183,7 @@ pub fn to_str_exact(num: float, digits: uint) -> ~str {
/// * num - The float value
/// * digits - The number of significant digits
///
#[inline(always)]
#[inline]
pub fn to_str_digits(num: float, digits: uint) -> ~str {
let (r, _) = strconv::to_str_common(
&num, 10u, true, strconv::SignNeg, strconv::DigMax(digits));
@ -191,12 +191,12 @@ pub fn to_str_digits(num: float, digits: uint) -> ~str {
}
impl to_str::ToStr for float {
#[inline(always)]
#[inline]
fn to_str(&self) -> ~str { to_str_digits(*self, 8) }
}
impl num::ToStrRadix for float {
#[inline(always)]
#[inline]
fn to_str_radix(&self, radix: uint) -> ~str {
to_str_radix(*self, radix)
}
@ -229,7 +229,7 @@ impl num::ToStrRadix for float {
/// `none` if the string did not represent a valid number. Otherwise,
/// `Some(n)` where `n` is the floating-point number represented by `num`.
///
#[inline(always)]
#[inline]
pub fn from_str(num: &str) -> Option<float> {
strconv::from_str_common(num, 10u, true, true, true,
strconv::ExpDec, false, false)
@ -262,7 +262,7 @@ pub fn from_str(num: &str) -> Option<float> {
/// `none` if the string did not represent a valid number. Otherwise,
/// `Some(n)` where `n` is the floating-point number represented by `[num]`.
///
#[inline(always)]
#[inline]
pub fn from_str_hex(num: &str) -> Option<float> {
strconv::from_str_common(num, 16u, true, true, true,
strconv::ExpBin, false, false)
@ -287,19 +287,19 @@ pub fn from_str_hex(num: &str) -> Option<float> {
/// `none` if the string did not represent a valid number. Otherwise,
/// `Some(n)` where `n` is the floating-point number represented by `num`.
///
#[inline(always)]
#[inline]
pub fn from_str_radix(num: &str, radix: uint) -> Option<float> {
strconv::from_str_common(num, radix, true, true, false,
strconv::ExpNone, false, false)
}
impl FromStr for float {
#[inline(always)]
#[inline]
fn from_str(val: &str) -> Option<float> { from_str(val) }
}
impl num::FromStrRadix for float {
#[inline(always)]
#[inline]
fn from_str_radix(val: &str, radix: uint) -> Option<float> {
from_str_radix(val, radix)
}
@ -341,27 +341,27 @@ pub fn pow_with_uint(base: uint, pow: uint) -> float {
return total;
}
#[inline(always)]
#[inline]
pub fn abs(x: float) -> float {
f64::abs(x as f64) as float
}
#[inline(always)]
#[inline]
pub fn sqrt(x: float) -> float {
f64::sqrt(x as f64) as float
}
#[inline(always)]
#[inline]
pub fn atan(x: float) -> float {
f64::atan(x as f64) as float
}
#[inline(always)]
#[inline]
pub fn sin(x: float) -> float {
f64::sin(x as f64) as float
}
#[inline(always)]
#[inline]
pub fn cos(x: float) -> float {
f64::cos(x as f64) as float
}
#[inline(always)]
#[inline]
pub fn tan(x: float) -> float {
f64::tan(x as f64) as float
}
@ -370,23 +370,23 @@ impl Num for float {}
#[cfg(not(test))]
impl Eq for float {
#[inline(always)]
#[inline]
fn eq(&self, other: &float) -> bool { (*self) == (*other) }
#[inline(always)]
#[inline]
fn ne(&self, other: &float) -> bool { (*self) != (*other) }
}
#[cfg(not(test))]
impl ApproxEq<float> for float {
#[inline(always)]
#[inline]
fn approx_epsilon() -> float { 1.0e-6 }
#[inline(always)]
#[inline]
fn approx_eq(&self, other: &float) -> bool {
self.approx_eq_eps(other, &ApproxEq::approx_epsilon::<float, float>())
}
#[inline(always)]
#[inline]
fn approx_eq_eps(&self, other: &float, approx_epsilon: &float) -> bool {
(*self - *other).abs() < *approx_epsilon
}
@ -394,66 +394,66 @@ impl ApproxEq<float> for float {
#[cfg(not(test))]
impl Ord for float {
#[inline(always)]
#[inline]
fn lt(&self, other: &float) -> bool { (*self) < (*other) }
#[inline(always)]
#[inline]
fn le(&self, other: &float) -> bool { (*self) <= (*other) }
#[inline(always)]
#[inline]
fn ge(&self, other: &float) -> bool { (*self) >= (*other) }
#[inline(always)]
#[inline]
fn gt(&self, other: &float) -> bool { (*self) > (*other) }
}
impl Orderable for float {
/// Returns `NaN` if either of the numbers are `NaN`.
#[inline(always)]
#[inline]
fn min(&self, other: &float) -> float {
(*self as f64).min(&(*other as f64)) as float
}
/// Returns `NaN` if either of the numbers are `NaN`.
#[inline(always)]
#[inline]
fn max(&self, other: &float) -> float {
(*self as f64).max(&(*other as f64)) as float
}
/// Returns the number constrained within the range `mn <= self <= mx`.
/// If any of the numbers are `NaN` then `NaN` is returned.
#[inline(always)]
#[inline]
fn clamp(&self, mn: &float, mx: &float) -> float {
(*self as f64).clamp(&(*mn as f64), &(*mx as f64)) as float
}
}
impl Zero for float {
#[inline(always)]
#[inline]
fn zero() -> float { 0.0 }
/// Returns true if the number is equal to either `0.0` or `-0.0`
#[inline(always)]
#[inline]
fn is_zero(&self) -> bool { *self == 0.0 || *self == -0.0 }
}
impl One for float {
#[inline(always)]
#[inline]
fn one() -> float { 1.0 }
}
impl Round for float {
/// Round half-way cases toward `neg_infinity`
#[inline(always)]
#[inline]
fn floor(&self) -> float { floor(*self as f64) as float }
/// Round half-way cases toward `infinity`
#[inline(always)]
#[inline]
fn ceil(&self) -> float { ceil(*self as f64) as float }
/// Round half-way cases away from `0.0`
#[inline(always)]
#[inline]
fn round(&self) -> float { round(*self as f64) as float }
/// The integer part of the number (rounds towards `0.0`)
#[inline(always)]
#[inline]
fn trunc(&self) -> float { trunc(*self as f64) as float }
///
@ -463,81 +463,81 @@ impl Round for float {
/// assert!(x == trunc(x) + fract(x))
/// ~~~
///
#[inline(always)]
#[inline]
fn fract(&self) -> float { *self - self.trunc() }
}
impl Fractional for float {
/// The reciprocal (multiplicative inverse) of the number
#[inline(always)]
#[inline]
fn recip(&self) -> float { 1.0 / *self }
}
impl Algebraic for float {
#[inline(always)]
#[inline]
fn pow(&self, n: &float) -> float {
(*self as f64).pow(&(*n as f64)) as float
}
#[inline(always)]
#[inline]
fn sqrt(&self) -> float {
(*self as f64).sqrt() as float
}
#[inline(always)]
#[inline]
fn rsqrt(&self) -> float {
(*self as f64).rsqrt() as float
}
#[inline(always)]
#[inline]
fn cbrt(&self) -> float {
(*self as f64).cbrt() as float
}
#[inline(always)]
#[inline]
fn hypot(&self, other: &float) -> float {
(*self as f64).hypot(&(*other as f64)) as float
}
}
impl Trigonometric for float {
#[inline(always)]
#[inline]
fn sin(&self) -> float {
(*self as f64).sin() as float
}
#[inline(always)]
#[inline]
fn cos(&self) -> float {
(*self as f64).cos() as float
}
#[inline(always)]
#[inline]
fn tan(&self) -> float {
(*self as f64).tan() as float
}
#[inline(always)]
#[inline]
fn asin(&self) -> float {
(*self as f64).asin() as float
}
#[inline(always)]
#[inline]
fn acos(&self) -> float {
(*self as f64).acos() as float
}
#[inline(always)]
#[inline]
fn atan(&self) -> float {
(*self as f64).atan() as float
}
#[inline(always)]
#[inline]
fn atan2(&self, other: &float) -> float {
(*self as f64).atan2(&(*other as f64)) as float
}
/// Simultaneously computes the sine and cosine of the number
#[inline(always)]
#[inline]
fn sin_cos(&self) -> (float, float) {
match (*self as f64).sin_cos() {
(s, c) => (s as float, c as float)
@ -547,54 +547,54 @@ impl Trigonometric for float {
impl Exponential for float {
/// Returns the exponential of the number
#[inline(always)]
#[inline]
fn exp(&self) -> float {
(*self as f64).exp() as float
}
/// Returns 2 raised to the power of the number
#[inline(always)]
#[inline]
fn exp2(&self) -> float {
(*self as f64).exp2() as float
}
/// Returns the natural logarithm of the number
#[inline(always)]
#[inline]
fn ln(&self) -> float {
(*self as f64).ln() as float
}
/// Returns the logarithm of the number with respect to an arbitrary base
#[inline(always)]
#[inline]
fn log(&self, base: &float) -> float {
(*self as f64).log(&(*base as f64)) as float
}
/// Returns the base 2 logarithm of the number
#[inline(always)]
#[inline]
fn log2(&self) -> float {
(*self as f64).log2() as float
}
/// Returns the base 10 logarithm of the number
#[inline(always)]
#[inline]
fn log10(&self) -> float {
(*self as f64).log10() as float
}
}
impl Hyperbolic for float {
#[inline(always)]
#[inline]
fn sinh(&self) -> float {
(*self as f64).sinh() as float
}
#[inline(always)]
#[inline]
fn cosh(&self) -> float {
(*self as f64).cosh() as float
}
#[inline(always)]
#[inline]
fn tanh(&self) -> float {
(*self as f64).tanh() as float
}
@ -608,7 +608,7 @@ impl Hyperbolic for float {
/// - `self` if `self` is `0.0`, `-0.0`, `infinity`, or `neg_infinity`
/// - `NaN` if `self` is `NaN`
///
#[inline(always)]
#[inline]
fn asinh(&self) -> float {
(*self as f64).asinh() as float
}
@ -622,7 +622,7 @@ impl Hyperbolic for float {
/// - `infinity` if `self` is `infinity`
/// - `NaN` if `self` is `NaN` or `self < 1.0` (including `neg_infinity`)
///
#[inline(always)]
#[inline]
fn acosh(&self) -> float {
(*self as f64).acosh() as float
}
@ -639,7 +639,7 @@ impl Hyperbolic for float {
/// - `NaN` if the `self` is `NaN` or outside the domain of `-1.0 <= self <= 1.0`
/// (including `infinity` and `neg_infinity`)
///
#[inline(always)]
#[inline]
fn atanh(&self) -> float {
(*self as f64).atanh() as float
}
@ -647,157 +647,157 @@ impl Hyperbolic for float {
impl Real for float {
/// Archimedes' constant
#[inline(always)]
#[inline]
fn pi() -> float { 3.14159265358979323846264338327950288 }
/// 2.0 * pi
#[inline(always)]
#[inline]
fn two_pi() -> float { 6.28318530717958647692528676655900576 }
/// pi / 2.0
#[inline(always)]
#[inline]
fn frac_pi_2() -> float { 1.57079632679489661923132169163975144 }
/// pi / 3.0
#[inline(always)]
#[inline]
fn frac_pi_3() -> float { 1.04719755119659774615421446109316763 }
/// pi / 4.0
#[inline(always)]
#[inline]
fn frac_pi_4() -> float { 0.785398163397448309615660845819875721 }
/// pi / 6.0
#[inline(always)]
#[inline]
fn frac_pi_6() -> float { 0.52359877559829887307710723054658381 }
/// pi / 8.0
#[inline(always)]
#[inline]
fn frac_pi_8() -> float { 0.39269908169872415480783042290993786 }
/// 1.0 / pi
#[inline(always)]
#[inline]
fn frac_1_pi() -> float { 0.318309886183790671537767526745028724 }
/// 2.0 / pi
#[inline(always)]
#[inline]
fn frac_2_pi() -> float { 0.636619772367581343075535053490057448 }
/// 2 .0/ sqrt(pi)
#[inline(always)]
#[inline]
fn frac_2_sqrtpi() -> float { 1.12837916709551257389615890312154517 }
/// sqrt(2.0)
#[inline(always)]
#[inline]
fn sqrt2() -> float { 1.41421356237309504880168872420969808 }
/// 1.0 / sqrt(2.0)
#[inline(always)]
#[inline]
fn frac_1_sqrt2() -> float { 0.707106781186547524400844362104849039 }
/// Euler's number
#[inline(always)]
#[inline]
fn e() -> float { 2.71828182845904523536028747135266250 }
/// log2(e)
#[inline(always)]
#[inline]
fn log2_e() -> float { 1.44269504088896340735992468100189214 }
/// log10(e)
#[inline(always)]
#[inline]
fn log10_e() -> float { 0.434294481903251827651128918916605082 }
/// ln(2.0)
#[inline(always)]
#[inline]
fn ln_2() -> float { 0.693147180559945309417232121458176568 }
/// ln(10.0)
#[inline(always)]
#[inline]
fn ln_10() -> float { 2.30258509299404568401799145468436421 }
/// Converts to degrees, assuming the number is in radians
#[inline(always)]
#[inline]
fn to_degrees(&self) -> float { (*self as f64).to_degrees() as float }
/// Converts to radians, assuming the number is in degrees
#[inline(always)]
#[inline]
fn to_radians(&self) -> float { (*self as f64).to_radians() as float }
}
impl RealExt for float {
#[inline(always)]
#[inline]
fn lgamma(&self) -> (int, float) {
let mut sign = 0;
let result = lgamma(*self as f64, &mut sign);
(sign as int, result as float)
}
#[inline(always)]
#[inline]
fn tgamma(&self) -> float { tgamma(*self as f64) as float }
#[inline(always)]
#[inline]
fn j0(&self) -> float { j0(*self as f64) as float }
#[inline(always)]
#[inline]
fn j1(&self) -> float { j1(*self as f64) as float }
#[inline(always)]
#[inline]
fn jn(&self, n: int) -> float { jn(n as c_int, *self as f64) as float }
#[inline(always)]
#[inline]
fn y0(&self) -> float { y0(*self as f64) as float }
#[inline(always)]
#[inline]
fn y1(&self) -> float { y1(*self as f64) as float }
#[inline(always)]
#[inline]
fn yn(&self, n: int) -> float { yn(n as c_int, *self as f64) as float }
}
#[cfg(not(test))]
impl Add<float,float> for float {
#[inline(always)]
#[inline]
fn add(&self, other: &float) -> float { *self + *other }
}
#[cfg(not(test))]
impl Sub<float,float> for float {
#[inline(always)]
#[inline]
fn sub(&self, other: &float) -> float { *self - *other }
}
#[cfg(not(test))]
impl Mul<float,float> for float {
#[inline(always)]
#[inline]
fn mul(&self, other: &float) -> float { *self * *other }
}
#[cfg(not(test))]
impl Div<float,float> for float {
#[inline(always)]
#[inline]
fn div(&self, other: &float) -> float { *self / *other }
}
#[cfg(not(test))]
impl Rem<float,float> for float {
#[inline(always)]
#[inline]
fn rem(&self, other: &float) -> float { *self % *other }
}
#[cfg(not(test))]
impl Neg<float> for float {
#[inline(always)]
#[inline]
fn neg(&self) -> float { -*self }
}
impl Signed for float {
/// Computes the absolute value. Returns `NaN` if the number is `NaN`.
#[inline(always)]
#[inline]
fn abs(&self) -> float { abs(*self) }
///
/// The positive difference of two numbers. Returns `0.0` if the number is less than or
/// equal to `other`, otherwise the difference between`self` and `other` is returned.
///
#[inline(always)]
#[inline]
fn abs_sub(&self, other: &float) -> float {
(*self as f64).abs_sub(&(*other as f64)) as float
}
@ -809,93 +809,93 @@ impl Signed for float {
/// - `-1.0` if the number is negative, `-0.0` or `neg_infinity`
/// - `NaN` if the number is NaN
///
#[inline(always)]
#[inline]
fn signum(&self) -> float {
if self.is_NaN() { NaN } else { f64::copysign(1.0, *self as f64) as float }
}
/// Returns `true` if the number is positive, including `+0.0` and `infinity`
#[inline(always)]
#[inline]
fn is_positive(&self) -> bool { *self > 0.0 || (1.0 / *self) == infinity }
/// Returns `true` if the number is negative, including `-0.0` and `neg_infinity`
#[inline(always)]
#[inline]
fn is_negative(&self) -> bool { *self < 0.0 || (1.0 / *self) == neg_infinity }
}
impl Bounded for float {
#[inline(always)]
#[inline]
fn min_value() -> float { Bounded::min_value::<f64>() as float }
#[inline(always)]
#[inline]
fn max_value() -> float { Bounded::max_value::<f64>() as float }
}
impl Primitive for float {
#[inline(always)]
#[inline]
fn bits() -> uint { Primitive::bits::<f64>() }
#[inline(always)]
#[inline]
fn bytes() -> uint { Primitive::bytes::<f64>() }
}
impl Float for float {
#[inline(always)]
#[inline]
fn NaN() -> float { Float::NaN::<f64>() as float }
#[inline(always)]
#[inline]
fn infinity() -> float { Float::infinity::<f64>() as float }
#[inline(always)]
#[inline]
fn neg_infinity() -> float { Float::neg_infinity::<f64>() as float }
#[inline(always)]
#[inline]
fn neg_zero() -> float { Float::neg_zero::<f64>() as float }
/// Returns `true` if the number is NaN
#[inline(always)]
#[inline]
fn is_NaN(&self) -> bool { (*self as f64).is_NaN() }
/// Returns `true` if the number is infinite
#[inline(always)]
#[inline]
fn is_infinite(&self) -> bool { (*self as f64).is_infinite() }
/// Returns `true` if the number is neither infinite or NaN
#[inline(always)]
#[inline]
fn is_finite(&self) -> bool { (*self as f64).is_finite() }
/// Returns `true` if the number is neither zero, infinite, subnormal or NaN
#[inline(always)]
#[inline]
fn is_normal(&self) -> bool { (*self as f64).is_normal() }
/// Returns the floating point category of the number. If only one property is going to
/// be tested, it is generally faster to use the specific predicate instead.
#[inline(always)]
#[inline]
fn classify(&self) -> FPCategory { (*self as f64).classify() }
#[inline(always)]
#[inline]
fn mantissa_digits() -> uint { Float::mantissa_digits::<f64>() }
#[inline(always)]
#[inline]
fn digits() -> uint { Float::digits::<f64>() }
#[inline(always)]
#[inline]
fn epsilon() -> float { Float::epsilon::<f64>() as float }
#[inline(always)]
#[inline]
fn min_exp() -> int { Float::min_exp::<f64>() }
#[inline(always)]
#[inline]
fn max_exp() -> int { Float::max_exp::<f64>() }
#[inline(always)]
#[inline]
fn min_10_exp() -> int { Float::min_10_exp::<f64>() }
#[inline(always)]
#[inline]
fn max_10_exp() -> int { Float::max_10_exp::<f64>() }
/// Constructs a floating point number by multiplying `x` by 2 raised to the power of `exp`
#[inline(always)]
#[inline]
fn ldexp(x: float, exp: int) -> float {
Float::ldexp(x as f64, exp) as float
}
@ -906,7 +906,7 @@ impl Float for float {
/// - `self = x * pow(2, exp)`
/// - `0.5 <= abs(x) < 1.0`
///
#[inline(always)]
#[inline]
fn frexp(&self) -> (float, int) {
match (*self as f64).frexp() {
(x, exp) => (x as float, exp)
@ -917,7 +917,7 @@ impl Float for float {
/// Returns the exponential of the number, minus `1`, in a way that is accurate
/// even if the number is close to zero
///
#[inline(always)]
#[inline]
fn exp_m1(&self) -> float {
(*self as f64).exp_m1() as float
}
@ -926,7 +926,7 @@ impl Float for float {
/// Returns the natural logarithm of the number plus `1` (`ln(1+n)`) more accurately
/// than if the operations were performed separately
///
#[inline(always)]
#[inline]
fn ln_1p(&self) -> float {
(*self as f64).ln_1p() as float
}
@ -936,13 +936,13 @@ impl Float for float {
/// produces a more accurate result with better performance than a separate multiplication
/// operation followed by an add.
///
#[inline(always)]
#[inline]
fn mul_add(&self, a: float, b: float) -> float {
mul_add(*self as f64, a as f64, b as f64) as float
}
/// Returns the next representable floating-point value in the direction of `other`
#[inline(always)]
#[inline]
fn next_after(&self, other: float) -> float {
next_after(*self as f64, other as f64) as float
}

View file

@ -19,14 +19,14 @@ int_module!(i16, 16)
impl BitCount for i16 {
/// Counts the number of bits set. Wraps LLVM's `ctpop` intrinsic.
#[inline(always)]
#[inline]
fn population_count(&self) -> i16 { unsafe { intrinsics::ctpop16(*self) } }
/// Counts the number of leading zeros. Wraps LLVM's `ctlz` intrinsic.
#[inline(always)]
#[inline]
fn leading_zeros(&self) -> i16 { unsafe { intrinsics::ctlz16(*self) } }
/// Counts the number of trailing zeros. Wraps LLVM's `cttz` intrinsic.
#[inline(always)]
#[inline]
fn trailing_zeros(&self) -> i16 { unsafe { intrinsics::cttz16(*self) } }
}

View file

@ -19,14 +19,14 @@ int_module!(i32, 32)
impl BitCount for i32 {
/// Counts the number of bits set. Wraps LLVM's `ctpop` intrinsic.
#[inline(always)]
#[inline]
fn population_count(&self) -> i32 { unsafe { intrinsics::ctpop32(*self) } }
/// Counts the number of leading zeros. Wraps LLVM's `ctlz` intrinsic.
#[inline(always)]
#[inline]
fn leading_zeros(&self) -> i32 { unsafe { intrinsics::ctlz32(*self) } }
/// Counts the number of trailing zeros. Wraps LLVM's `cttz` intrinsic.
#[inline(always)]
#[inline]
fn trailing_zeros(&self) -> i32 { unsafe { intrinsics::cttz32(*self) } }
}

View file

@ -19,14 +19,14 @@ int_module!(i64, 64)
impl BitCount for i64 {
/// Counts the number of bits set. Wraps LLVM's `ctpop` intrinsic.
#[inline(always)]
#[inline]
fn population_count(&self) -> i64 { unsafe { intrinsics::ctpop64(*self) } }
/// Counts the number of leading zeros. Wraps LLVM's `ctlz` intrinsic.
#[inline(always)]
#[inline]
fn leading_zeros(&self) -> i64 { unsafe { intrinsics::ctlz64(*self) } }
/// Counts the number of trailing zeros. Wraps LLVM's `cttz` intrinsic.
#[inline(always)]
#[inline]
fn trailing_zeros(&self) -> i64 { unsafe { intrinsics::cttz64(*self) } }
}

View file

@ -19,14 +19,14 @@ int_module!(i8, 8)
impl BitCount for i8 {
/// Counts the number of bits set. Wraps LLVM's `ctpop` intrinsic.
#[inline(always)]
#[inline]
fn population_count(&self) -> i8 { unsafe { intrinsics::ctpop8(*self) } }
/// Counts the number of leading zeros. Wraps LLVM's `ctlz` intrinsic.
#[inline(always)]
#[inline]
fn leading_zeros(&self) -> i8 { unsafe { intrinsics::ctlz8(*self) } }
/// Counts the number of trailing zeros. Wraps LLVM's `cttz` intrinsic.
#[inline(always)]
#[inline]
fn trailing_zeros(&self) -> i8 { unsafe { intrinsics::cttz8(*self) } }
}

View file

@ -22,30 +22,30 @@ int_module!(int, super::bits)
#[cfg(target_word_size = "32")]
impl BitCount for int {
/// Counts the number of bits set. Wraps LLVM's `ctpop` intrinsic.
#[inline(always)]
#[inline]
fn population_count(&self) -> int { (*self as i32).population_count() as int }
/// Counts the number of leading zeros. Wraps LLVM's `ctlz` intrinsic.
#[inline(always)]
#[inline]
fn leading_zeros(&self) -> int { (*self as i32).leading_zeros() as int }
/// Counts the number of trailing zeros. Wraps LLVM's `cttz` intrinsic.
#[inline(always)]
#[inline]
fn trailing_zeros(&self) -> int { (*self as i32).trailing_zeros() as int }
}
#[cfg(target_word_size = "64")]
impl BitCount for int {
/// Counts the number of bits set. Wraps LLVM's `ctpop` intrinsic.
#[inline(always)]
#[inline]
fn population_count(&self) -> int { (*self as i64).population_count() as int }
/// Counts the number of leading zeros. Wraps LLVM's `ctlz` intrinsic.
#[inline(always)]
#[inline]
fn leading_zeros(&self) -> int { (*self as i64).leading_zeros() as int }
/// Counts the number of trailing zeros. Wraps LLVM's `cttz` intrinsic.
#[inline(always)]
#[inline]
fn trailing_zeros(&self) -> int { (*self as i64).trailing_zeros() as int }
}

View file

@ -27,17 +27,17 @@ pub static min_value: $T = (-1 as $T) << (bits - 1);
pub static max_value: $T = min_value - 1 as $T;
/// Calculates the sum of two numbers
#[inline(always)]
#[inline]
pub fn add(x: $T, y: $T) -> $T { x + y }
/// Subtracts the second number from the first
#[inline(always)]
#[inline]
pub fn sub(x: $T, y: $T) -> $T { x - y }
/// Multiplies two numbers together
#[inline(always)]
#[inline]
pub fn mul(x: $T, y: $T) -> $T { x * y }
/// Divides the first argument by the second argument (using integer division)
/// Divides the first argument by the second argument (using integer division)
#[inline(always)]
#[inline]
pub fn div(x: $T, y: $T) -> $T { x / y }
///
@ -60,26 +60,26 @@ pub fn div(x: $T, y: $T) -> $T { x / y }
/// ~~~
///
///
#[inline(always)]
#[inline]
pub fn rem(x: $T, y: $T) -> $T { x % y }
/// Returns true iff `x < y`
#[inline(always)]
#[inline]
pub fn lt(x: $T, y: $T) -> bool { x < y }
/// Returns true iff `x <= y`
#[inline(always)]
#[inline]
pub fn le(x: $T, y: $T) -> bool { x <= y }
/// Returns true iff `x == y`
#[inline(always)]
#[inline]
pub fn eq(x: $T, y: $T) -> bool { x == y }
/// Returns true iff `x != y`
#[inline(always)]
#[inline]
pub fn ne(x: $T, y: $T) -> bool { x != y }
/// Returns true iff `x >= y`
#[inline(always)]
#[inline]
pub fn ge(x: $T, y: $T) -> bool { x >= y }
/// Returns true iff `x > y`
#[inline(always)]
#[inline]
pub fn gt(x: $T, y: $T) -> bool { x > y }
///
@ -99,7 +99,7 @@ pub fn gt(x: $T, y: $T) -> bool { x > y }
/// assert!(sum == 10);
/// ~~~
///
#[inline(always)]
#[inline]
pub fn range_step(start: $T, stop: $T, step: $T, it: &fn($T) -> bool) -> bool {
let mut i = start;
if step == 0 {
@ -122,62 +122,62 @@ pub fn range_step(start: $T, stop: $T, step: $T, it: &fn($T) -> bool) -> bool {
return true;
}
#[inline(always)]
#[inline]
/// Iterate over the range [`lo`..`hi`)
pub fn range(lo: $T, hi: $T, it: &fn($T) -> bool) -> bool {
range_step(lo, hi, 1 as $T, it)
}
#[inline(always)]
#[inline]
/// Iterate over the range [`hi`..`lo`)
pub fn range_rev(hi: $T, lo: $T, it: &fn($T) -> bool) -> bool {
range_step(hi, lo, -1 as $T, it)
}
/// Computes the bitwise complement
#[inline(always)]
#[inline]
pub fn compl(i: $T) -> $T {
-1 as $T ^ i
}
/// Computes the absolute value
#[inline(always)]
#[inline]
pub fn abs(i: $T) -> $T { i.abs() }
impl Num for $T {}
#[cfg(not(test))]
impl Ord for $T {
#[inline(always)]
#[inline]
fn lt(&self, other: &$T) -> bool { return (*self) < (*other); }
#[inline(always)]
#[inline]
fn le(&self, other: &$T) -> bool { return (*self) <= (*other); }
#[inline(always)]
#[inline]
fn ge(&self, other: &$T) -> bool { return (*self) >= (*other); }
#[inline(always)]
#[inline]
fn gt(&self, other: &$T) -> bool { return (*self) > (*other); }
}
#[cfg(not(test))]
impl Eq for $T {
#[inline(always)]
#[inline]
fn eq(&self, other: &$T) -> bool { return (*self) == (*other); }
#[inline(always)]
#[inline]
fn ne(&self, other: &$T) -> bool { return (*self) != (*other); }
}
impl Orderable for $T {
#[inline(always)]
#[inline]
fn min(&self, other: &$T) -> $T {
if *self < *other { *self } else { *other }
}
#[inline(always)]
#[inline]
fn max(&self, other: &$T) -> $T {
if *self > *other { *self } else { *other }
}
#[inline(always)]
#[inline]
fn clamp(&self, mn: &$T, mx: &$T) -> $T {
if *self > *mx { *mx } else
if *self < *mn { *mn } else { *self }
@ -185,33 +185,33 @@ impl Orderable for $T {
}
impl Zero for $T {
#[inline(always)]
#[inline]
fn zero() -> $T { 0 }
#[inline(always)]
#[inline]
fn is_zero(&self) -> bool { *self == 0 }
}
impl One for $T {
#[inline(always)]
#[inline]
fn one() -> $T { 1 }
}
#[cfg(not(test))]
impl Add<$T,$T> for $T {
#[inline(always)]
#[inline]
fn add(&self, other: &$T) -> $T { *self + *other }
}
#[cfg(not(test))]
impl Sub<$T,$T> for $T {
#[inline(always)]
#[inline]
fn sub(&self, other: &$T) -> $T { *self - *other }
}
#[cfg(not(test))]
impl Mul<$T,$T> for $T {
#[inline(always)]
#[inline]
fn mul(&self, other: &$T) -> $T { *self * *other }
}
@ -235,7 +235,7 @@ impl Div<$T,$T> for $T {
/// assert!(-1 / -2 == 0);
/// ~~~
///
#[inline(always)]
#[inline]
fn div(&self, other: &$T) -> $T { *self / *other }
}
@ -262,19 +262,19 @@ impl Rem<$T,$T> for $T {
/// assert!(-1 % -2 == -1);
/// ~~~
///
#[inline(always)]
#[inline]
fn rem(&self, other: &$T) -> $T { *self % *other }
}
#[cfg(not(test))]
impl Neg<$T> for $T {
#[inline(always)]
#[inline]
fn neg(&self) -> $T { -*self }
}
impl Signed for $T {
/// Computes the absolute value
#[inline(always)]
#[inline]
fn abs(&self) -> $T {
if self.is_negative() { -*self } else { *self }
}
@ -283,7 +283,7 @@ impl Signed for $T {
/// The positive difference of two numbers. Returns `0` if the number is less than or
/// equal to `other`, otherwise the difference between`self` and `other` is returned.
///
#[inline(always)]
#[inline]
fn abs_sub(&self, other: &$T) -> $T {
if *self <= *other { 0 } else { *self - *other }
}
@ -295,7 +295,7 @@ impl Signed for $T {
/// - `1` if the number is positive
/// - `-1` if the number is negative
///
#[inline(always)]
#[inline]
fn signum(&self) -> $T {
match *self {
n if n > 0 => 1,
@ -305,11 +305,11 @@ impl Signed for $T {
}
/// Returns true if the number is positive
#[inline(always)]
#[inline]
fn is_positive(&self) -> bool { *self > 0 }
/// Returns true if the number is negative
#[inline(always)]
#[inline]
fn is_negative(&self) -> bool { *self < 0 }
}
@ -331,7 +331,7 @@ impl Integer for $T {
/// assert!((-1).div_floor(-2) == 0);
/// ~~~
///
#[inline(always)]
#[inline]
fn div_floor(&self, other: &$T) -> $T {
// Algorithm from [Daan Leijen. _Division and Modulus for Computer Scientists_,
// December 2001](http://research.microsoft.com/pubs/151917/divmodnote-letter.pdf)
@ -363,7 +363,7 @@ impl Integer for $T {
/// assert!((-1).mod_floor(-2) == -1);
/// ~~~
///
#[inline(always)]
#[inline]
fn mod_floor(&self, other: &$T) -> $T {
// Algorithm from [Daan Leijen. _Division and Modulus for Computer Scientists_,
// December 2001](http://research.microsoft.com/pubs/151917/divmodnote-letter.pdf)
@ -375,7 +375,7 @@ impl Integer for $T {
}
/// Calculates `div_floor` and `mod_floor` simultaneously
#[inline(always)]
#[inline]
fn div_mod_floor(&self, other: &$T) -> ($T,$T) {
// Algorithm from [Daan Leijen. _Division and Modulus for Computer Scientists_,
// December 2001](http://research.microsoft.com/pubs/151917/divmodnote-letter.pdf)
@ -387,7 +387,7 @@ impl Integer for $T {
}
/// Calculates `div` (`\`) and `rem` (`%`) simultaneously
#[inline(always)]
#[inline]
fn div_rem(&self, other: &$T) -> ($T,$T) {
(*self / *other, *self % *other)
}
@ -397,7 +397,7 @@ impl Integer for $T {
///
/// The result is always positive
///
#[inline(always)]
#[inline]
fn gcd(&self, other: &$T) -> $T {
// Use Euclid's algorithm
let mut (m, n) = (*self, *other);
@ -412,21 +412,21 @@ impl Integer for $T {
///
/// Calculates the Lowest Common Multiple (LCM) of the number and `other`
///
#[inline(always)]
#[inline]
fn lcm(&self, other: &$T) -> $T {
((*self * *other) / self.gcd(other)).abs() // should not have to recaluculate abs
}
/// Returns `true` if the number can be divided by `other` without leaving a remainder
#[inline(always)]
#[inline]
fn is_multiple_of(&self, other: &$T) -> bool { *self % *other == 0 }
/// Returns `true` if the number is divisible by `2`
#[inline(always)]
#[inline]
fn is_even(&self) -> bool { self.is_multiple_of(&2) }
/// Returns `true` if the number is not divisible by `2`
#[inline(always)]
#[inline]
fn is_odd(&self) -> bool { !self.is_even() }
}
@ -434,90 +434,90 @@ impl Bitwise for $T {}
#[cfg(not(test))]
impl BitOr<$T,$T> for $T {
#[inline(always)]
#[inline]
fn bitor(&self, other: &$T) -> $T { *self | *other }
}
#[cfg(not(test))]
impl BitAnd<$T,$T> for $T {
#[inline(always)]
#[inline]
fn bitand(&self, other: &$T) -> $T { *self & *other }
}
#[cfg(not(test))]
impl BitXor<$T,$T> for $T {
#[inline(always)]
#[inline]
fn bitxor(&self, other: &$T) -> $T { *self ^ *other }
}
#[cfg(not(test))]
impl Shl<$T,$T> for $T {
#[inline(always)]
#[inline]
fn shl(&self, other: &$T) -> $T { *self << *other }
}
#[cfg(not(test))]
impl Shr<$T,$T> for $T {
#[inline(always)]
#[inline]
fn shr(&self, other: &$T) -> $T { *self >> *other }
}
#[cfg(not(test))]
impl Not<$T> for $T {
#[inline(always)]
#[inline]
fn not(&self) -> $T { !*self }
}
impl Bounded for $T {
#[inline(always)]
#[inline]
fn min_value() -> $T { min_value }
#[inline(always)]
#[inline]
fn max_value() -> $T { max_value }
}
impl Int for $T {}
impl Primitive for $T {
#[inline(always)]
#[inline]
fn bits() -> uint { bits }
#[inline(always)]
#[inline]
fn bytes() -> uint { bits / 8 }
}
// String conversion functions and impl str -> num
/// Parse a string as a number in base 10.
#[inline(always)]
#[inline]
pub fn from_str(s: &str) -> Option<$T> {
strconv::from_str_common(s, 10u, true, false, false,
strconv::ExpNone, false, false)
}
/// Parse a string as a number in the given base.
#[inline(always)]
#[inline]
pub fn from_str_radix(s: &str, radix: uint) -> Option<$T> {
strconv::from_str_common(s, radix, true, false, false,
strconv::ExpNone, false, false)
}
/// Parse a byte slice as a number in the given base.
#[inline(always)]
#[inline]
pub fn parse_bytes(buf: &[u8], radix: uint) -> Option<$T> {
strconv::from_str_bytes_common(buf, radix, true, false, false,
strconv::ExpNone, false, false)
}
impl FromStr for $T {
#[inline(always)]
#[inline]
fn from_str(s: &str) -> Option<$T> {
from_str(s)
}
}
impl FromStrRadix for $T {
#[inline(always)]
#[inline]
fn from_str_radix(s: &str, radix: uint) -> Option<$T> {
from_str_radix(s, radix)
}
@ -526,7 +526,7 @@ impl FromStrRadix for $T {
// String conversion functions and impl num -> str
/// Convert to a string as a byte slice in a given base.
#[inline(always)]
#[inline]
pub fn to_str_bytes<U>(n: $T, radix: uint, f: &fn(v: &[u8]) -> U) -> U {
let (buf, _) = strconv::to_str_bytes_common(&n, radix, false,
strconv::SignNeg, strconv::DigAll);
@ -534,7 +534,7 @@ pub fn to_str_bytes<U>(n: $T, radix: uint, f: &fn(v: &[u8]) -> U) -> U {
}
/// Convert to a string in base 10.
#[inline(always)]
#[inline]
pub fn to_str(num: $T) -> ~str {
let (buf, _) = strconv::to_str_common(&num, 10u, false,
strconv::SignNeg, strconv::DigAll);
@ -542,7 +542,7 @@ pub fn to_str(num: $T) -> ~str {
}
/// Convert to a string in a given base.
#[inline(always)]
#[inline]
pub fn to_str_radix(num: $T, radix: uint) -> ~str {
let (buf, _) = strconv::to_str_common(&num, radix, false,
strconv::SignNeg, strconv::DigAll);
@ -550,14 +550,14 @@ pub fn to_str_radix(num: $T, radix: uint) -> ~str {
}
impl ToStr for $T {
#[inline(always)]
#[inline]
fn to_str(&self) -> ~str {
to_str(*self)
}
}
impl ToStrRadix for $T {
#[inline(always)]
#[inline]
fn to_str_radix(&self, radix: uint) -> ~str {
to_str_radix(*self, radix)
}

View file

@ -307,7 +307,7 @@ pub trait Float: Real
/// assert_eq!(twenty, 20f32);
/// ~~~
///
#[inline(always)]
#[inline]
pub fn cast<T:NumCast,U:NumCast>(n: T) -> U {
NumCast::from(n)
}
@ -338,28 +338,28 @@ pub trait NumCast {
macro_rules! impl_num_cast(
($T:ty, $conv:ident) => (
impl NumCast for $T {
#[inline(always)]
#[inline]
fn from<N:NumCast>(n: N) -> $T {
// `$conv` could be generated using `concat_idents!`, but that
// macro seems to be broken at the moment
n.$conv()
}
#[inline(always)] fn to_u8(&self) -> u8 { *self as u8 }
#[inline(always)] fn to_u16(&self) -> u16 { *self as u16 }
#[inline(always)] fn to_u32(&self) -> u32 { *self as u32 }
#[inline(always)] fn to_u64(&self) -> u64 { *self as u64 }
#[inline(always)] fn to_uint(&self) -> uint { *self as uint }
#[inline] fn to_u8(&self) -> u8 { *self as u8 }
#[inline] fn to_u16(&self) -> u16 { *self as u16 }
#[inline] fn to_u32(&self) -> u32 { *self as u32 }
#[inline] fn to_u64(&self) -> u64 { *self as u64 }
#[inline] fn to_uint(&self) -> uint { *self as uint }
#[inline(always)] fn to_i8(&self) -> i8 { *self as i8 }
#[inline(always)] fn to_i16(&self) -> i16 { *self as i16 }
#[inline(always)] fn to_i32(&self) -> i32 { *self as i32 }
#[inline(always)] fn to_i64(&self) -> i64 { *self as i64 }
#[inline(always)] fn to_int(&self) -> int { *self as int }
#[inline] fn to_i8(&self) -> i8 { *self as i8 }
#[inline] fn to_i16(&self) -> i16 { *self as i16 }
#[inline] fn to_i32(&self) -> i32 { *self as i32 }
#[inline] fn to_i64(&self) -> i64 { *self as i64 }
#[inline] fn to_int(&self) -> int { *self as int }
#[inline(always)] fn to_f32(&self) -> f32 { *self as f32 }
#[inline(always)] fn to_f64(&self) -> f64 { *self as f64 }
#[inline(always)] fn to_float(&self) -> float { *self as float }
#[inline] fn to_f32(&self) -> f32 { *self as f32 }
#[inline] fn to_f64(&self) -> f64 { *self as f64 }
#[inline] fn to_float(&self) -> float { *self as float }
}
)
)

View file

@ -42,12 +42,12 @@ pub enum SignFormat {
SignAll
}
#[inline(always)]
#[inline]
fn is_NaN<T:Eq>(num: &T) -> bool {
*num != *num
}
#[inline(always)]
#[inline]
fn is_inf<T:Eq+NumStrConv>(num: &T) -> bool {
match NumStrConv::inf() {
None => false,
@ -55,7 +55,7 @@ fn is_inf<T:Eq+NumStrConv>(num: &T) -> bool {
}
}
#[inline(always)]
#[inline]
fn is_neg_inf<T:Eq+NumStrConv>(num: &T) -> bool {
match NumStrConv::neg_inf() {
None => false,
@ -63,7 +63,7 @@ fn is_neg_inf<T:Eq+NumStrConv>(num: &T) -> bool {
}
}
#[inline(always)]
#[inline]
fn is_neg_zero<T:Eq+One+Zero+NumStrConv+Div<T,T>>(num: &T) -> bool {
let _0: T = Zero::zero();
let _1: T = One::one();
@ -83,23 +83,23 @@ pub trait NumStrConv {
macro_rules! impl_NumStrConv_Floating (($t:ty) => (
impl NumStrConv for $t {
#[inline(always)]
#[inline]
fn NaN() -> Option<$t> { Some( 0.0 / 0.0) }
#[inline(always)]
#[inline]
fn inf() -> Option<$t> { Some( 1.0 / 0.0) }
#[inline(always)]
#[inline]
fn neg_inf() -> Option<$t> { Some(-1.0 / 0.0) }
#[inline(always)]
#[inline]
fn neg_zero() -> Option<$t> { Some(-0.0 ) }
#[inline(always)]
#[inline]
fn round_to_zero(&self) -> $t {
( if *self < 0.0 { f64::ceil(*self as f64) }
else { f64::floor(*self as f64) }
) as $t
}
#[inline(always)]
#[inline]
fn fractional_part(&self) -> $t {
*self - self.round_to_zero()
}
@ -108,13 +108,13 @@ macro_rules! impl_NumStrConv_Floating (($t:ty) => (
macro_rules! impl_NumStrConv_Integer (($t:ty) => (
impl NumStrConv for $t {
#[inline(always)] fn NaN() -> Option<$t> { None }
#[inline(always)] fn inf() -> Option<$t> { None }
#[inline(always)] fn neg_inf() -> Option<$t> { None }
#[inline(always)] fn neg_zero() -> Option<$t> { None }
#[inline] fn NaN() -> Option<$t> { None }
#[inline] fn inf() -> Option<$t> { None }
#[inline] fn neg_inf() -> Option<$t> { None }
#[inline] fn neg_zero() -> Option<$t> { None }
#[inline(always)] fn round_to_zero(&self) -> $t { *self }
#[inline(always)] fn fractional_part(&self) -> $t { 0 }
#[inline] fn round_to_zero(&self) -> $t { *self }
#[inline] fn fractional_part(&self) -> $t { 0 }
}
))
@ -381,7 +381,7 @@ pub fn to_str_bytes_common<T:NumCast+Zero+One+Eq+Ord+NumStrConv+Copy+
* Converts a number to its string representation. This is a wrapper for
* `to_str_bytes_common()`, for details see there.
*/
#[inline(always)]
#[inline]
pub fn to_str_common<T:NumCast+Zero+One+Eq+Ord+NumStrConv+Copy+
Div<T,T>+Neg<T>+Rem<T,T>+Mul<T,T>>(
num: &T, radix: uint, negative_zero: bool,
@ -632,7 +632,7 @@ pub fn from_str_bytes_common<T:NumCast+Zero+One+Eq+Ord+Copy+Div<T,T>+
* Parses a string as a number. This is a wrapper for
* `from_str_bytes_common()`, for details see there.
*/
#[inline(always)]
#[inline]
pub fn from_str_common<T:NumCast+Zero+One+Eq+Ord+Copy+Div<T,T>+Mul<T,T>+
Sub<T,T>+Neg<T>+Add<T,T>+NumStrConv>(
buf: &str, radix: uint, negative: bool, fractional: bool,

View file

@ -95,7 +95,7 @@ pub fn iterate(lo: uint, hi: uint, it: &fn(uint) -> bool) -> bool {
}
impl iter::Times for uint {
#[inline(always)]
#[inline]
///
/// A convenience form for basic iteration. Given a uint `x`,
/// `for x.times { ... }` executes the given block x times.
@ -117,7 +117,7 @@ impl iter::Times for uint {
}
/// Returns the smallest power of 2 greater than or equal to `n`
#[inline(always)]
#[inline]
pub fn next_power_of_two(n: uint) -> uint {
let halfbits: uint = sys::size_of::<uint>() * 4u;
let mut tmp: uint = n - 1u;

View file

@ -28,42 +28,42 @@ pub static min_value: $T = 0 as $T;
pub static max_value: $T = 0 as $T - 1 as $T;
/// Calculates the sum of two numbers
#[inline(always)]
#[inline]
pub fn add(x: $T, y: $T) -> $T { x + y }
/// Subtracts the second number from the first
#[inline(always)]
#[inline]
pub fn sub(x: $T, y: $T) -> $T { x - y }
/// Multiplies two numbers together
#[inline(always)]
#[inline]
pub fn mul(x: $T, y: $T) -> $T { x * y }
/// Divides the first argument by the second argument (using integer division)
#[inline(always)]
#[inline]
pub fn div(x: $T, y: $T) -> $T { x / y }
/// Calculates the integer remainder when x is divided by y (equivalent to the
/// '%' operator)
#[inline(always)]
#[inline]
pub fn rem(x: $T, y: $T) -> $T { x % y }
/// Returns true iff `x < y`
#[inline(always)]
#[inline]
pub fn lt(x: $T, y: $T) -> bool { x < y }
/// Returns true iff `x <= y`
#[inline(always)]
#[inline]
pub fn le(x: $T, y: $T) -> bool { x <= y }
/// Returns true iff `x == y`
#[inline(always)]
#[inline]
pub fn eq(x: $T, y: $T) -> bool { x == y }
/// Returns true iff `x != y`
#[inline(always)]
#[inline]
pub fn ne(x: $T, y: $T) -> bool { x != y }
/// Returns true iff `x >= y`
#[inline(always)]
#[inline]
pub fn ge(x: $T, y: $T) -> bool { x >= y }
/// Returns true iff `x > y`
#[inline(always)]
#[inline]
pub fn gt(x: $T, y: $T) -> bool { x > y }
#[inline(always)]
#[inline]
/**
* Iterate through a range with a given step value.
*
@ -99,20 +99,20 @@ pub fn range_step(start: $T, stop: $T, step: $T_SIGNED, it: &fn($T) -> bool) ->
return true;
}
#[inline(always)]
#[inline]
/// Iterate over the range [`lo`..`hi`)
pub fn range(lo: $T, hi: $T, it: &fn($T) -> bool) -> bool {
range_step(lo, hi, 1 as $T_SIGNED, it)
}
#[inline(always)]
#[inline]
/// Iterate over the range [`hi`..`lo`)
pub fn range_rev(hi: $T, lo: $T, it: &fn($T) -> bool) -> bool {
range_step(hi, lo, -1 as $T_SIGNED, it)
}
/// Computes the bitwise complement
#[inline(always)]
#[inline]
pub fn compl(i: $T) -> $T {
max_value ^ i
}
@ -121,37 +121,37 @@ impl Num for $T {}
#[cfg(not(test))]
impl Ord for $T {
#[inline(always)]
#[inline]
fn lt(&self, other: &$T) -> bool { (*self) < (*other) }
#[inline(always)]
#[inline]
fn le(&self, other: &$T) -> bool { (*self) <= (*other) }
#[inline(always)]
#[inline]
fn ge(&self, other: &$T) -> bool { (*self) >= (*other) }
#[inline(always)]
#[inline]
fn gt(&self, other: &$T) -> bool { (*self) > (*other) }
}
#[cfg(not(test))]
impl Eq for $T {
#[inline(always)]
#[inline]
fn eq(&self, other: &$T) -> bool { return (*self) == (*other); }
#[inline(always)]
#[inline]
fn ne(&self, other: &$T) -> bool { return (*self) != (*other); }
}
impl Orderable for $T {
#[inline(always)]
#[inline]
fn min(&self, other: &$T) -> $T {
if *self < *other { *self } else { *other }
}
#[inline(always)]
#[inline]
fn max(&self, other: &$T) -> $T {
if *self > *other { *self } else { *other }
}
/// Returns the number constrained within the range `mn <= self <= mx`.
#[inline(always)]
#[inline]
fn clamp(&self, mn: &$T, mx: &$T) -> $T {
cond!(
(*self > *mx) { *mx }
@ -162,51 +162,51 @@ impl Orderable for $T {
}
impl Zero for $T {
#[inline(always)]
#[inline]
fn zero() -> $T { 0 }
#[inline(always)]
#[inline]
fn is_zero(&self) -> bool { *self == 0 }
}
impl One for $T {
#[inline(always)]
#[inline]
fn one() -> $T { 1 }
}
#[cfg(not(test))]
impl Add<$T,$T> for $T {
#[inline(always)]
#[inline]
fn add(&self, other: &$T) -> $T { *self + *other }
}
#[cfg(not(test))]
impl Sub<$T,$T> for $T {
#[inline(always)]
#[inline]
fn sub(&self, other: &$T) -> $T { *self - *other }
}
#[cfg(not(test))]
impl Mul<$T,$T> for $T {
#[inline(always)]
#[inline]
fn mul(&self, other: &$T) -> $T { *self * *other }
}
#[cfg(not(test))]
impl Div<$T,$T> for $T {
#[inline(always)]
#[inline]
fn div(&self, other: &$T) -> $T { *self / *other }
}
#[cfg(not(test))]
impl Rem<$T,$T> for $T {
#[inline(always)]
#[inline]
fn rem(&self, other: &$T) -> $T { *self % *other }
}
#[cfg(not(test))]
impl Neg<$T> for $T {
#[inline(always)]
#[inline]
fn neg(&self) -> $T { -*self }
}
@ -214,27 +214,27 @@ impl Unsigned for $T {}
impl Integer for $T {
/// Calculates `div` (`\`) and `rem` (`%`) simultaneously
#[inline(always)]
#[inline]
fn div_rem(&self, other: &$T) -> ($T,$T) {
(*self / *other, *self % *other)
}
/// Unsigned integer division. Returns the same result as `div` (`/`).
#[inline(always)]
#[inline]
fn div_floor(&self, other: &$T) -> $T { *self / *other }
/// Unsigned integer modulo operation. Returns the same result as `rem` (`%`).
#[inline(always)]
#[inline]
fn mod_floor(&self, other: &$T) -> $T { *self / *other }
/// Calculates `div_floor` and `modulo_floor` simultaneously
#[inline(always)]
#[inline]
fn div_mod_floor(&self, other: &$T) -> ($T,$T) {
(*self / *other, *self % *other)
}
/// Calculates the Greatest Common Divisor (GCD) of the number and `other`
#[inline(always)]
#[inline]
fn gcd(&self, other: &$T) -> $T {
// Use Euclid's algorithm
let mut (m, n) = (*self, *other);
@ -247,21 +247,21 @@ impl Integer for $T {
}
/// Calculates the Lowest Common Multiple (LCM) of the number and `other`
#[inline(always)]
#[inline]
fn lcm(&self, other: &$T) -> $T {
(*self * *other) / self.gcd(other)
}
/// Returns `true` if the number can be divided by `other` without leaving a remainder
#[inline(always)]
#[inline]
fn is_multiple_of(&self, other: &$T) -> bool { *self % *other == 0 }
/// Returns `true` if the number is divisible by `2`
#[inline(always)]
#[inline]
fn is_even(&self) -> bool { self.is_multiple_of(&2) }
/// Returns `true` if the number is not divisible by `2`
#[inline(always)]
#[inline]
fn is_odd(&self) -> bool { !self.is_even() }
}
@ -269,45 +269,45 @@ impl Bitwise for $T {}
#[cfg(not(test))]
impl BitOr<$T,$T> for $T {
#[inline(always)]
#[inline]
fn bitor(&self, other: &$T) -> $T { *self | *other }
}
#[cfg(not(test))]
impl BitAnd<$T,$T> for $T {
#[inline(always)]
#[inline]
fn bitand(&self, other: &$T) -> $T { *self & *other }
}
#[cfg(not(test))]
impl BitXor<$T,$T> for $T {
#[inline(always)]
#[inline]
fn bitxor(&self, other: &$T) -> $T { *self ^ *other }
}
#[cfg(not(test))]
impl Shl<$T,$T> for $T {
#[inline(always)]
#[inline]
fn shl(&self, other: &$T) -> $T { *self << *other }
}
#[cfg(not(test))]
impl Shr<$T,$T> for $T {
#[inline(always)]
#[inline]
fn shr(&self, other: &$T) -> $T { *self >> *other }
}
#[cfg(not(test))]
impl Not<$T> for $T {
#[inline(always)]
#[inline]
fn not(&self) -> $T { !*self }
}
impl Bounded for $T {
#[inline(always)]
#[inline]
fn min_value() -> $T { min_value }
#[inline(always)]
#[inline]
fn max_value() -> $T { max_value }
}
@ -316,35 +316,35 @@ impl Int for $T {}
// String conversion functions and impl str -> num
/// Parse a string as a number in base 10.
#[inline(always)]
#[inline]
pub fn from_str(s: &str) -> Option<$T> {
strconv::from_str_common(s, 10u, false, false, false,
strconv::ExpNone, false, false)
}
/// Parse a string as a number in the given base.
#[inline(always)]
#[inline]
pub fn from_str_radix(s: &str, radix: uint) -> Option<$T> {
strconv::from_str_common(s, radix, false, false, false,
strconv::ExpNone, false, false)
}
/// Parse a byte slice as a number in the given base.
#[inline(always)]
#[inline]
pub fn parse_bytes(buf: &[u8], radix: uint) -> Option<$T> {
strconv::from_str_bytes_common(buf, radix, false, false, false,
strconv::ExpNone, false, false)
}
impl FromStr for $T {
#[inline(always)]
#[inline]
fn from_str(s: &str) -> Option<$T> {
from_str(s)
}
}
impl FromStrRadix for $T {
#[inline(always)]
#[inline]
fn from_str_radix(s: &str, radix: uint) -> Option<$T> {
from_str_radix(s, radix)
}
@ -353,7 +353,7 @@ impl FromStrRadix for $T {
// String conversion functions and impl num -> str
/// Convert to a string as a byte slice in a given base.
#[inline(always)]
#[inline]
pub fn to_str_bytes<U>(n: $T, radix: uint, f: &fn(v: &[u8]) -> U) -> U {
let (buf, _) = strconv::to_str_bytes_common(&n, radix, false,
strconv::SignNeg, strconv::DigAll);
@ -361,7 +361,7 @@ pub fn to_str_bytes<U>(n: $T, radix: uint, f: &fn(v: &[u8]) -> U) -> U {
}
/// Convert to a string in base 10.
#[inline(always)]
#[inline]
pub fn to_str(num: $T) -> ~str {
let (buf, _) = strconv::to_str_common(&num, 10u, false,
strconv::SignNeg, strconv::DigAll);
@ -369,7 +369,7 @@ pub fn to_str(num: $T) -> ~str {
}
/// Convert to a string in a given base.
#[inline(always)]
#[inline]
pub fn to_str_radix(num: $T, radix: uint) -> ~str {
let (buf, _) = strconv::to_str_common(&num, radix, false,
strconv::SignNeg, strconv::DigAll);
@ -377,42 +377,42 @@ pub fn to_str_radix(num: $T, radix: uint) -> ~str {
}
impl ToStr for $T {
#[inline(always)]
#[inline]
fn to_str(&self) -> ~str {
to_str(*self)
}
}
impl ToStrRadix for $T {
#[inline(always)]
#[inline]
fn to_str_radix(&self, radix: uint) -> ~str {
to_str_radix(*self, radix)
}
}
impl Primitive for $T {
#[inline(always)]
#[inline]
fn bits() -> uint { bits }
#[inline(always)]
#[inline]
fn bytes() -> uint { bits / 8 }
}
impl BitCount for $T {
/// Counts the number of bits set. Wraps LLVM's `ctpop` intrinsic.
#[inline(always)]
#[inline]
fn population_count(&self) -> $T {
(*self as $T_SIGNED).population_count() as $T
}
/// Counts the number of leading zeros. Wraps LLVM's `ctlz` intrinsic.
#[inline(always)]
#[inline]
fn leading_zeros(&self) -> $T {
(*self as $T_SIGNED).leading_zeros() as $T
}
/// Counts the number of trailing zeros. Wraps LLVM's `cttz` intrinsic.
#[inline(always)]
#[inline]
fn trailing_zeros(&self) -> $T {
(*self as $T_SIGNED).trailing_zeros() as $T
}

View file

@ -73,7 +73,7 @@ pub trait Buildable<A> {
fn build_sized(size: uint, builder: &fn(push: &fn(A))) -> Self;
}
#[inline(always)]
#[inline]
pub fn _eachi<A,IA:BaseIter<A>>(this: &IA, blk: &fn(uint, &A) -> bool) -> bool {
let mut i = 0;
for this.each |a| {
@ -89,7 +89,7 @@ pub fn eachi<A,IA:BaseIter<A>>(this: &IA, blk: &fn(uint, &A) -> bool) -> bool {
_eachi(this, blk)
}
#[inline(always)]
#[inline]
pub fn all<A,IA:BaseIter<A>>(this: &IA, blk: &fn(&A) -> bool) -> bool {
for this.each |a| {
if !blk(a) {
@ -99,7 +99,7 @@ pub fn all<A,IA:BaseIter<A>>(this: &IA, blk: &fn(&A) -> bool) -> bool {
return true;
}
#[inline(always)]
#[inline]
pub fn any<A,IA:BaseIter<A>>(this: &IA, blk: &fn(&A) -> bool) -> bool {
for this.each |a| {
if blk(a) {
@ -109,7 +109,7 @@ pub fn any<A,IA:BaseIter<A>>(this: &IA, blk: &fn(&A) -> bool) -> bool {
return false;
}
#[inline(always)]
#[inline]
pub fn filter_to_vec<A:Copy,IA:BaseIter<A>>(this: &IA,
prd: &fn(&A) -> bool)
-> ~[A] {
@ -120,7 +120,7 @@ pub fn filter_to_vec<A:Copy,IA:BaseIter<A>>(this: &IA,
}
}
#[inline(always)]
#[inline]
pub fn map_to_vec<A,B,IA:BaseIter<A>>(this: &IA, op: &fn(&A) -> B) -> ~[B] {
do vec::build_sized_opt(this.size_hint()) |push| {
for this.each |a| {
@ -129,7 +129,7 @@ pub fn map_to_vec<A,B,IA:BaseIter<A>>(this: &IA, op: &fn(&A) -> B) -> ~[B] {
}
}
#[inline(always)]
#[inline]
pub fn flat_map_to_vec<A,B,IA:BaseIter<A>,IB:BaseIter<B>>(this: &IA,
op: &fn(&A) -> IB)
-> ~[B] {
@ -142,7 +142,7 @@ pub fn flat_map_to_vec<A,B,IA:BaseIter<A>,IB:BaseIter<B>>(this: &IA,
}
}
#[inline(always)]
#[inline]
pub fn foldl<A,B,IA:BaseIter<A>>(this: &IA, b0: B, blk: &fn(&B, &A) -> B)
-> B {
let mut b = b0;
@ -152,12 +152,12 @@ pub fn foldl<A,B,IA:BaseIter<A>>(this: &IA, b0: B, blk: &fn(&B, &A) -> B)
b
}
#[inline(always)]
#[inline]
pub fn to_vec<A:Copy,IA:BaseIter<A>>(this: &IA) -> ~[A] {
map_to_vec(this, |&x| x)
}
#[inline(always)]
#[inline]
pub fn contains<A:Eq,IA:BaseIter<A>>(this: &IA, x: &A) -> bool {
for this.each |a| {
if *a == *x { return true; }
@ -165,7 +165,7 @@ pub fn contains<A:Eq,IA:BaseIter<A>>(this: &IA, x: &A) -> bool {
return false;
}
#[inline(always)]
#[inline]
pub fn count<A:Eq,IA:BaseIter<A>>(this: &IA, x: &A) -> uint {
do foldl(this, 0) |count, value| {
if *value == *x {
@ -176,7 +176,7 @@ pub fn count<A:Eq,IA:BaseIter<A>>(this: &IA, x: &A) -> uint {
}
}
#[inline(always)]
#[inline]
pub fn position<A,IA:BaseIter<A>>(this: &IA, f: &fn(&A) -> bool)
-> Option<uint> {
let mut i = 0;
@ -187,7 +187,7 @@ pub fn position<A,IA:BaseIter<A>>(this: &IA, f: &fn(&A) -> bool)
return None;
}
#[inline(always)]
#[inline]
pub fn find<A:Copy,IA:BaseIter<A>>(this: &IA, f: &fn(&A) -> bool)
-> Option<A> {
for this.each |i| {
@ -208,7 +208,7 @@ pub fn find<A:Copy,IA:BaseIter<A>>(this: &IA, f: &fn(&A) -> bool)
* as an argument a function that will push an element
* onto the sequence being constructed.
*/
#[inline(always)]
#[inline]
pub fn build<A,B: Buildable<A>>(builder: &fn(push: &fn(A))) -> B {
Buildable::build_sized(4, builder)
}
@ -226,7 +226,7 @@ pub fn build<A,B: Buildable<A>>(builder: &fn(push: &fn(A))) -> B {
* as an argument a function that will push an element
* onto the sequence being constructed.
*/
#[inline(always)]
#[inline]
pub fn build_sized_opt<A,B: Buildable<A>>(size: Option<uint>,
builder: &fn(push: &fn(A))) -> B {
Buildable::build_sized(size.get_or_default(4), builder)
@ -236,7 +236,7 @@ pub fn build_sized_opt<A,B: Buildable<A>>(size: Option<uint>,
/// Applies a function to each element of an iterable and returns the results
/// in a sequence built via `BU`. See also `map_to_vec`.
#[inline(always)]
#[inline]
pub fn map<T,IT: BaseIter<T>,U,BU: Buildable<U>>(v: &IT, f: &fn(&T) -> U)
-> BU {
do build_sized_opt(v.size_hint()) |push| {
@ -252,7 +252,7 @@ pub fn map<T,IT: BaseIter<T>,U,BU: Buildable<U>>(v: &IT, f: &fn(&T) -> U)
* Creates a generic sequence of size `n_elts` and initializes the elements
* to the value returned by the function `op`.
*/
#[inline(always)]
#[inline]
pub fn from_fn<T,BT: Buildable<T>>(n_elts: uint, op: InitOp<T>) -> BT {
do Buildable::build_sized(n_elts) |push| {
let mut i: uint = 0u;
@ -266,7 +266,7 @@ pub fn from_fn<T,BT: Buildable<T>>(n_elts: uint, op: InitOp<T>) -> BT {
* Creates an immutable vector of size `n_elts` and initializes the elements
* to the value `t`.
*/
#[inline(always)]
#[inline]
pub fn from_elem<T:Copy,BT:Buildable<T>>(n_elts: uint, t: T) -> BT {
do Buildable::build_sized(n_elts) |push| {
let mut i: uint = 0;
@ -275,7 +275,7 @@ pub fn from_elem<T:Copy,BT:Buildable<T>>(n_elts: uint, t: T) -> BT {
}
/// Appends two generic sequences.
#[inline(always)]
#[inline]
pub fn append<T:Copy,IT:BaseIter<T>,BT:Buildable<T>>(lhs: &IT, rhs: &IT)
-> BT {
let size_opt = lhs.size_hint().chain_ref(
@ -288,7 +288,7 @@ pub fn append<T:Copy,IT:BaseIter<T>,BT:Buildable<T>>(lhs: &IT, rhs: &IT)
/// Copies a generic sequence, possibly converting it to a different
/// type of sequence.
#[inline(always)]
#[inline]
pub fn copy_seq<T:Copy,IT:BaseIter<T>,BT:Buildable<T>>(v: &IT) -> BT {
do build_sized_opt(v.size_hint()) |push| {
for v.each |x| { push(copy *x); }

View file

@ -89,7 +89,7 @@ impl<T:Ord> Ord for Option<T> {
}
impl<T: Copy+Add<T,T>> Add<Option<T>, Option<T>> for Option<T> {
#[inline(always)]
#[inline]
fn add(&self, other: &Option<T>) -> Option<T> {
match (&*self, &*other) {
(&None, &None) => None,
@ -126,12 +126,12 @@ impl<T> Option<T> {
}
/// Returns true if the option contains some value
#[inline(always)]
#[inline]
pub fn is_some(&const self) -> bool { !self.is_none() }
/// Update an optional value by optionally running its content through a
/// function that returns an option.
#[inline(always)]
#[inline]
pub fn chain<U>(self, f: &fn(t: T) -> Option<U>) -> Option<U> {
match self {
Some(t) => f(t),
@ -140,7 +140,7 @@ impl<T> Option<T> {
}
/// Returns the leftmost Some() value, or None if both are None.
#[inline(always)]
#[inline]
pub fn or(self, optb: Option<T>) -> Option<T> {
match self {
Some(opta) => Some(opta),
@ -150,7 +150,7 @@ impl<T> Option<T> {
/// Update an optional value by optionally running its content by reference
/// through a function that returns an option.
#[inline(always)]
#[inline]
pub fn chain_ref<'a, U>(&'a self, f: &fn(x: &'a T) -> Option<U>)
-> Option<U> {
match *self {
@ -160,27 +160,27 @@ impl<T> Option<T> {
}
/// Maps a `some` value from one type to another by reference
#[inline(always)]
#[inline]
pub fn map<'a, U>(&self, f: &fn(&'a T) -> U) -> Option<U> {
match *self { Some(ref x) => Some(f(x)), None => None }
}
/// As `map`, but consumes the option and gives `f` ownership to avoid
/// copying.
#[inline(always)]
#[inline]
pub fn map_consume<U>(self, f: &fn(v: T) -> U) -> Option<U> {
match self { None => None, Some(v) => Some(f(v)) }
}
/// Applies a function to the contained value or returns a default
#[inline(always)]
#[inline]
pub fn map_default<'a, U>(&'a self, def: U, f: &fn(&'a T) -> U) -> U {
match *self { None => def, Some(ref t) => f(t) }
}
/// As `map_default`, but consumes the option and gives `f`
/// ownership to avoid copying.
#[inline(always)]
#[inline]
pub fn map_consume_default<U>(self, def: U, f: &fn(v: T) -> U) -> U {
match self { None => def, Some(v) => f(v) }
}
@ -215,7 +215,7 @@ impl<T> Option<T> {
Instead, prefer to use pattern matching and handle the `None`
case explicitly.
*/
#[inline(always)]
#[inline]
pub fn get_ref<'a>(&'a self) -> &'a T {
match *self {
Some(ref x) => x,
@ -237,7 +237,7 @@ impl<T> Option<T> {
Instead, prefer to use pattern matching and handle the `None`
case explicitly.
*/
#[inline(always)]
#[inline]
pub fn get_mut_ref<'a>(&'a mut self) -> &'a mut T {
match *self {
Some(ref mut x) => x,
@ -245,7 +245,7 @@ impl<T> Option<T> {
}
}
#[inline(always)]
#[inline]
pub fn unwrap(self) -> T {
/*!
Moves a value out of an option type and returns it.
@ -277,7 +277,7 @@ impl<T> Option<T> {
*
* Fails if the value equals `None`.
*/
#[inline(always)]
#[inline]
pub fn swap_unwrap(&mut self) -> T {
if self.is_none() { fail!("option::swap_unwrap none") }
util::replace(self, None).unwrap()
@ -291,7 +291,7 @@ impl<T> Option<T> {
*
* Fails if the value equals `none`
*/
#[inline(always)]
#[inline]
pub fn expect(self, reason: &str) -> T {
match self {
Some(val) => val,
@ -315,7 +315,7 @@ impl<T:Copy> Option<T> {
Instead, prefer to use pattern matching and handle the `None`
case explicitly.
*/
#[inline(always)]
#[inline]
pub fn get(self) -> T {
match self {
Some(x) => return x,
@ -324,13 +324,13 @@ impl<T:Copy> Option<T> {
}
/// Returns the contained value or a default
#[inline(always)]
#[inline]
pub fn get_or_default(self, def: T) -> T {
match self { Some(x) => x, None => def }
}
/// Applies a function zero or more times until the result is none.
#[inline(always)]
#[inline]
pub fn while_some(self, blk: &fn(v: T) -> Option<T>) {
let mut opt = self;
while opt.is_some() {
@ -341,7 +341,7 @@ impl<T:Copy> Option<T> {
impl<T:Copy + Zero> Option<T> {
/// Returns the contained value or zero (for this type)
#[inline(always)]
#[inline]
pub fn get_or_zero(self) -> T {
match self {
Some(x) => x,

View file

@ -14,20 +14,20 @@
#[cfg(not(test))]
impl<T:Eq> Eq for ~T {
#[inline(always)]
#[inline]
fn eq(&self, other: &~T) -> bool { *(*self) == *(*other) }
#[inline(always)]
#[inline]
fn ne(&self, other: &~T) -> bool { *(*self) != *(*other) }
}
#[cfg(not(test))]
impl<T:Ord> Ord for ~T {
#[inline(always)]
#[inline]
fn lt(&self, other: &~T) -> bool { *(*self) < *(*other) }
#[inline(always)]
#[inline]
fn le(&self, other: &~T) -> bool { *(*self) <= *(*other) }
#[inline(always)]
#[inline]
fn ge(&self, other: &~T) -> bool { *(*self) >= *(*other) }
#[inline(always)]
#[inline]
fn gt(&self, other: &~T) -> bool { *(*self) > *(*other) }
}

View file

@ -904,7 +904,7 @@ pub mod windows {
use libc;
use option::{None, Option, Some};
#[inline(always)]
#[inline]
pub fn is_sep(u: char) -> bool {
u == '/' || u == '\\'
}

View file

@ -19,31 +19,31 @@ use unstable::intrinsics;
use uint;
/// Calculate the offset from a pointer
#[inline(always)]
#[inline]
pub fn offset<T>(ptr: *T, count: uint) -> *T {
(ptr as uint + count * sys::size_of::<T>()) as *T
}
/// Calculate the offset from a const pointer
#[inline(always)]
#[inline]
pub fn const_offset<T>(ptr: *const T, count: uint) -> *const T {
(ptr as uint + count * sys::size_of::<T>()) as *T
}
/// Calculate the offset from a mut pointer
#[inline(always)]
#[inline]
pub fn mut_offset<T>(ptr: *mut T, count: uint) -> *mut T {
(ptr as uint + count * sys::size_of::<T>()) as *mut T
}
/// Return the offset of the first null pointer in `buf`.
#[inline(always)]
#[inline]
pub unsafe fn buf_len<T>(buf: **T) -> uint {
position(buf, |i| *i == null())
}
/// Return the first offset `i` such that `f(buf[i]) == true`.
#[inline(always)]
#[inline]
pub unsafe fn position<T>(buf: *T, f: &fn(&T) -> bool) -> uint {
let mut i = 0;
loop {
@ -53,19 +53,19 @@ pub unsafe fn position<T>(buf: *T, f: &fn(&T) -> bool) -> uint {
}
/// Create an unsafe null pointer
#[inline(always)]
#[inline]
pub fn null<T>() -> *T { 0 as *T }
/// Create an unsafe mutable null pointer
#[inline(always)]
#[inline]
pub fn mut_null<T>() -> *mut T { 0 as *mut T }
/// Returns true if the pointer is equal to the null pointer.
#[inline(always)]
#[inline]
pub fn is_null<T>(ptr: *const T) -> bool { ptr == null() }
/// Returns true if the pointer is not equal to the null pointer.
#[inline(always)]
#[inline]
pub fn is_not_null<T>(ptr: *const T) -> bool { !is_null(ptr) }
/**
@ -74,7 +74,7 @@ pub fn is_not_null<T>(ptr: *const T) -> bool { !is_null(ptr) }
* Copies `count` elements (not bytes) from `src` to `dst`. The source
* and destination may overlap.
*/
#[inline(always)]
#[inline]
#[cfg(target_word_size = "32", stage0)]
pub unsafe fn copy_memory<T>(dst: *mut T, src: *const T, count: uint) {
use unstable::intrinsics::memmove32;
@ -88,7 +88,7 @@ pub unsafe fn copy_memory<T>(dst: *mut T, src: *const T, count: uint) {
* Copies `count` elements (not bytes) from `src` to `dst`. The source
* and destination may overlap.
*/
#[inline(always)]
#[inline]
#[cfg(target_word_size = "32", not(stage0))]
pub unsafe fn copy_memory<T>(dst: *mut T, src: *const T, count: uint) {
use unstable::intrinsics::memmove32;
@ -101,7 +101,7 @@ pub unsafe fn copy_memory<T>(dst: *mut T, src: *const T, count: uint) {
* Copies `count` elements (not bytes) from `src` to `dst`. The source
* and destination may overlap.
*/
#[inline(always)]
#[inline]
#[cfg(target_word_size = "64", stage0)]
pub unsafe fn copy_memory<T>(dst: *mut T, src: *const T, count: uint) {
use unstable::intrinsics::memmove64;
@ -115,7 +115,7 @@ pub unsafe fn copy_memory<T>(dst: *mut T, src: *const T, count: uint) {
* Copies `count` elements (not bytes) from `src` to `dst`. The source
* and destination may overlap.
*/
#[inline(always)]
#[inline]
#[cfg(target_word_size = "64", not(stage0))]
pub unsafe fn copy_memory<T>(dst: *mut T, src: *const T, count: uint) {
use unstable::intrinsics::memmove64;
@ -128,7 +128,7 @@ pub unsafe fn copy_memory<T>(dst: *mut T, src: *const T, count: uint) {
* Copies `count` elements (not bytes) from `src` to `dst`. The source
* and destination may *not* overlap.
*/
#[inline(always)]
#[inline]
#[cfg(target_word_size = "32", stage0)]
pub unsafe fn copy_nonoverlapping_memory<T>(dst: *mut T, src: *const T, count: uint) {
use unstable::intrinsics::memmove32;
@ -142,7 +142,7 @@ pub unsafe fn copy_nonoverlapping_memory<T>(dst: *mut T, src: *const T, count: u
* Copies `count` elements (not bytes) from `src` to `dst`. The source
* and destination may *not* overlap.
*/
#[inline(always)]
#[inline]
#[cfg(target_word_size = "32", not(stage0))]
pub unsafe fn copy_nonoverlapping_memory<T>(dst: *mut T, src: *const T, count: uint) {
use unstable::intrinsics::memcpy32;
@ -155,7 +155,7 @@ pub unsafe fn copy_nonoverlapping_memory<T>(dst: *mut T, src: *const T, count: u
* Copies `count` elements (not bytes) from `src` to `dst`. The source
* and destination may *not* overlap.
*/
#[inline(always)]
#[inline]
#[cfg(target_word_size = "64", stage0)]
pub unsafe fn copy_nonoverlapping_memory<T>(dst: *mut T, src: *const T, count: uint) {
use unstable::intrinsics::memmove64;
@ -169,7 +169,7 @@ pub unsafe fn copy_nonoverlapping_memory<T>(dst: *mut T, src: *const T, count: u
* Copies `count` elements (not bytes) from `src` to `dst`. The source
* and destination may *not* overlap.
*/
#[inline(always)]
#[inline]
#[cfg(target_word_size = "64", not(stage0))]
pub unsafe fn copy_nonoverlapping_memory<T>(dst: *mut T, src: *const T, count: uint) {
use unstable::intrinsics::memcpy64;
@ -180,7 +180,7 @@ pub unsafe fn copy_nonoverlapping_memory<T>(dst: *mut T, src: *const T, count: u
* Invokes memset on the specified pointer, setting `count * size_of::<T>()`
* bytes of memory starting at `dst` to `c`.
*/
#[inline(always)]
#[inline]
#[cfg(target_word_size = "32", not(stage0))]
pub unsafe fn set_memory<T>(dst: *mut T, c: u8, count: uint) {
use unstable::intrinsics::memset32;
@ -191,7 +191,7 @@ pub unsafe fn set_memory<T>(dst: *mut T, c: u8, count: uint) {
* Invokes memset on the specified pointer, setting `count * size_of::<T>()`
* bytes of memory starting at `dst` to `c`.
*/
#[inline(always)]
#[inline]
#[cfg(target_word_size = "64", not(stage0))]
pub unsafe fn set_memory<T>(dst: *mut T, c: u8, count: uint) {
use unstable::intrinsics::memset64;
@ -222,26 +222,26 @@ pub unsafe fn swap_ptr<T>(x: *mut T, y: *mut T) {
* Replace the value at a mutable location with a new one, returning the old
* value, without deinitialising or copying either one.
*/
#[inline(always)]
#[inline]
pub unsafe fn replace_ptr<T>(dest: *mut T, mut src: T) -> T {
swap_ptr(dest, &mut src);
src
}
/// Transform a region pointer - &T - to an unsafe pointer - *T.
#[inline(always)]
#[inline]
pub fn to_unsafe_ptr<T>(thing: &T) -> *T {
thing as *T
}
/// Transform a const region pointer - &const T - to a const unsafe pointer - *const T.
#[inline(always)]
#[inline]
pub fn to_const_unsafe_ptr<T>(thing: &const T) -> *const T {
thing as *const T
}
/// Transform a mutable region pointer - &mut T - to a mutable unsafe pointer - *mut T.
#[inline(always)]
#[inline]
pub fn to_mut_unsafe_ptr<T>(thing: &mut T) -> *mut T {
thing as *mut T
}
@ -297,11 +297,11 @@ pub trait RawPtr<T> {
/// Extension methods for immutable pointers
impl<T> RawPtr<T> for *T {
/// Returns true if the pointer is equal to the null pointer.
#[inline(always)]
#[inline]
fn is_null(&const self) -> bool { is_null(*self) }
/// Returns true if the pointer is not equal to the null pointer.
#[inline(always)]
#[inline]
fn is_not_null(&const self) -> bool { is_not_null(*self) }
///
@ -314,7 +314,7 @@ impl<T> RawPtr<T> for *T {
/// that this is still an unsafe operation because the returned value could
/// be pointing to invalid memory.
///
#[inline(always)]
#[inline]
unsafe fn to_option(&const self) -> Option<&T> {
if self.is_null() { None } else {
Some(cast::transmute(*self))
@ -322,18 +322,18 @@ impl<T> RawPtr<T> for *T {
}
/// Calculates the offset from a pointer.
#[inline(always)]
#[inline]
fn offset(&self, count: uint) -> *T { offset(*self, count) }
}
/// Extension methods for mutable pointers
impl<T> RawPtr<T> for *mut T {
/// Returns true if the pointer is equal to the null pointer.
#[inline(always)]
#[inline]
fn is_null(&const self) -> bool { is_null(*self) }
/// Returns true if the pointer is not equal to the null pointer.
#[inline(always)]
#[inline]
fn is_not_null(&const self) -> bool { is_not_null(*self) }
///
@ -346,7 +346,7 @@ impl<T> RawPtr<T> for *mut T {
/// that this is still an unsafe operation because the returned value could
/// be pointing to invalid memory.
///
#[inline(always)]
#[inline]
unsafe fn to_option(&const self) -> Option<&T> {
if self.is_null() { None } else {
Some(cast::transmute(*self))
@ -354,37 +354,37 @@ impl<T> RawPtr<T> for *mut T {
}
/// Calculates the offset from a mutable pointer.
#[inline(always)]
#[inline]
fn offset(&self, count: uint) -> *mut T { mut_offset(*self, count) }
}
// Equality for pointers
#[cfg(not(test))]
impl<T> Eq for *const T {
#[inline(always)]
#[inline]
fn eq(&self, other: &*const T) -> bool {
(*self as uint) == (*other as uint)
}
#[inline(always)]
#[inline]
fn ne(&self, other: &*const T) -> bool { !self.eq(other) }
}
// Comparison for pointers
#[cfg(not(test))]
impl<T> Ord for *const T {
#[inline(always)]
#[inline]
fn lt(&self, other: &*const T) -> bool {
(*self as uint) < (*other as uint)
}
#[inline(always)]
#[inline]
fn le(&self, other: &*const T) -> bool {
(*self as uint) <= (*other as uint)
}
#[inline(always)]
#[inline]
fn ge(&self, other: &*const T) -> bool {
(*self as uint) >= (*other as uint)
}
#[inline(always)]
#[inline]
fn gt(&self, other: &*const T) -> bool {
(*self as uint) > (*other as uint)
}

View file

@ -451,7 +451,7 @@ pub trait RngUtil {
/// Extension methods for random number generators
impl<R: Rng> RngUtil for R {
/// Return a random value for a Rand type
#[inline(always)]
#[inline]
fn gen<T: Rand>(&mut self) -> T {
Rand::rand(self)
}
@ -762,7 +762,7 @@ impl IsaacRng {
}
impl Rng for IsaacRng {
#[inline(always)]
#[inline]
fn next(&mut self) -> u32 {
if self.cnt == 0 {
// make some more numbers
@ -862,7 +862,7 @@ pub fn task_rng() -> @@mut IsaacRng {
// Allow direct chaining with `task_rng`
impl<R: Rng> Rng for @@mut R {
#[inline(always)]
#[inline]
fn next(&mut self) -> u32 {
match *self {
@@ref mut r => r.next()

View file

@ -26,7 +26,7 @@ use rand::{Rng,Rand};
mod ziggurat_tables;
// inlining should mean there is no performance penalty for this
#[inline(always)]
#[inline]
fn ziggurat<R:Rng>(rng: &mut R,
center_u: bool,
X: ziggurat_tables::ZigTable,
@ -77,11 +77,11 @@ pub struct StandardNormal(f64);
impl Rand for StandardNormal {
fn rand<R:Rng>(rng: &mut R) -> StandardNormal {
#[inline(always)]
#[inline]
fn pdf(x: f64) -> f64 {
f64::exp((-x*x/2.0) as f64) as f64
}
#[inline(always)]
#[inline]
fn zero_case<R:Rng>(rng: &mut R, u: f64) -> f64 {
// compute a random number in the tail by hand
@ -131,11 +131,11 @@ pub struct Exp1(f64);
impl Rand for Exp1 {
#[inline]
fn rand<R:Rng>(rng: &mut R) -> Exp1 {
#[inline(always)]
#[inline]
fn pdf(x: f64) -> f64 {
f64::exp(-x)
}
#[inline(always)]
#[inline]
fn zero_case<R:Rng>(rng: &mut R, _u: f64) -> f64 {
ziggurat_tables::ZIG_EXP_R - f64::ln(rng.gen())
}

View file

@ -35,7 +35,7 @@ pub trait MovePtr {
}
/// Helper function for alignment calculation.
#[inline(always)]
#[inline]
pub fn align(size: uint, align: uint) -> uint {
((size + align) - 1u) & !(align - 1u)
}
@ -49,26 +49,26 @@ pub fn MovePtrAdaptor<V:TyVisitor + MovePtr>(v: V) -> MovePtrAdaptor<V> {
}
impl<V:TyVisitor + MovePtr> MovePtrAdaptor<V> {
#[inline(always)]
#[inline]
pub fn bump(&self, sz: uint) {
do self.inner.move_ptr() |p| {
((p as uint) + sz) as *c_void
};
}
#[inline(always)]
#[inline]
pub fn align(&self, a: uint) {
do self.inner.move_ptr() |p| {
align(p as uint, a) as *c_void
};
}
#[inline(always)]
#[inline]
pub fn align_to<T>(&self) {
self.align(sys::min_align_of::<T>());
}
#[inline(always)]
#[inline]
pub fn bump_past<T>(&self) {
self.bump(sys::size_of::<T>());
}

View file

@ -164,7 +164,7 @@ pub fn ReprVisitor(ptr: *c_void, writer: @Writer) -> ReprVisitor {
}
impl MovePtr for ReprVisitor {
#[inline(always)]
#[inline]
fn move_ptr(&self, adjustment: &fn(*c_void) -> *c_void) {
*self.ptr = adjustment(*self.ptr);
}
@ -179,7 +179,7 @@ impl MovePtr for ReprVisitor {
impl ReprVisitor {
// Various helpers for the TyVisitor impl
#[inline(always)]
#[inline]
pub fn get<T>(&self, f: &fn(&T)) -> bool {
unsafe {
f(transmute::<*c_void,&T>(*self.ptr));
@ -187,12 +187,12 @@ impl ReprVisitor {
true
}
#[inline(always)]
#[inline]
pub fn visit_inner(&self, inner: *TyDesc) -> bool {
self.visit_ptr_inner(*self.ptr, inner)
}
#[inline(always)]
#[inline]
pub fn visit_ptr_inner(&self, ptr: *c_void, inner: *TyDesc) -> bool {
unsafe {
let u = ReprVisitor(ptr, self.writer);
@ -202,7 +202,7 @@ impl ReprVisitor {
}
}
#[inline(always)]
#[inline]
pub fn write<T:Repr>(&self) -> bool {
do self.get |v:&T| {
v.write_repr(self.writer);

View file

@ -38,7 +38,7 @@ pub enum Result<T, U> {
*
* If the result is an error
*/
#[inline(always)]
#[inline]
pub fn get<T:Copy,U>(res: &Result<T, U>) -> T {
match *res {
Ok(ref t) => copy *t,
@ -54,7 +54,7 @@ pub fn get<T:Copy,U>(res: &Result<T, U>) -> T {
*
* If the result is an error
*/
#[inline(always)]
#[inline]
pub fn get_ref<'a, T, U>(res: &'a Result<T, U>) -> &'a T {
match *res {
Ok(ref t) => t,
@ -70,7 +70,7 @@ pub fn get_ref<'a, T, U>(res: &'a Result<T, U>) -> &'a T {
*
* If the result is not an error
*/
#[inline(always)]
#[inline]
pub fn get_err<T, U: Copy>(res: &Result<T, U>) -> U {
match *res {
Err(ref u) => copy *u,
@ -79,7 +79,7 @@ pub fn get_err<T, U: Copy>(res: &Result<T, U>) -> U {
}
/// Returns true if the result is `ok`
#[inline(always)]
#[inline]
pub fn is_ok<T, U>(res: &Result<T, U>) -> bool {
match *res {
Ok(_) => true,
@ -88,7 +88,7 @@ pub fn is_ok<T, U>(res: &Result<T, U>) -> bool {
}
/// Returns true if the result is `err`
#[inline(always)]
#[inline]
pub fn is_err<T, U>(res: &Result<T, U>) -> bool {
!is_ok(res)
}
@ -99,7 +99,7 @@ pub fn is_err<T, U>(res: &Result<T, U>) -> bool {
* `ok` result variants are converted to `either::right` variants, `err`
* result variants are converted to `either::left`.
*/
#[inline(always)]
#[inline]
pub fn to_either<T:Copy,U:Copy>(res: &Result<U, T>)
-> Either<T, U> {
match *res {
@ -122,7 +122,7 @@ pub fn to_either<T:Copy,U:Copy>(res: &Result<U, T>)
* ok(parse_bytes(buf))
* }
*/
#[inline(always)]
#[inline]
pub fn chain<T, U, V>(res: Result<T, V>, op: &fn(T)
-> Result<U, V>) -> Result<U, V> {
match res {
@ -139,7 +139,7 @@ pub fn chain<T, U, V>(res: Result<T, V>, op: &fn(T)
* immediately returned. This function can be used to pass through a
* successful result while handling an error.
*/
#[inline(always)]
#[inline]
pub fn chain_err<T, U, V>(
res: Result<T, V>,
op: &fn(t: V) -> Result<T, U>)
@ -164,7 +164,7 @@ pub fn chain_err<T, U, V>(
* print_buf(buf)
* }
*/
#[inline(always)]
#[inline]
pub fn iter<T, E>(res: &Result<T, E>, f: &fn(&T)) {
match *res {
Ok(ref t) => f(t),
@ -180,7 +180,7 @@ pub fn iter<T, E>(res: &Result<T, E>, f: &fn(&T)) {
* This function can be used to pass through a successful result while
* handling an error.
*/
#[inline(always)]
#[inline]
pub fn iter_err<T, E>(res: &Result<T, E>, f: &fn(&E)) {
match *res {
Ok(_) => (),
@ -202,7 +202,7 @@ pub fn iter_err<T, E>(res: &Result<T, E>, f: &fn(&E)) {
* parse_bytes(buf)
* }
*/
#[inline(always)]
#[inline]
pub fn map<T, E: Copy, U: Copy>(res: &Result<T, E>, op: &fn(&T) -> U)
-> Result<U, E> {
match *res {
@ -219,7 +219,7 @@ pub fn map<T, E: Copy, U: Copy>(res: &Result<T, E>, op: &fn(&T) -> U)
* is immediately returned. This function can be used to pass through a
* successful result while handling an error.
*/
#[inline(always)]
#[inline]
pub fn map_err<T:Copy,E,F:Copy>(res: &Result<T, E>, op: &fn(&E) -> F)
-> Result<T, F> {
match *res {
@ -229,53 +229,53 @@ pub fn map_err<T:Copy,E,F:Copy>(res: &Result<T, E>, op: &fn(&E) -> F)
}
impl<T, E> Result<T, E> {
#[inline(always)]
#[inline]
pub fn get_ref<'a>(&'a self) -> &'a T { get_ref(self) }
#[inline(always)]
#[inline]
pub fn is_ok(&self) -> bool { is_ok(self) }
#[inline(always)]
#[inline]
pub fn is_err(&self) -> bool { is_err(self) }
#[inline(always)]
#[inline]
pub fn iter(&self, f: &fn(&T)) { iter(self, f) }
#[inline(always)]
#[inline]
pub fn iter_err(&self, f: &fn(&E)) { iter_err(self, f) }
#[inline(always)]
#[inline]
pub fn unwrap(self) -> T { unwrap(self) }
#[inline(always)]
#[inline]
pub fn unwrap_err(self) -> E { unwrap_err(self) }
#[inline(always)]
#[inline]
pub fn chain<U>(self, op: &fn(T) -> Result<U,E>) -> Result<U,E> {
chain(self, op)
}
#[inline(always)]
#[inline]
pub fn chain_err<F>(self, op: &fn(E) -> Result<T,F>) -> Result<T,F> {
chain_err(self, op)
}
}
impl<T:Copy,E> Result<T, E> {
#[inline(always)]
#[inline]
pub fn get(&self) -> T { get(self) }
#[inline(always)]
#[inline]
pub fn map_err<F:Copy>(&self, op: &fn(&E) -> F) -> Result<T,F> {
map_err(self, op)
}
}
impl<T, E: Copy> Result<T, E> {
#[inline(always)]
#[inline]
pub fn get_err(&self) -> E { get_err(self) }
#[inline(always)]
#[inline]
pub fn map<U:Copy>(&self, op: &fn(&T) -> U) -> Result<U,E> {
map(self, op)
}
@ -298,7 +298,7 @@ impl<T, E: Copy> Result<T, E> {
* assert!(incd == ~[2u, 3u, 4u]);
* }
*/
#[inline(always)]
#[inline]
pub fn map_vec<T,U:Copy,V:Copy>(
ts: &[T], op: &fn(&T) -> Result<V,U>) -> Result<~[V],U> {
@ -312,7 +312,7 @@ pub fn map_vec<T,U:Copy,V:Copy>(
return Ok(vs);
}
#[inline(always)]
#[inline]
#[allow(missing_doc)]
pub fn map_opt<T,U:Copy,V:Copy>(
o_t: &Option<T>, op: &fn(&T) -> Result<V,U>) -> Result<Option<V>,U> {
@ -335,7 +335,7 @@ pub fn map_opt<T,U:Copy,V:Copy>(
* used in 'careful' code contexts where it is both appropriate and easy
* to accommodate an error like the vectors being of different lengths.
*/
#[inline(always)]
#[inline]
pub fn map_vec2<S,T,U:Copy,V:Copy>(ss: &[S], ts: &[T],
op: &fn(&S,&T) -> Result<V,U>) -> Result<~[V],U> {
@ -358,7 +358,7 @@ pub fn map_vec2<S,T,U:Copy,V:Copy>(ss: &[S], ts: &[T],
* error. This could be implemented using `map_zip()` but it is more efficient
* on its own as no result vector is built.
*/
#[inline(always)]
#[inline]
pub fn iter_vec2<S,T,U:Copy>(ss: &[S], ts: &[T],
op: &fn(&S,&T) -> Result<(),U>) -> Result<(),U> {
@ -376,7 +376,7 @@ pub fn iter_vec2<S,T,U:Copy>(ss: &[S], ts: &[T],
}
/// Unwraps a result, assuming it is an `ok(T)`
#[inline(always)]
#[inline]
pub fn unwrap<T, U>(res: Result<T, U>) -> T {
match res {
Ok(t) => t,
@ -385,7 +385,7 @@ pub fn unwrap<T, U>(res: Result<T, U>) -> T {
}
/// Unwraps a result, assuming it is an `err(U)`
#[inline(always)]
#[inline]
pub fn unwrap_err<T, U>(res: Result<T, U>) -> U {
match res {
Err(u) => u,

View file

@ -207,7 +207,7 @@ fn align_down(sp: *mut uint) -> *mut uint {
}
// XXX: ptr::offset is positive ints only
#[inline(always)]
#[inline]
pub fn mut_offset<T>(ptr: *mut T, count: int) -> *mut T {
use core::sys::size_of;
(ptr as int + count * (size_of::<T>() as int)) as *mut T

View file

@ -106,21 +106,21 @@ pub fn from_bytes_slice<'a>(vector: &'a [u8]) -> &'a str {
}
/// Copy a slice into a new unique str
#[inline(always)]
#[inline]
pub fn to_owned(s: &str) -> ~str {
unsafe { raw::slice_bytes_owned(s, 0, s.len()) }
}
impl ToStr for ~str {
#[inline(always)]
#[inline]
fn to_str(&self) -> ~str { to_owned(*self) }
}
impl<'self> ToStr for &'self str {
#[inline(always)]
#[inline]
fn to_str(&self) -> ~str { to_owned(*self) }
}
impl ToStr for @str {
#[inline(always)]
#[inline]
fn to_str(&self) -> ~str { to_owned(*self) }
}
@ -241,26 +241,26 @@ pub trait CharEq {
fn only_ascii(&self) -> bool;
}
impl CharEq for char {
#[inline(always)]
#[inline]
fn matches(&self, c: char) -> bool { *self == c }
fn only_ascii(&self) -> bool { (*self as uint) < 128 }
}
impl<'self> CharEq for &'self fn(char) -> bool {
#[inline(always)]
#[inline]
fn matches(&self, c: char) -> bool { (*self)(c) }
fn only_ascii(&self) -> bool { false }
}
impl CharEq for extern "Rust" fn(char) -> bool {
#[inline(always)]
#[inline]
fn matches(&self, c: char) -> bool { (*self)(c) }
fn only_ascii(&self) -> bool { false }
}
impl<'self, C: CharEq> CharEq for &'self [C] {
#[inline(always)]
#[inline]
fn matches(&self, c: char) -> bool {
self.iter().any_(|m| m.matches(c))
}
@ -705,7 +705,7 @@ impl<'self> StrUtil for &'self str {
/**
* Deprecated. Use the `as_c_str` method on strings instead.
*/
#[inline(always)]
#[inline]
pub fn as_c_str<T>(s: &str, f: &fn(*libc::c_char) -> T) -> T {
s.as_c_str(f)
}
@ -718,7 +718,7 @@ pub fn as_c_str<T>(s: &str, f: &fn(*libc::c_char) -> T) -> T {
* indexable area for a null byte, as is the case in slices pointing
* to full strings, or suffixes of them.
*/
#[inline(always)]
#[inline]
pub fn as_buf<T>(s: &str, f: &fn(*u8, uint) -> T) -> T {
unsafe {
let v : *(*u8,uint) = transmute(&s);
@ -915,7 +915,7 @@ pub mod traits {
use super::{Str, eq_slice};
impl<'self> Add<&'self str,~str> for &'self str {
#[inline(always)]
#[inline]
fn add(&self, rhs: & &'self str) -> ~str {
let mut ret = self.to_owned();
ret.push_str(*rhs);
@ -949,98 +949,98 @@ pub mod traits {
}
impl<'self> Eq for &'self str {
#[inline(always)]
#[inline]
fn eq(&self, other: & &'self str) -> bool {
eq_slice((*self), (*other))
}
#[inline(always)]
#[inline]
fn ne(&self, other: & &'self str) -> bool { !(*self).eq(other) }
}
impl Eq for ~str {
#[inline(always)]
#[inline]
fn eq(&self, other: &~str) -> bool {
eq_slice((*self), (*other))
}
#[inline(always)]
#[inline]
fn ne(&self, other: &~str) -> bool { !(*self).eq(other) }
}
impl Eq for @str {
#[inline(always)]
#[inline]
fn eq(&self, other: &@str) -> bool {
eq_slice((*self), (*other))
}
#[inline(always)]
#[inline]
fn ne(&self, other: &@str) -> bool { !(*self).eq(other) }
}
impl<'self> TotalEq for &'self str {
#[inline(always)]
#[inline]
fn equals(&self, other: & &'self str) -> bool {
eq_slice((*self), (*other))
}
}
impl TotalEq for ~str {
#[inline(always)]
#[inline]
fn equals(&self, other: &~str) -> bool {
eq_slice((*self), (*other))
}
}
impl TotalEq for @str {
#[inline(always)]
#[inline]
fn equals(&self, other: &@str) -> bool {
eq_slice((*self), (*other))
}
}
impl<'self> Ord for &'self str {
#[inline(always)]
#[inline]
fn lt(&self, other: & &'self str) -> bool { self.cmp(other) == Less }
#[inline(always)]
#[inline]
fn le(&self, other: & &'self str) -> bool { self.cmp(other) != Greater }
#[inline(always)]
#[inline]
fn ge(&self, other: & &'self str) -> bool { self.cmp(other) != Less }
#[inline(always)]
#[inline]
fn gt(&self, other: & &'self str) -> bool { self.cmp(other) == Greater }
}
impl Ord for ~str {
#[inline(always)]
#[inline]
fn lt(&self, other: &~str) -> bool { self.cmp(other) == Less }
#[inline(always)]
#[inline]
fn le(&self, other: &~str) -> bool { self.cmp(other) != Greater }
#[inline(always)]
#[inline]
fn ge(&self, other: &~str) -> bool { self.cmp(other) != Less }
#[inline(always)]
#[inline]
fn gt(&self, other: &~str) -> bool { self.cmp(other) == Greater }
}
impl Ord for @str {
#[inline(always)]
#[inline]
fn lt(&self, other: &@str) -> bool { self.cmp(other) == Less }
#[inline(always)]
#[inline]
fn le(&self, other: &@str) -> bool { self.cmp(other) != Greater }
#[inline(always)]
#[inline]
fn ge(&self, other: &@str) -> bool { self.cmp(other) != Less }
#[inline(always)]
#[inline]
fn gt(&self, other: &@str) -> bool { self.cmp(other) == Greater }
}
impl<'self, S: Str> Equiv<S> for &'self str {
#[inline(always)]
#[inline]
fn equiv(&self, other: &S) -> bool { eq_slice(*self, other.as_slice()) }
}
impl<'self, S: Str> Equiv<S> for @str {
#[inline(always)]
#[inline]
fn equiv(&self, other: &S) -> bool { eq_slice(*self, other.as_slice()) }
}
impl<'self, S: Str> Equiv<S> for ~str {
#[inline(always)]
#[inline]
fn equiv(&self, other: &S) -> bool { eq_slice(*self, other.as_slice()) }
}
}
@ -1055,17 +1055,17 @@ pub trait Str {
}
impl<'self> Str for &'self str {
#[inline(always)]
#[inline]
fn as_slice<'a>(&'a self) -> &'a str { *self }
}
impl<'self> Str for ~str {
#[inline(always)]
#[inline]
fn as_slice<'a>(&'a self) -> &'a str {
let s: &'a str = *self; s
}
}
impl<'self> Str for @str {
#[inline(always)]
#[inline]
fn as_slice<'a>(&'a self) -> &'a str {
let s: &'a str = *self; s
}
@ -1311,7 +1311,7 @@ impl<'self> StrSlice<'self> for &'self str {
#[inline]
fn is_alphanumeric(&self) -> bool { self.iter().all(char::is_alphanumeric) }
/// Returns the size in bytes not counting the null terminator
#[inline(always)]
#[inline]
fn len(&self) -> uint {
do as_buf(*self) |_p, n| { n - 1u }
}
@ -1854,7 +1854,7 @@ impl<'self> StrSlice<'self> for &'self str {
* assert!(string.subslice_offset(lines[2]) == 4); // &"c"
* ~~~
*/
#[inline(always)]
#[inline]
fn subslice_offset(&self, inner: &str) -> uint {
do as_buf(*self) |a, a_len| {
do as_buf(inner) |b, b_len| {
@ -1925,7 +1925,7 @@ pub trait OwnedStr {
impl OwnedStr for ~str {
/// Appends a string slice to the back of a string, without overallocating
#[inline(always)]
#[inline]
fn push_str_no_overallocate(&mut self, rhs: &str) {
unsafe {
let llen = self.len();
@ -2078,7 +2078,7 @@ impl OwnedStr for ~str {
* * s - A string
* * n - The number of bytes to reserve space for
*/
#[inline(always)]
#[inline]
pub fn reserve(&mut self, n: uint) {
unsafe {
let v: *mut ~[u8] = cast::transmute(self);
@ -2106,7 +2106,7 @@ impl OwnedStr for ~str {
* * s - A string
* * n - The number of bytes to reserve space for
*/
#[inline(always)]
#[inline]
fn reserve_at_least(&mut self, n: uint) {
self.reserve(uint::next_power_of_two(n + 1u) - 1u)
}
@ -2131,7 +2131,7 @@ impl OwnedStr for ~str {
}
impl Clone for ~str {
#[inline(always)]
#[inline]
fn clone(&self) -> ~str {
to_owned(*self)
}

View file

@ -25,19 +25,19 @@ pub struct Ascii { priv chr: u8 }
impl Ascii {
/// Converts a ascii character into a `u8`.
#[inline(always)]
#[inline]
pub fn to_byte(self) -> u8 {
self.chr
}
/// Converts a ascii character into a `char`.
#[inline(always)]
#[inline]
pub fn to_char(self) -> char {
self.chr as char
}
/// Convert to lowercase.
#[inline(always)]
#[inline]
pub fn to_lower(self) -> Ascii {
if self.chr >= 65 && self.chr <= 90 {
Ascii{chr: self.chr | 0x20 }
@ -47,7 +47,7 @@ impl Ascii {
}
/// Convert to uppercase.
#[inline(always)]
#[inline]
pub fn to_upper(self) -> Ascii {
if self.chr >= 97 && self.chr <= 122 {
Ascii{chr: self.chr & !0x20 }
@ -57,14 +57,14 @@ impl Ascii {
}
/// Compares two ascii characters of equality, ignoring case.
#[inline(always)]
#[inline]
pub fn eq_ignore_case(self, other: Ascii) -> bool {
self.to_lower().chr == other.to_lower().chr
}
}
impl ToStr for Ascii {
#[inline(always)]
#[inline]
fn to_str(&self) -> ~str { str::from_bytes(['\'' as u8, self.chr, '\'' as u8]) }
}
@ -81,18 +81,18 @@ pub trait AsciiCast<T> {
}
impl<'self> AsciiCast<&'self[Ascii]> for &'self [u8] {
#[inline(always)]
#[inline]
fn to_ascii(&self) -> &'self[Ascii] {
assert!(self.is_ascii());
unsafe {self.to_ascii_nocheck()}
}
#[inline(always)]
#[inline]
unsafe fn to_ascii_nocheck(&self) -> &'self[Ascii] {
cast::transmute(*self)
}
#[inline(always)]
#[inline]
fn is_ascii(&self) -> bool {
for self.each |b| {
if !b.is_ascii() { return false; }
@ -102,55 +102,55 @@ impl<'self> AsciiCast<&'self[Ascii]> for &'self [u8] {
}
impl<'self> AsciiCast<&'self[Ascii]> for &'self str {
#[inline(always)]
#[inline]
fn to_ascii(&self) -> &'self[Ascii] {
assert!(self.is_ascii());
unsafe {self.to_ascii_nocheck()}
}
#[inline(always)]
#[inline]
unsafe fn to_ascii_nocheck(&self) -> &'self[Ascii] {
let (p,len): (*u8, uint) = cast::transmute(*self);
cast::transmute((p, len - 1))
}
#[inline(always)]
#[inline]
fn is_ascii(&self) -> bool {
self.bytes_iter().all(|b| b.is_ascii())
}
}
impl AsciiCast<Ascii> for u8 {
#[inline(always)]
#[inline]
fn to_ascii(&self) -> Ascii {
assert!(self.is_ascii());
unsafe {self.to_ascii_nocheck()}
}
#[inline(always)]
#[inline]
unsafe fn to_ascii_nocheck(&self) -> Ascii {
Ascii{ chr: *self }
}
#[inline(always)]
#[inline]
fn is_ascii(&self) -> bool {
*self & 128 == 0u8
}
}
impl AsciiCast<Ascii> for char {
#[inline(always)]
#[inline]
fn to_ascii(&self) -> Ascii {
assert!(self.is_ascii());
unsafe {self.to_ascii_nocheck()}
}
#[inline(always)]
#[inline]
unsafe fn to_ascii_nocheck(&self) -> Ascii {
Ascii{ chr: *self as u8 }
}
#[inline(always)]
#[inline]
fn is_ascii(&self) -> bool {
*self - ('\x7F' & *self) == '\x00'
}
@ -167,26 +167,26 @@ pub trait OwnedAsciiCast {
}
impl OwnedAsciiCast for ~[u8] {
#[inline(always)]
#[inline]
fn into_ascii(self) -> ~[Ascii] {
assert!(self.is_ascii());
unsafe {self.into_ascii_nocheck()}
}
#[inline(always)]
#[inline]
unsafe fn into_ascii_nocheck(self) -> ~[Ascii] {
cast::transmute(self)
}
}
impl OwnedAsciiCast for ~str {
#[inline(always)]
#[inline]
fn into_ascii(self) -> ~[Ascii] {
assert!(self.is_ascii());
unsafe {self.into_ascii_nocheck()}
}
#[inline(always)]
#[inline]
unsafe fn into_ascii_nocheck(self) -> ~[Ascii] {
let mut r: ~[Ascii] = cast::transmute(self);
r.pop();
@ -210,31 +210,31 @@ pub trait AsciiStr {
}
impl<'self> AsciiStr for &'self [Ascii] {
#[inline(always)]
#[inline]
fn to_str_ascii(&self) -> ~str {
let mut cpy = self.to_owned();
cpy.push(0u8.to_ascii());
unsafe {cast::transmute(cpy)}
}
#[inline(always)]
#[inline]
fn to_lower(&self) -> ~[Ascii] {
self.map(|a| a.to_lower())
}
#[inline(always)]
#[inline]
fn to_upper(&self) -> ~[Ascii] {
self.map(|a| a.to_upper())
}
#[inline(always)]
#[inline]
fn eq_ignore_case(self, other: &[Ascii]) -> bool {
do self.iter().zip(other.iter()).all |(&a, &b)| { a.eq_ignore_case(b) }
}
}
impl ToStrConsume for ~[Ascii] {
#[inline(always)]
#[inline]
fn into_str(self) -> ~str {
let mut cpy = self;
cpy.push(0u8.to_ascii());
@ -243,7 +243,7 @@ impl ToStrConsume for ~[Ascii] {
}
impl IterBytes for Ascii {
#[inline(always)]
#[inline]
fn iter_bytes(&self, _lsb0: bool, f: &fn(buf: &[u8]) -> bool) -> bool {
f([self.to_byte()])
}

View file

@ -57,25 +57,25 @@ pub mod rustrt {
* Useful for calling certain function in the Rust runtime or otherwise
* performing dark magick.
*/
#[inline(always)]
#[inline]
pub fn get_type_desc<T>() -> *TypeDesc {
unsafe { intrinsics::get_tydesc::<T>() as *TypeDesc }
}
/// Returns a pointer to a type descriptor.
#[inline(always)]
#[inline]
pub fn get_type_desc_val<T>(_val: &T) -> *TypeDesc {
get_type_desc::<T>()
}
/// Returns the size of a type
#[inline(always)]
#[inline]
pub fn size_of<T>() -> uint {
unsafe { intrinsics::size_of::<T>() }
}
/// Returns the size of the type that `_val` points to
#[inline(always)]
#[inline]
pub fn size_of_val<T>(_val: &T) -> uint {
size_of::<T>()
}
@ -85,14 +85,14 @@ pub fn size_of_val<T>(_val: &T) -> uint {
*
* Useful for building structures containing variable-length arrays.
*/
#[inline(always)]
#[inline]
pub fn nonzero_size_of<T>() -> uint {
let s = size_of::<T>();
if s == 0 { 1 } else { s }
}
/// Returns the size of the type of the value that `_val` points to
#[inline(always)]
#[inline]
pub fn nonzero_size_of_val<T>(_val: &T) -> uint {
nonzero_size_of::<T>()
}
@ -104,33 +104,33 @@ pub fn nonzero_size_of_val<T>(_val: &T) -> uint {
* This is the alignment used for struct fields. It may be smaller
* than the preferred alignment.
*/
#[inline(always)]
#[inline]
pub fn min_align_of<T>() -> uint {
unsafe { intrinsics::min_align_of::<T>() }
}
/// Returns the ABI-required minimum alignment of the type of the value that
/// `_val` points to
#[inline(always)]
#[inline]
pub fn min_align_of_val<T>(_val: &T) -> uint {
min_align_of::<T>()
}
/// Returns the preferred alignment of a type
#[inline(always)]
#[inline]
pub fn pref_align_of<T>() -> uint {
unsafe { intrinsics::pref_align_of::<T>() }
}
/// Returns the preferred alignment of the type of the value that
/// `_val` points to
#[inline(always)]
#[inline]
pub fn pref_align_of_val<T>(_val: &T) -> uint {
pref_align_of::<T>()
}
/// Returns the refcount of a shared box (as just before calling this)
#[inline(always)]
#[inline]
pub fn refcount<T>(t: @T) -> uint {
unsafe {
let ref_ptr: *uint = cast::transmute_copy(&t);

View file

@ -157,14 +157,14 @@ struct AncestorNode {
struct AncestorList(Option<Exclusive<AncestorNode>>);
// Accessors for taskgroup arcs and ancestor arcs that wrap the unsafety.
#[inline(always)]
#[inline]
fn access_group<U>(x: &TaskGroupArc, blk: &fn(TaskGroupInner) -> U) -> U {
unsafe {
x.with(blk)
}
}
#[inline(always)]
#[inline]
fn access_ancestors<U>(x: &Exclusive<AncestorNode>,
blk: &fn(x: &mut AncestorNode) -> U) -> U {
unsafe {

View file

@ -49,7 +49,7 @@ pub trait IterBytes {
}
impl IterBytes for bool {
#[inline(always)]
#[inline]
fn iter_bytes(&self, _lsb0: bool, f: Cb) -> bool {
f([
*self as u8
@ -58,7 +58,7 @@ impl IterBytes for bool {
}
impl IterBytes for u8 {
#[inline(always)]
#[inline]
fn iter_bytes(&self, _lsb0: bool, f: Cb) -> bool {
f([
*self
@ -67,7 +67,7 @@ impl IterBytes for u8 {
}
impl IterBytes for u16 {
#[inline(always)]
#[inline]
fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool {
if lsb0 {
f([
@ -84,7 +84,7 @@ impl IterBytes for u16 {
}
impl IterBytes for u32 {
#[inline(always)]
#[inline]
fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool {
if lsb0 {
f([
@ -105,7 +105,7 @@ impl IterBytes for u32 {
}
impl IterBytes for u64 {
#[inline(always)]
#[inline]
fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool {
if lsb0 {
f([
@ -134,35 +134,35 @@ impl IterBytes for u64 {
}
impl IterBytes for i8 {
#[inline(always)]
#[inline]
fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool {
(*self as u8).iter_bytes(lsb0, f)
}
}
impl IterBytes for i16 {
#[inline(always)]
#[inline]
fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool {
(*self as u16).iter_bytes(lsb0, f)
}
}
impl IterBytes for i32 {
#[inline(always)]
#[inline]
fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool {
(*self as u32).iter_bytes(lsb0, f)
}
}
impl IterBytes for i64 {
#[inline(always)]
#[inline]
fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool {
(*self as u64).iter_bytes(lsb0, f)
}
}
impl IterBytes for char {
#[inline(always)]
#[inline]
fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool {
(*self as u32).iter_bytes(lsb0, f)
}
@ -170,7 +170,7 @@ impl IterBytes for char {
#[cfg(target_word_size = "32")]
impl IterBytes for uint {
#[inline(always)]
#[inline]
fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool {
(*self as u32).iter_bytes(lsb0, f)
}
@ -178,28 +178,28 @@ impl IterBytes for uint {
#[cfg(target_word_size = "64")]
impl IterBytes for uint {
#[inline(always)]
#[inline]
fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool {
(*self as u64).iter_bytes(lsb0, f)
}
}
impl IterBytes for int {
#[inline(always)]
#[inline]
fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool {
(*self as uint).iter_bytes(lsb0, f)
}
}
impl IterBytes for float {
#[inline(always)]
#[inline]
fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool {
(*self as f64).iter_bytes(lsb0, f)
}
}
impl IterBytes for f32 {
#[inline(always)]
#[inline]
fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool {
let i: u32 = unsafe {
// 0.0 == -0.0 so they should also have the same hashcode
@ -210,7 +210,7 @@ impl IterBytes for f32 {
}
impl IterBytes for f64 {
#[inline(always)]
#[inline]
fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool {
let i: u64 = unsafe {
// 0.0 == -0.0 so they should also have the same hashcode
@ -221,14 +221,14 @@ impl IterBytes for f64 {
}
impl<'self,A:IterBytes> IterBytes for &'self [A] {
#[inline(always)]
#[inline]
fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool {
self.each(|elt| elt.iter_bytes(lsb0, |b| f(b)))
}
}
impl<A:IterBytes,B:IterBytes> IterBytes for (A,B) {
#[inline(always)]
#[inline]
fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool {
match *self {
(ref a, ref b) => { a.iter_bytes(lsb0, f) && b.iter_bytes(lsb0, f) }
@ -237,7 +237,7 @@ impl<A:IterBytes,B:IterBytes> IterBytes for (A,B) {
}
impl<A:IterBytes,B:IterBytes,C:IterBytes> IterBytes for (A,B,C) {
#[inline(always)]
#[inline]
fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool {
match *self {
(ref a, ref b, ref c) => {
@ -253,28 +253,28 @@ fn borrow<'x,A>(a: &'x [A]) -> &'x [A] {
}
impl<A:IterBytes> IterBytes for ~[A] {
#[inline(always)]
#[inline]
fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool {
borrow(*self).iter_bytes(lsb0, f)
}
}
impl<A:IterBytes> IterBytes for @[A] {
#[inline(always)]
#[inline]
fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool {
borrow(*self).iter_bytes(lsb0, f)
}
}
impl<'self> IterBytes for &'self str {
#[inline(always)]
#[inline]
fn iter_bytes(&self, _lsb0: bool, f: Cb) -> bool {
f(self.as_bytes())
}
}
impl IterBytes for ~str {
#[inline(always)]
#[inline]
fn iter_bytes(&self, _lsb0: bool, f: Cb) -> bool {
// this should possibly include the null terminator, but that
// breaks .find_equiv on hashmaps.
@ -283,7 +283,7 @@ impl IterBytes for ~str {
}
impl IterBytes for @str {
#[inline(always)]
#[inline]
fn iter_bytes(&self, _lsb0: bool, f: Cb) -> bool {
// this should possibly include the null terminator, but that
// breaks .find_equiv on hashmaps.
@ -292,7 +292,7 @@ impl IterBytes for @str {
}
impl<A:IterBytes> IterBytes for Option<A> {
#[inline(always)]
#[inline]
fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool {
match *self {
Some(ref a) => 0u8.iter_bytes(lsb0, f) && a.iter_bytes(lsb0, f),
@ -302,21 +302,21 @@ impl<A:IterBytes> IterBytes for Option<A> {
}
impl<'self,A:IterBytes> IterBytes for &'self A {
#[inline(always)]
#[inline]
fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool {
(**self).iter_bytes(lsb0, f)
}
}
impl<A:IterBytes> IterBytes for @A {
#[inline(always)]
#[inline]
fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool {
(**self).iter_bytes(lsb0, f)
}
}
impl<A:IterBytes> IterBytes for ~A {
#[inline(always)]
#[inline]
fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool {
(**self).iter_bytes(lsb0, f)
}
@ -325,7 +325,7 @@ impl<A:IterBytes> IterBytes for ~A {
// NB: raw-pointer IterBytes does _not_ dereference
// to the target; it just gives you the pointer-bytes.
impl<A> IterBytes for *const A {
#[inline(always)]
#[inline]
fn iter_bytes(&self, lsb0: bool, f: Cb) -> bool {
(*self as uint).iter_bytes(lsb0, f)
}

View file

@ -35,12 +35,12 @@ pub trait ToStrConsume {
}
impl ToStr for () {
#[inline(always)]
#[inline]
fn to_str(&self) -> ~str { ~"()" }
}
impl<A:ToStr> ToStr for (A,) {
#[inline(always)]
#[inline]
fn to_str(&self) -> ~str {
match *self {
(ref a,) => {
@ -51,7 +51,7 @@ impl<A:ToStr> ToStr for (A,) {
}
impl<A:ToStr+Hash+Eq, B:ToStr+Hash+Eq> ToStr for HashMap<A, B> {
#[inline(always)]
#[inline]
fn to_str(&self) -> ~str {
let mut (acc, first) = (~"{", true);
for self.each |key, value| {
@ -71,7 +71,7 @@ impl<A:ToStr+Hash+Eq, B:ToStr+Hash+Eq> ToStr for HashMap<A, B> {
}
impl<A:ToStr+Hash+Eq> ToStr for HashSet<A> {
#[inline(always)]
#[inline]
fn to_str(&self) -> ~str {
let mut (acc, first) = (~"{", true);
for self.each |element| {
@ -89,7 +89,7 @@ impl<A:ToStr+Hash+Eq> ToStr for HashSet<A> {
}
impl<A:ToStr,B:ToStr> ToStr for (A, B) {
#[inline(always)]
#[inline]
fn to_str(&self) -> ~str {
// FIXME(#4653): this causes an llvm assertion
//let &(ref a, ref b) = self;
@ -102,7 +102,7 @@ impl<A:ToStr,B:ToStr> ToStr for (A, B) {
}
impl<A:ToStr,B:ToStr,C:ToStr> ToStr for (A, B, C) {
#[inline(always)]
#[inline]
fn to_str(&self) -> ~str {
// FIXME(#4653): this causes an llvm assertion
//let &(ref a, ref b, ref c) = self;
@ -119,7 +119,7 @@ impl<A:ToStr,B:ToStr,C:ToStr> ToStr for (A, B, C) {
}
impl<'self,A:ToStr> ToStr for &'self [A] {
#[inline(always)]
#[inline]
fn to_str(&self) -> ~str {
let mut (acc, first) = (~"[", true);
for self.each |elt| {
@ -137,7 +137,7 @@ impl<'self,A:ToStr> ToStr for &'self [A] {
}
impl<A:ToStr> ToStr for ~[A] {
#[inline(always)]
#[inline]
fn to_str(&self) -> ~str {
let mut (acc, first) = (~"[", true);
for self.each |elt| {
@ -155,7 +155,7 @@ impl<A:ToStr> ToStr for ~[A] {
}
impl<A:ToStr> ToStr for @[A] {
#[inline(always)]
#[inline]
fn to_str(&self) -> ~str {
let mut (acc, first) = (~"[", true);
for self.each |elt| {

View file

@ -34,17 +34,17 @@ pub struct TrieMap<T> {
impl<T> Container for TrieMap<T> {
/// Return the number of elements in the map
#[inline(always)]
#[inline]
fn len(&const self) -> uint { self.length }
/// Return true if the map contains no elements
#[inline(always)]
#[inline]
fn is_empty(&const self) -> bool { self.len() == 0 }
}
impl<T> Mutable for TrieMap<T> {
/// Clear the map, removing all values.
#[inline(always)]
#[inline]
fn clear(&mut self) {
self.root = TrieNode::new();
self.length = 0;
@ -53,37 +53,37 @@ impl<T> Mutable for TrieMap<T> {
impl<T> Map<uint, T> for TrieMap<T> {
/// Return true if the map contains a value for the specified key
#[inline(always)]
#[inline]
fn contains_key(&self, key: &uint) -> bool {
self.find(key).is_some()
}
/// Visit all key-value pairs in order
#[inline(always)]
#[inline]
fn each<'a>(&'a self, f: &fn(&uint, &'a T) -> bool) -> bool {
self.root.each(f)
}
/// Visit all keys in order
#[inline(always)]
#[inline]
fn each_key(&self, f: &fn(&uint) -> bool) -> bool {
self.each(|k, _| f(k))
}
/// Visit all values in order
#[inline(always)]
#[inline]
fn each_value<'a>(&'a self, f: &fn(&'a T) -> bool) -> bool {
self.each(|_, v| f(v))
}
/// Iterate over the map and mutate the contained values
#[inline(always)]
#[inline]
fn mutate_values(&mut self, f: &fn(&uint, &mut T) -> bool) -> bool {
self.root.mutate_values(f)
}
/// Return a reference to the value corresponding to the key
#[inline(hint)]
#[inline]
fn find<'a>(&'a self, key: &uint) -> Option<&'a T> {
let mut node: &'a TrieNode<T> = &self.root;
let mut idx = 0;
@ -104,7 +104,7 @@ impl<T> Map<uint, T> for TrieMap<T> {
}
/// Return a mutable reference to the value corresponding to the key
#[inline(always)]
#[inline]
fn find_mut<'a>(&'a mut self, key: &uint) -> Option<&'a mut T> {
find_mut(&mut self.root.children[chunk(*key, 0)], *key, 1)
}
@ -112,14 +112,14 @@ impl<T> Map<uint, T> for TrieMap<T> {
/// Insert a key-value pair into the map. An existing value for a
/// key is replaced by the new value. Return true if the key did
/// not already exist in the map.
#[inline(always)]
#[inline]
fn insert(&mut self, key: uint, value: T) -> bool {
self.swap(key, value).is_none()
}
/// Remove a key-value pair from the map. Return true if the key
/// was present in the map, otherwise false.
#[inline(always)]
#[inline]
fn remove(&mut self, key: &uint) -> bool {
self.pop(key).is_some()
}
@ -147,25 +147,25 @@ impl<T> Map<uint, T> for TrieMap<T> {
impl<T> TrieMap<T> {
/// Create an empty TrieMap
#[inline(always)]
#[inline]
pub fn new() -> TrieMap<T> {
TrieMap{root: TrieNode::new(), length: 0}
}
/// Visit all key-value pairs in reverse order
#[inline(always)]
#[inline]
pub fn each_reverse<'a>(&'a self, f: &fn(&uint, &'a T) -> bool) -> bool {
self.root.each_reverse(f)
}
/// Visit all keys in reverse order
#[inline(always)]
#[inline]
pub fn each_key_reverse(&self, f: &fn(&uint) -> bool) -> bool {
self.each_reverse(|k, _| f(k))
}
/// Visit all values in reverse order
#[inline(always)]
#[inline]
pub fn each_value_reverse(&self, f: &fn(&T) -> bool) -> bool {
self.each_reverse(|_, v| f(v))
}
@ -178,15 +178,15 @@ pub struct TrieSet {
impl BaseIter<uint> for TrieSet {
/// Visit all values in order
#[inline(always)]
#[inline]
fn each(&self, f: &fn(&uint) -> bool) -> bool { self.map.each_key(f) }
#[inline(always)]
#[inline]
fn size_hint(&self) -> Option<uint> { Some(self.len()) }
}
impl ReverseIter<uint> for TrieSet {
/// Visit all values in reverse order
#[inline(always)]
#[inline]
fn each_reverse(&self, f: &fn(&uint) -> bool) -> bool {
self.map.each_key_reverse(f)
}
@ -194,43 +194,43 @@ impl ReverseIter<uint> for TrieSet {
impl Container for TrieSet {
/// Return the number of elements in the set
#[inline(always)]
#[inline]
fn len(&const self) -> uint { self.map.len() }
/// Return true if the set contains no elements
#[inline(always)]
#[inline]
fn is_empty(&const self) -> bool { self.map.is_empty() }
}
impl Mutable for TrieSet {
/// Clear the set, removing all values.
#[inline(always)]
#[inline]
fn clear(&mut self) { self.map.clear() }
}
impl TrieSet {
/// Create an empty TrieSet
#[inline(always)]
#[inline]
pub fn new() -> TrieSet {
TrieSet{map: TrieMap::new()}
}
/// Return true if the set contains a value
#[inline(always)]
#[inline]
pub fn contains(&self, value: &uint) -> bool {
self.map.contains_key(value)
}
/// Add a value to the set. Return true if the value was not already
/// present in the set.
#[inline(always)]
#[inline]
pub fn insert(&mut self, value: uint) -> bool {
self.map.insert(value, ())
}
/// Remove a value from the set. Return true if the value was
/// present in the set.
#[inline(always)]
#[inline]
pub fn remove(&mut self, value: &uint) -> bool {
self.map.remove(value)
}
@ -242,7 +242,7 @@ struct TrieNode<T> {
}
impl<T> TrieNode<T> {
#[inline(always)]
#[inline]
fn new() -> TrieNode<T> {
// FIXME: #5244: [Nothing, ..SIZE] should be possible without Copy
TrieNode{count: 0,
@ -291,7 +291,7 @@ impl<T> TrieNode<T> {
}
// if this was done via a trait, the key could be generic
#[inline(always)]
#[inline]
fn chunk(n: uint, idx: uint) -> uint {
let sh = uint::bits - (SHIFT * (idx + 1));
(n >> sh) & MASK

View file

@ -29,7 +29,7 @@ pub trait CopyableTuple<T, U> {
impl<T:Copy,U:Copy> CopyableTuple<T, U> for (T, U) {
/// Return the first element of self
#[inline(always)]
#[inline]
fn first(&self) -> T {
match *self {
(ref t, _) => copy *t,
@ -37,7 +37,7 @@ impl<T:Copy,U:Copy> CopyableTuple<T, U> for (T, U) {
}
/// Return the second element of self
#[inline(always)]
#[inline]
fn second(&self) -> U {
match *self {
(_, ref u) => copy *u,
@ -45,7 +45,7 @@ impl<T:Copy,U:Copy> CopyableTuple<T, U> for (T, U) {
}
/// Return the results of swapping the two elements of self
#[inline(always)]
#[inline]
fn swap(&self) -> (U, T) {
match copy *self {
(t, u) => (u, t),
@ -63,13 +63,13 @@ pub trait ImmutableTuple<T, U> {
}
impl<T, U> ImmutableTuple<T, U> for (T, U) {
#[inline(always)]
#[inline]
fn first_ref<'a>(&'a self) -> &'a T {
match *self {
(ref t, _) => t,
}
}
#[inline(always)]
#[inline]
fn second_ref<'a>(&'a self) -> &'a U {
match *self {
(_, ref u) => u,
@ -83,7 +83,7 @@ pub trait ExtendedTupleOps<A,B> {
}
impl<'self,A:Copy,B:Copy> ExtendedTupleOps<A,B> for (&'self [A], &'self [B]) {
#[inline(always)]
#[inline]
fn zip(&self) -> ~[(A, B)] {
match *self {
(ref a, ref b) => {
@ -92,7 +92,7 @@ impl<'self,A:Copy,B:Copy> ExtendedTupleOps<A,B> for (&'self [A], &'self [B]) {
}
}
#[inline(always)]
#[inline]
fn map<C>(&self, f: &fn(a: &A, b: &B) -> C) -> ~[C] {
match *self {
(ref a, ref b) => {
@ -103,7 +103,7 @@ impl<'self,A:Copy,B:Copy> ExtendedTupleOps<A,B> for (&'self [A], &'self [B]) {
}
impl<A:Copy,B:Copy> ExtendedTupleOps<A,B> for (~[A], ~[B]) {
#[inline(always)]
#[inline]
fn zip(&self) -> ~[(A, B)] {
match *self {
(ref a, ref b) => {
@ -112,7 +112,7 @@ impl<A:Copy,B:Copy> ExtendedTupleOps<A,B> for (~[A], ~[B]) {
}
}
#[inline(always)]
#[inline]
fn map<C>(&self, f: &fn(a: &A, b: &B) -> C) -> ~[C] {
match *self {
(ref a, ref b) => {
@ -144,7 +144,7 @@ macro_rules! tuple_impls {
impl<$($T:Clone),+> $cloneable_trait<$($T),+> for ($($T),+) {
$(
#[inline(always)]
#[inline]
fn $get_fn(&self) -> $T {
self.$get_ref_fn().clone()
}
@ -157,7 +157,7 @@ macro_rules! tuple_impls {
impl<$($T),+> $immutable_trait<$($T),+> for ($($T),+) {
$(
#[inline(always)]
#[inline]
fn $get_ref_fn<'a>(&'a self) -> &'a $T {
match *self { $get_pattern => $ret }
}
@ -172,11 +172,11 @@ macro_rules! tuple_impls {
#[cfg(not(test))]
impl<$($T:Eq),+> Eq for ($($T),+) {
#[inline(always)]
#[inline]
fn eq(&self, other: &($($T),+)) -> bool {
$(*self.$get_ref_fn() == *other.$get_ref_fn())&&+
}
#[inline(always)]
#[inline]
fn ne(&self, other: &($($T),+)) -> bool {
!(*self == *other)
}
@ -184,7 +184,7 @@ macro_rules! tuple_impls {
#[cfg(not(test))]
impl<$($T:TotalEq),+> TotalEq for ($($T),+) {
#[inline(always)]
#[inline]
fn equals(&self, other: &($($T),+)) -> bool {
$(self.$get_ref_fn().equals(other.$get_ref_fn()))&&+
}
@ -192,15 +192,15 @@ macro_rules! tuple_impls {
#[cfg(not(test))]
impl<$($T:Ord),+> Ord for ($($T),+) {
#[inline(always)]
#[inline]
fn lt(&self, other: &($($T),+)) -> bool {
lexical_lt!($(self.$get_ref_fn(), other.$get_ref_fn()),+)
}
#[inline(always)]
#[inline]
fn le(&self, other: &($($T),+)) -> bool { !(*other).lt(&(*self)) }
#[inline(always)]
#[inline]
fn ge(&self, other: &($($T),+)) -> bool { !(*self).lt(other) }
#[inline(always)]
#[inline]
fn gt(&self, other: &($($T),+)) -> bool { (*other).lt(&(*self)) }
}

View file

@ -82,7 +82,7 @@ impl AtomicFlag {
/**
* Clears the atomic flag
*/
#[inline(always)]
#[inline]
pub fn clear(&mut self, order: Ordering) {
unsafe {atomic_store(&mut self.v, 0, order)}
}
@ -91,7 +91,7 @@ impl AtomicFlag {
* Sets the flag if it was previously unset, returns the previous value of the
* flag.
*/
#[inline(always)]
#[inline]
pub fn test_and_set(&mut self, order: Ordering) -> bool {
unsafe {atomic_compare_and_swap(&mut self.v, 0, 1, order) > 0}
}
@ -102,26 +102,26 @@ impl AtomicBool {
AtomicBool { v: if v { 1 } else { 0 } }
}
#[inline(always)]
#[inline]
pub fn load(&self, order: Ordering) -> bool {
unsafe { atomic_load(&self.v, order) > 0 }
}
#[inline(always)]
#[inline]
pub fn store(&mut self, val: bool, order: Ordering) {
let val = if val { 1 } else { 0 };
unsafe { atomic_store(&mut self.v, val, order); }
}
#[inline(always)]
#[inline]
pub fn swap(&mut self, val: bool, order: Ordering) -> bool {
let val = if val { 1 } else { 0 };
unsafe { atomic_swap(&mut self.v, val, order) > 0}
}
#[inline(always)]
#[inline]
pub fn compare_and_swap(&mut self, old: bool, new: bool, order: Ordering) -> bool {
let old = if old { 1 } else { 0 };
let new = if new { 1 } else { 0 };
@ -135,34 +135,34 @@ impl AtomicInt {
AtomicInt { v:v }
}
#[inline(always)]
#[inline]
pub fn load(&self, order: Ordering) -> int {
unsafe { atomic_load(&self.v, order) }
}
#[inline(always)]
#[inline]
pub fn store(&mut self, val: int, order: Ordering) {
unsafe { atomic_store(&mut self.v, val, order); }
}
#[inline(always)]
#[inline]
pub fn swap(&mut self, val: int, order: Ordering) -> int {
unsafe { atomic_swap(&mut self.v, val, order) }
}
#[inline(always)]
#[inline]
pub fn compare_and_swap(&mut self, old: int, new: int, order: Ordering) -> int {
unsafe { atomic_compare_and_swap(&mut self.v, old, new, order) }
}
/// Returns the old value (like __sync_fetch_and_add).
#[inline(always)]
#[inline]
pub fn fetch_add(&mut self, val: int, order: Ordering) -> int {
unsafe { atomic_add(&mut self.v, val, order) }
}
/// Returns the old value (like __sync_fetch_and_sub).
#[inline(always)]
#[inline]
pub fn fetch_sub(&mut self, val: int, order: Ordering) -> int {
unsafe { atomic_sub(&mut self.v, val, order) }
}
@ -173,34 +173,34 @@ impl AtomicUint {
AtomicUint { v:v }
}
#[inline(always)]
#[inline]
pub fn load(&self, order: Ordering) -> uint {
unsafe { atomic_load(&self.v, order) }
}
#[inline(always)]
#[inline]
pub fn store(&mut self, val: uint, order: Ordering) {
unsafe { atomic_store(&mut self.v, val, order); }
}
#[inline(always)]
#[inline]
pub fn swap(&mut self, val: uint, order: Ordering) -> uint {
unsafe { atomic_swap(&mut self.v, val, order) }
}
#[inline(always)]
#[inline]
pub fn compare_and_swap(&mut self, old: uint, new: uint, order: Ordering) -> uint {
unsafe { atomic_compare_and_swap(&mut self.v, old, new, order) }
}
/// Returns the old value (like __sync_fetch_and_add).
#[inline(always)]
#[inline]
pub fn fetch_add(&mut self, val: uint, order: Ordering) -> uint {
unsafe { atomic_add(&mut self.v, val, order) }
}
/// Returns the old value (like __sync_fetch_and_sub)..
#[inline(always)]
#[inline]
pub fn fetch_sub(&mut self, val: uint, order: Ordering) -> uint {
unsafe { atomic_sub(&mut self.v, val, order) }
}
@ -211,22 +211,22 @@ impl<T> AtomicPtr<T> {
AtomicPtr { p:p }
}
#[inline(always)]
#[inline]
pub fn load(&self, order: Ordering) -> *mut T {
unsafe { atomic_load(&self.p, order) }
}
#[inline(always)]
#[inline]
pub fn store(&mut self, ptr: *mut T, order: Ordering) {
unsafe { atomic_store(&mut self.p, ptr, order); }
}
#[inline(always)]
#[inline]
pub fn swap(&mut self, ptr: *mut T, order: Ordering) -> *mut T {
unsafe { atomic_swap(&mut self.p, ptr, order) }
}
#[inline(always)]
#[inline]
pub fn compare_and_swap(&mut self, old: *mut T, new: *mut T, order: Ordering) -> *mut T {
unsafe { atomic_compare_and_swap(&mut self.p, old, new, order) }
}
@ -249,7 +249,7 @@ impl<T> AtomicOption<T> {
}
}
#[inline(always)]
#[inline]
pub fn swap(&mut self, val: ~T, order: Ordering) -> Option<~T> {
unsafe {
let val = cast::transmute(val);
@ -265,7 +265,7 @@ impl<T> AtomicOption<T> {
}
}
#[inline(always)]
#[inline]
pub fn take(&mut self, order: Ordering) -> Option<~T> {
unsafe {
self.swap(cast::transmute(0), order)
@ -286,7 +286,7 @@ impl<T> Drop for AtomicOption<T> {
}
}
#[inline(always)]
#[inline]
pub unsafe fn atomic_store<T>(dst: &mut T, val: T, order:Ordering) {
let dst = cast::transmute(dst);
let val = cast::transmute(val);
@ -297,7 +297,7 @@ pub unsafe fn atomic_store<T>(dst: &mut T, val: T, order:Ordering) {
}
}
#[inline(always)]
#[inline]
pub unsafe fn atomic_load<T>(dst: &T, order:Ordering) -> T {
let dst = cast::transmute(dst);
@ -307,7 +307,7 @@ pub unsafe fn atomic_load<T>(dst: &T, order:Ordering) -> T {
})
}
#[inline(always)]
#[inline]
pub unsafe fn atomic_swap<T>(dst: &mut T, val: T, order: Ordering) -> T {
let dst = cast::transmute(dst);
let val = cast::transmute(val);
@ -320,7 +320,7 @@ pub unsafe fn atomic_swap<T>(dst: &mut T, val: T, order: Ordering) -> T {
}
/// Returns the old value (like __sync_fetch_and_add).
#[inline(always)]
#[inline]
pub unsafe fn atomic_add<T>(dst: &mut T, val: T, order: Ordering) -> T {
let dst = cast::transmute(dst);
let val = cast::transmute(val);
@ -333,7 +333,7 @@ pub unsafe fn atomic_add<T>(dst: &mut T, val: T, order: Ordering) -> T {
}
/// Returns the old value (like __sync_fetch_and_sub).
#[inline(always)]
#[inline]
pub unsafe fn atomic_sub<T>(dst: &mut T, val: T, order: Ordering) -> T {
let dst = cast::transmute(dst);
let val = cast::transmute(val);
@ -345,7 +345,7 @@ pub unsafe fn atomic_sub<T>(dst: &mut T, val: T, order: Ordering) -> T {
})
}
#[inline(always)]
#[inline]
pub unsafe fn atomic_compare_and_swap<T>(dst:&mut T, old:T, new:T, order: Ordering) -> T {
let dst = cast::transmute(dst);
let old = cast::transmute(old);

View file

@ -673,7 +673,7 @@ pub mod rt {
}
buf.push_str(s);
}
#[inline(always)]
#[inline]
pub fn have_flag(flags: u32, f: u32) -> bool {
flags & f != 0
}

View file

@ -152,7 +152,7 @@ unsafe fn fail_borrowed(box: *mut BoxRepr, file: *c_char, line: size_t) {
// FIXME #4942: Make these signatures agree with exchange_alloc's signatures
#[lang="exchange_malloc"]
#[inline(always)]
#[inline]
pub unsafe fn exchange_malloc(td: *c_char, size: uintptr_t) -> *c_char {
transmute(global_heap::malloc(transmute(td), transmute(size)))
}
@ -232,7 +232,7 @@ impl DebugPrints for io::fd_t {
// inside a landing pad may corrupt the state of the exception handler. If a
// problem occurs, call exit instead.
#[lang="exchange_free"]
#[inline(always)]
#[inline]
pub unsafe fn exchange_free(ptr: *c_char) {
global_heap::free(transmute(ptr))
}
@ -271,7 +271,7 @@ pub unsafe fn local_free(ptr: *c_char) {
}
#[lang="borrow_as_imm"]
#[inline(always)]
#[inline]
pub unsafe fn borrow_as_imm(a: *u8, file: *c_char, line: size_t) -> uint {
let a: *mut BoxRepr = transmute(a);
let old_ref_count = (*a).header.ref_count;
@ -289,7 +289,7 @@ pub unsafe fn borrow_as_imm(a: *u8, file: *c_char, line: size_t) -> uint {
}
#[lang="borrow_as_mut"]
#[inline(always)]
#[inline]
pub unsafe fn borrow_as_mut(a: *u8, file: *c_char, line: size_t) -> uint {
let a: *mut BoxRepr = transmute(a);
let old_ref_count = (*a).header.ref_count;
@ -346,7 +346,7 @@ pub unsafe fn unrecord_borrow(a: *u8, old_ref_count: uint,
}
#[lang="return_to_mut"]
#[inline(always)]
#[inline]
pub unsafe fn return_to_mut(a: *u8, orig_ref_count: uint,
file: *c_char, line: size_t) {
// Sometimes the box is null, if it is conditionally frozen.
@ -365,7 +365,7 @@ pub unsafe fn return_to_mut(a: *u8, orig_ref_count: uint,
}
#[lang="check_not_borrowed"]
#[inline(always)]
#[inline]
pub unsafe fn check_not_borrowed(a: *u8,
file: *c_char,
line: size_t) {
@ -378,7 +378,7 @@ pub unsafe fn check_not_borrowed(a: *u8,
}
#[lang="strdup_uniq"]
#[inline(always)]
#[inline]
pub unsafe fn strdup_uniq(ptr: *c_uchar, len: uint) -> ~str {
str::raw::from_buf_len(ptr, len)
}

View file

@ -40,7 +40,7 @@ impl<T: Owned> UnsafeAtomicRcBox<T> {
}
}
#[inline(always)]
#[inline]
pub unsafe fn get(&self) -> *mut T
{
let mut data: ~AtomicRcBoxData<T> = cast::transmute(self.data);
@ -50,7 +50,7 @@ impl<T: Owned> UnsafeAtomicRcBox<T> {
return r;
}
#[inline(always)]
#[inline]
pub unsafe fn get_immut(&self) -> *T
{
let mut data: ~AtomicRcBoxData<T> = cast::transmute(self.data);
@ -118,7 +118,7 @@ fn LittleLock() -> LittleLock {
}
impl LittleLock {
#[inline(always)]
#[inline]
pub unsafe fn lock<T>(&self, f: &fn() -> T) -> T {
do atomically {
rust_lock_little_lock(self.l);
@ -169,7 +169,7 @@ impl<T:Owned> Exclusive<T> {
// Currently, scheduling operations (i.e., yielding, receiving on a pipe,
// accessing the provided condition variable) are prohibited while inside
// the exclusive. Supporting that is a work in progress.
#[inline(always)]
#[inline]
pub unsafe fn with<U>(&self, f: &fn(x: &mut T) -> U) -> U {
let rec = self.x.get();
do (*rec).lock.lock {
@ -183,7 +183,7 @@ impl<T:Owned> Exclusive<T> {
}
}
#[inline(always)]
#[inline]
pub unsafe fn with_imm<U>(&self, f: &fn(x: &T) -> U) -> U {
do self.with |x| {
f(cast::transmute_immut(x))

View file

@ -16,11 +16,11 @@ use prelude::*;
use unstable::intrinsics;
/// The identity function.
#[inline(always)]
#[inline]
pub fn id<T>(x: T) -> T { x }
/// Ignores a value.
#[inline(always)]
#[inline]
pub fn ignore<T>(_x: T) { }
/// Sets `*ptr` to `new_value`, invokes `op()`, and then restores the
@ -30,7 +30,7 @@ pub fn ignore<T>(_x: T) { }
/// an obvious borrowck hazard. Typically passing in `&mut T` will
/// cause borrow check errors because it freezes whatever location
/// that `&mut T` is stored in (either statically or dynamically).
#[inline(always)]
#[inline]
pub fn with<T,R>(
ptr: @mut T,
value: T,
@ -46,7 +46,7 @@ pub fn with<T,R>(
* Swap the values at two mutable locations of the same type, without
* deinitialising or copying either one.
*/
#[inline(always)]
#[inline]
pub fn swap<T>(x: &mut T, y: &mut T) {
unsafe {
// Give ourselves some scratch space to work with
@ -68,7 +68,7 @@ pub fn swap<T>(x: &mut T, y: &mut T) {
* Replace the value at a mutable location with a new one, returning the old
* value, without deinitialising or copying either one.
*/
#[inline(always)]
#[inline]
pub fn replace<T>(dest: &mut T, mut src: T) -> T {
swap(dest, &mut src);
src

View file

@ -111,7 +111,7 @@ pub fn reserve_at_least<T>(v: &mut ~[T], n: uint) {
}
/// Returns the number of elements the vector can hold without reallocating
#[inline(always)]
#[inline]
pub fn capacity<T>(v: &const ~[T]) -> uint {
unsafe {
let repr: **raw::VecRepr = transmute(v);
@ -189,7 +189,7 @@ pub fn with_capacity<T>(capacity: uint) -> ~[T] {
* as an argument a function that will push an element
* onto the vector being constructed.
*/
#[inline(always)]
#[inline]
pub fn build_sized<A>(size: uint, builder: &fn(push: &fn(v: A))) -> ~[A] {
let mut vec = with_capacity(size);
builder(|x| vec.push(x));
@ -206,7 +206,7 @@ pub fn build_sized<A>(size: uint, builder: &fn(push: &fn(v: A))) -> ~[A] {
* as an argument a function that will push an element
* onto the vector being constructed.
*/
#[inline(always)]
#[inline]
pub fn build<A>(builder: &fn(push: &fn(v: A))) -> ~[A] {
build_sized(4, builder)
}
@ -223,7 +223,7 @@ pub fn build<A>(builder: &fn(push: &fn(v: A))) -> ~[A] {
* as an argument a function that will push an element
* onto the vector being constructed.
*/
#[inline(always)]
#[inline]
pub fn build_sized_opt<A>(size: Option<uint>,
builder: &fn(push: &fn(v: A)))
-> ~[A] {
@ -271,7 +271,7 @@ pub fn last_opt<'r,T>(v: &'r [T]) -> Option<&'r T> {
}
/// Return a slice that points into another slice.
#[inline(always)]
#[inline]
pub fn slice<'r,T>(v: &'r [T], start: uint, end: uint) -> &'r [T] {
assert!(start <= end);
assert!(end <= v.len());
@ -284,7 +284,7 @@ pub fn slice<'r,T>(v: &'r [T], start: uint, end: uint) -> &'r [T] {
}
/// Return a slice that points into another slice.
#[inline(always)]
#[inline]
pub fn mut_slice<'r,T>(v: &'r mut [T], start: uint, end: uint)
-> &'r mut [T] {
assert!(start <= end);
@ -298,7 +298,7 @@ pub fn mut_slice<'r,T>(v: &'r mut [T], start: uint, end: uint)
}
/// Return a slice that points into another slice.
#[inline(always)]
#[inline]
pub fn const_slice<'r,T>(v: &'r const [T], start: uint, end: uint)
-> &'r const [T] {
assert!(start <= end);
@ -633,7 +633,7 @@ pub fn swap_remove<T>(v: &mut ~[T], index: uint) -> T {
}
/// Append an element to a vector
#[inline(always)]
#[inline]
pub fn push<T>(v: &mut ~[T], initval: T) {
unsafe {
let repr: **raw::VecRepr = transmute(&mut *v);
@ -648,7 +648,7 @@ pub fn push<T>(v: &mut ~[T], initval: T) {
}
// This doesn't bother to make sure we have space.
#[inline(always)] // really pretty please
#[inline] // really pretty please
unsafe fn push_fast<T>(v: &mut ~[T], initval: T) {
let repr: **mut raw::VecRepr = transmute(v);
let fill = (**repr).unboxed.fill;
@ -675,7 +675,7 @@ fn push_slow<T>(v: &mut ~[T], initval: T) {
/// vec::push_all(&mut a, [2, 3, 4]);
/// assert!(a == ~[1, 2, 3, 4]);
/// ~~~
#[inline(always)]
#[inline]
pub fn push_all<T:Copy>(v: &mut ~[T], rhs: &const [T]) {
let new_len = v.len() + rhs.len();
reserve(&mut *v, new_len);
@ -696,7 +696,7 @@ pub fn push_all<T:Copy>(v: &mut ~[T], rhs: &const [T]) {
/// vec::push_all_move(&mut a, ~[~2, ~3, ~4]);
/// assert!(a == ~[~1, ~2, ~3, ~4]);
/// ~~~
#[inline(always)]
#[inline]
pub fn push_all_move<T>(v: &mut ~[T], mut rhs: ~[T]) {
let new_len = v.len() + rhs.len();
reserve(&mut *v, new_len);
@ -767,7 +767,7 @@ pub fn dedup<T:Eq>(v: &mut ~[T]) {
/// Iterates over the `rhs` vector, copying each element and appending it to the
/// `lhs`. Afterwards, the `lhs` is then returned for use again.
#[inline(always)]
#[inline]
pub fn append<T:Copy>(lhs: ~[T], rhs: &const [T]) -> ~[T] {
let mut v = lhs;
v.push_all(rhs);
@ -776,7 +776,7 @@ pub fn append<T:Copy>(lhs: ~[T], rhs: &const [T]) -> ~[T] {
/// Appends one element to the vector provided. The vector itself is then
/// returned for use again.
#[inline(always)]
#[inline]
pub fn append_one<T>(lhs: ~[T], x: T) -> ~[T] {
let mut v = lhs;
v.push(x);
@ -1295,7 +1295,7 @@ pub fn zip<T, U>(mut v: ~[T], mut u: ~[U]) -> ~[(T, U)] {
* * a - The index of the first element
* * b - The index of the second element
*/
#[inline(always)]
#[inline]
pub fn swap<T>(v: &mut [T], a: uint, b: uint) {
unsafe {
// Can't take two mutable loans from one vector, so instead just cast
@ -1403,7 +1403,7 @@ pub fn reversed<T:Copy>(v: &const [T]) -> ~[T] {
* }
* ~~~
*/
#[inline(always)]
#[inline]
pub fn each<'r,T>(v: &'r [T], f: &fn(&'r T) -> bool) -> bool {
// ^^^^
// NB---this CANNOT be &const [T]! The reason
@ -1429,7 +1429,7 @@ pub fn each<'r,T>(v: &'r [T], f: &fn(&'r T) -> bool) -> bool {
/// Like `each()`, but for the case where you have a vector that *may or may
/// not* have mutable contents.
#[inline(always)]
#[inline]
pub fn each_const<T>(v: &const [T], f: &fn(elem: &const T) -> bool) -> bool {
let mut i = 0;
let n = v.len();
@ -1447,7 +1447,7 @@ pub fn each_const<T>(v: &const [T], f: &fn(elem: &const T) -> bool) -> bool {
*
* Return true to continue, false to break.
*/
#[inline(always)]
#[inline]
pub fn eachi<'r,T>(v: &'r [T], f: &fn(uint, v: &'r T) -> bool) -> bool {
let mut i = 0;
for each(v) |p| {
@ -1540,7 +1540,7 @@ pub fn windowed<'r, T>(n: uint, v: &'r [T], it: &fn(&'r [T]) -> bool) -> bool {
* Allows for unsafe manipulation of vector contents, which is useful for
* foreign interop.
*/
#[inline(always)]
#[inline]
pub fn as_imm_buf<T,U>(s: &[T],
/* NB---this CANNOT be const, see below */
f: &fn(*T, uint) -> U) -> U {
@ -1559,7 +1559,7 @@ pub fn as_imm_buf<T,U>(s: &[T],
}
/// Similar to `as_imm_buf` but passing a `*const T`
#[inline(always)]
#[inline]
pub fn as_const_buf<T,U>(s: &const [T], f: &fn(*const T, uint) -> U) -> U {
unsafe {
let v : *(*const T,uint) = transmute(&s);
@ -1569,7 +1569,7 @@ pub fn as_const_buf<T,U>(s: &const [T], f: &fn(*const T, uint) -> U) -> U {
}
/// Similar to `as_imm_buf` but passing a `*mut T`
#[inline(always)]
#[inline]
pub fn as_mut_buf<T,U>(s: &mut [T], f: &fn(*mut T, uint) -> U) -> U {
unsafe {
let v : *(*mut T,uint) = transmute(&s);
@ -1612,49 +1612,49 @@ fn equals<T: TotalEq>(a: &[T], b: &[T]) -> bool {
#[cfg(not(test))]
impl<'self,T:Eq> Eq for &'self [T] {
#[inline(always)]
#[inline]
fn eq(&self, other: & &'self [T]) -> bool { eq(*self, *other) }
#[inline(always)]
#[inline]
fn ne(&self, other: & &'self [T]) -> bool { !self.eq(other) }
}
#[cfg(not(test))]
impl<T:Eq> Eq for ~[T] {
#[inline(always)]
#[inline]
fn eq(&self, other: &~[T]) -> bool { eq(*self, *other) }
#[inline(always)]
#[inline]
fn ne(&self, other: &~[T]) -> bool { !self.eq(other) }
}
#[cfg(not(test))]
impl<T:Eq> Eq for @[T] {
#[inline(always)]
#[inline]
fn eq(&self, other: &@[T]) -> bool { eq(*self, *other) }
#[inline(always)]
#[inline]
fn ne(&self, other: &@[T]) -> bool { !self.eq(other) }
}
#[cfg(not(test))]
impl<'self,T:TotalEq> TotalEq for &'self [T] {
#[inline(always)]
#[inline]
fn equals(&self, other: & &'self [T]) -> bool { equals(*self, *other) }
}
#[cfg(not(test))]
impl<T:TotalEq> TotalEq for ~[T] {
#[inline(always)]
#[inline]
fn equals(&self, other: &~[T]) -> bool { equals(*self, *other) }
}
#[cfg(not(test))]
impl<T:TotalEq> TotalEq for @[T] {
#[inline(always)]
#[inline]
fn equals(&self, other: &@[T]) -> bool { equals(*self, *other) }
}
#[cfg(not(test))]
impl<'self,T:Eq> Equiv<~[T]> for &'self [T] {
#[inline(always)]
#[inline]
fn equiv(&self, other: &~[T]) -> bool { eq(*self, *other) }
}
@ -1676,19 +1676,19 @@ fn cmp<T: TotalOrd>(a: &[T], b: &[T]) -> Ordering {
#[cfg(not(test))]
impl<'self,T:TotalOrd> TotalOrd for &'self [T] {
#[inline(always)]
#[inline]
fn cmp(&self, other: & &'self [T]) -> Ordering { cmp(*self, *other) }
}
#[cfg(not(test))]
impl<T: TotalOrd> TotalOrd for ~[T] {
#[inline(always)]
#[inline]
fn cmp(&self, other: &~[T]) -> Ordering { cmp(*self, *other) }
}
#[cfg(not(test))]
impl<T: TotalOrd> TotalOrd for @[T] {
#[inline(always)]
#[inline]
fn cmp(&self, other: &@[T]) -> Ordering { cmp(*self, *other) }
}
@ -1713,37 +1713,37 @@ fn gt<T:Ord>(a: &[T], b: &[T]) -> bool { lt(b, a) }
#[cfg(not(test))]
impl<'self,T:Ord> Ord for &'self [T] {
#[inline(always)]
#[inline]
fn lt(&self, other: & &'self [T]) -> bool { lt((*self), (*other)) }
#[inline(always)]
#[inline]
fn le(&self, other: & &'self [T]) -> bool { le((*self), (*other)) }
#[inline(always)]
#[inline]
fn ge(&self, other: & &'self [T]) -> bool { ge((*self), (*other)) }
#[inline(always)]
#[inline]
fn gt(&self, other: & &'self [T]) -> bool { gt((*self), (*other)) }
}
#[cfg(not(test))]
impl<T:Ord> Ord for ~[T] {
#[inline(always)]
#[inline]
fn lt(&self, other: &~[T]) -> bool { lt((*self), (*other)) }
#[inline(always)]
#[inline]
fn le(&self, other: &~[T]) -> bool { le((*self), (*other)) }
#[inline(always)]
#[inline]
fn ge(&self, other: &~[T]) -> bool { ge((*self), (*other)) }
#[inline(always)]
#[inline]
fn gt(&self, other: &~[T]) -> bool { gt((*self), (*other)) }
}
#[cfg(not(test))]
impl<T:Ord> Ord for @[T] {
#[inline(always)]
#[inline]
fn lt(&self, other: &@[T]) -> bool { lt((*self), (*other)) }
#[inline(always)]
#[inline]
fn le(&self, other: &@[T]) -> bool { le((*self), (*other)) }
#[inline(always)]
#[inline]
fn ge(&self, other: &@[T]) -> bool { ge((*self), (*other)) }
#[inline(always)]
#[inline]
fn gt(&self, other: &@[T]) -> bool { gt((*self), (*other)) }
}
@ -1754,7 +1754,7 @@ pub mod traits {
use vec::append;
impl<'self,T:Copy> Add<&'self const [T],~[T]> for ~[T] {
#[inline(always)]
#[inline]
fn add(&self, rhs: & &'self const [T]) -> ~[T] {
append(copy *self, (*rhs))
}
@ -1958,7 +1958,7 @@ impl<'self,T> ImmutableVector<'self, T> for &'self [T] {
/// Returns a pointer to the element at the given index, without doing
/// bounds checking.
#[inline(always)]
#[inline]
unsafe fn unsafe_ref(&self, index: uint) -> *T {
let (ptr, _): (*T, uint) = transmute(*self);
ptr.offset(index)
@ -2029,7 +2029,7 @@ impl<'self,T:Copy> ImmutableCopyableVector<T> for &'self [T] {
}
/// Returns the element at the given index, without doing bounds checking.
#[inline(always)]
#[inline]
unsafe fn unsafe_get(&self, index: uint) -> T {
copy *self.unsafe_ref(index)
}
@ -2210,14 +2210,14 @@ impl<'self,T> MutableVector<'self, T> for &'self mut [T] {
}
}
#[inline(always)]
#[inline]
unsafe fn unsafe_mut_ref(&self, index: uint) -> *mut T {
let pair_ptr: &(*mut T, uint) = transmute(self);
let (ptr, _) = *pair_ptr;
ptr.offset(index)
}
#[inline(always)]
#[inline]
unsafe fn unsafe_set(&self, index: uint, val: T) {
*self.unsafe_mut_ref(index) = val;
}
@ -2278,7 +2278,7 @@ pub mod raw {
* modifing its buffers, so it is up to the caller to ensure that
* the vector is actually the specified size.
*/
#[inline(always)]
#[inline]
pub unsafe fn set_len<T>(v: &mut ~[T], new_len: uint) {
let repr: **mut VecRepr = transmute(v);
(**repr).unboxed.fill = new_len * sys::nonzero_size_of::<T>();
@ -2293,7 +2293,7 @@ pub mod raw {
* Modifying the vector may cause its buffer to be reallocated, which
* would also make any pointers to it invalid.
*/
#[inline(always)]
#[inline]
pub fn to_ptr<T>(v: &[T]) -> *T {
unsafe {
let repr: **SliceRepr = transmute(&v);
@ -2302,7 +2302,7 @@ pub mod raw {
}
/** see `to_ptr()` */
#[inline(always)]
#[inline]
pub fn to_const_ptr<T>(v: &const [T]) -> *const T {
unsafe {
let repr: **SliceRepr = transmute(&v);
@ -2311,7 +2311,7 @@ pub mod raw {
}
/** see `to_ptr()` */
#[inline(always)]
#[inline]
pub fn to_mut_ptr<T>(v: &mut [T]) -> *mut T {
unsafe {
let repr: **SliceRepr = transmute(&v);
@ -2323,7 +2323,7 @@ pub mod raw {
* Form a slice from a pointer and length (as a number of units,
* not bytes).
*/
#[inline(always)]
#[inline]
pub unsafe fn buf_as_slice<T,U>(p: *T,
len: uint,
f: &fn(v: &[T]) -> U) -> U {
@ -2336,7 +2336,7 @@ pub mod raw {
* Form a slice from a pointer and length (as a number of units,
* not bytes).
*/
#[inline(always)]
#[inline]
pub unsafe fn mut_buf_as_slice<T,U>(p: *mut T,
len: uint,
f: &fn(v: &mut [T]) -> U) -> U {
@ -2348,7 +2348,7 @@ pub mod raw {
/**
* Unchecked vector indexing.
*/
#[inline(always)]
#[inline]
pub unsafe fn get<T:Copy>(v: &const [T], i: uint) -> T {
as_const_buf(v, |p, _len| copy *ptr::const_offset(p, i))
}
@ -2358,7 +2358,7 @@ pub mod raw {
* old value and hence is only suitable when the vector
* is newly allocated.
*/
#[inline(always)]
#[inline]
pub unsafe fn init_elem<T>(v: &mut [T], i: uint, val: T) {
let mut box = Some(val);
do as_mut_buf(v) |p, _len| {
@ -2377,7 +2377,7 @@ pub mod raw {
* * elts - The number of elements in the buffer
*/
// Was in raw, but needs to be called by net_tcp::on_tcp_read_cb
#[inline(always)]
#[inline]
pub unsafe fn from_buf_raw<T>(ptr: *T, elts: uint) -> ~[T] {
let mut dst = with_capacity(elts);
set_len(&mut dst, elts);
@ -2391,7 +2391,7 @@ pub mod raw {
* Copies `count` bytes from `src` to `dst`. The source and destination
* may overlap.
*/
#[inline(always)]
#[inline]
pub unsafe fn copy_memory<T>(dst: &mut [T], src: &const [T],
count: uint) {
assert!(dst.len() >= count);
@ -2457,7 +2457,7 @@ pub mod bytes {
* Copies `count` bytes from `src` to `dst`. The source and destination
* may overlap.
*/
#[inline(always)]
#[inline]
pub fn copy_memory(dst: &mut [u8], src: &const [u8], count: uint) {
// Bound checks are done at vec::raw::copy_memory.
unsafe { vec::raw::copy_memory(dst, src, count) }
@ -2468,31 +2468,31 @@ pub mod bytes {
// ITERATION TRAIT METHODS
impl<'self,A> old_iter::BaseIter<A> for &'self [A] {
#[inline(always)]
#[inline]
fn each<'a>(&'a self, blk: &fn(v: &'a A) -> bool) -> bool {
each(*self, blk)
}
#[inline(always)]
#[inline]
fn size_hint(&self) -> Option<uint> { Some(self.len()) }
}
// FIXME(#4148): This should be redundant
impl<A> old_iter::BaseIter<A> for ~[A] {
#[inline(always)]
#[inline]
fn each<'a>(&'a self, blk: &fn(v: &'a A) -> bool) -> bool {
each(*self, blk)
}
#[inline(always)]
#[inline]
fn size_hint(&self) -> Option<uint> { Some(self.len()) }
}
// FIXME(#4148): This should be redundant
impl<A> old_iter::BaseIter<A> for @[A] {
#[inline(always)]
#[inline]
fn each<'a>(&'a self, blk: &fn(v: &'a A) -> bool) -> bool {
each(*self, blk)
}
#[inline(always)]
#[inline]
fn size_hint(&self) -> Option<uint> { Some(self.len()) }
}
@ -2710,7 +2710,7 @@ pub struct VecMutRevIterator<'self, T> {
iterator!{impl VecMutRevIterator -> &'self mut T, -1}
impl<T> FromIter<T> for ~[T]{
#[inline(always)]
#[inline]
pub fn from_iter(iter: &fn(f: &fn(T) -> bool) -> bool) -> ~[T] {
let mut v = ~[];
for iter |x| { v.push(x) }

View file

@ -95,7 +95,7 @@ impl<D:Decoder> Decodable<D> for ident {
}
impl to_bytes::IterBytes for ident {
#[inline(always)]
#[inline]
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
self.name.iter_bytes(lsb0, f)
}

View file

@ -198,7 +198,7 @@ pub fn is_call_expr(e: @expr) -> bool {
// This makes def_id hashable
impl to_bytes::IterBytes for def_id {
#[inline(always)]
#[inline]
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
self.crate.iter_bytes(lsb0, f) && self.node.iter_bytes(lsb0, f)
}

View file

@ -312,7 +312,7 @@ pub enum inline_attr {
/// True if something like #[inline] is found in the list of attrs.
pub fn find_inline_attr(attrs: &[ast::attribute]) -> inline_attr {
// FIXME (#2809)---validate the usage of #[inline] and #[inline(always)]
// FIXME (#2809)---validate the usage of #[inline] and #[inline]
do attrs.iter().fold(ia_none) |ia,attr| {
match attr.node.value.node {
ast::meta_word(s) if "inline" == s => ia_hint,

View file

@ -1052,7 +1052,7 @@ f(cx, span, ~[self_1.method(__arg_1_1, __arg_2_1),
self_2.method(__arg_1_2, __arg_2_2)])
~~~
*/
#[inline(always)]
#[inline]
pub fn cs_same_method(f: &fn(@ExtCtxt, span, ~[@expr]) -> @expr,
enum_nonmatch_f: EnumNonMatchFunc,
cx: @ExtCtxt, span: span,
@ -1083,7 +1083,7 @@ Fold together the results of calling the derived method on all the
fields. `use_foldl` controls whether this is done left-to-right
(`true`) or right-to-left (`false`).
*/
#[inline(always)]
#[inline]
pub fn cs_same_method_fold(use_foldl: bool,
f: &fn(@ExtCtxt, span, @expr, @expr) -> @expr,
base: @expr,
@ -1111,7 +1111,7 @@ pub fn cs_same_method_fold(use_foldl: bool,
Use a given binop to combine the result of calling the derived method
on all the fields.
*/
#[inline(always)]
#[inline]
pub fn cs_binop(binop: ast::binop, base: @expr,
enum_nonmatch_f: EnumNonMatchFunc,
cx: @ExtCtxt, span: span,
@ -1130,7 +1130,7 @@ pub fn cs_binop(binop: ast::binop, base: @expr,
}
/// cs_binop with binop == or
#[inline(always)]
#[inline]
pub fn cs_or(enum_nonmatch_f: EnumNonMatchFunc,
cx: @ExtCtxt, span: span,
substructure: &Substructure) -> @expr {
@ -1139,7 +1139,7 @@ pub fn cs_or(enum_nonmatch_f: EnumNonMatchFunc,
cx, span, substructure)
}
/// cs_binop with binop == and
#[inline(always)]
#[inline]
pub fn cs_and(enum_nonmatch_f: EnumNonMatchFunc,
cx: @ExtCtxt, span: span,
substructure: &Substructure) -> @expr {

View file

@ -103,7 +103,7 @@ impl<T:Copy> OptVec<T> {
}
}
#[inline(always)]
#[inline]
fn mapi_to_vec<B>(&self, op: &fn(uint, &T) -> B) -> ~[B] {
let mut index = 0;
old_iter::map_to_vec(self, |a| {
@ -145,31 +145,31 @@ impl<A> BaseIter<A> for OptVec<A> {
}
impl<A> old_iter::ExtendedIter<A> for OptVec<A> {
#[inline(always)]
#[inline]
fn eachi(&self, blk: &fn(v: uint, v: &A) -> bool) -> bool {
old_iter::eachi(self, blk)
}
#[inline(always)]
#[inline]
fn all(&self, blk: &fn(&A) -> bool) -> bool {
old_iter::all(self, blk)
}
#[inline(always)]
#[inline]
fn any(&self, blk: &fn(&A) -> bool) -> bool {
old_iter::any(self, blk)
}
#[inline(always)]
#[inline]
fn foldl<B>(&self, b0: B, blk: &fn(&B, &A) -> B) -> B {
old_iter::foldl(self, b0, blk)
}
#[inline(always)]
#[inline]
fn position(&self, f: &fn(&A) -> bool) -> Option<uint> {
old_iter::position(self, f)
}
#[inline(always)]
#[inline]
fn map_to_vec<B>(&self, op: &fn(&A) -> B) -> ~[B] {
old_iter::map_to_vec(self, op)
}
#[inline(always)]
#[inline]
fn flat_map_to_vec<B,IB:BaseIter<B>>(&self, op: &fn(&A) -> IB)
-> ~[B] {
old_iter::flat_map_to_vec(self, op)
@ -178,20 +178,20 @@ impl<A> old_iter::ExtendedIter<A> for OptVec<A> {
}
impl<A: Eq> old_iter::EqIter<A> for OptVec<A> {
#[inline(always)]
#[inline]
fn contains(&self, x: &A) -> bool { old_iter::contains(self, x) }
#[inline(always)]
#[inline]
fn count(&self, x: &A) -> uint { old_iter::count(self, x) }
}
impl<A: Copy> old_iter::CopyableIter<A> for OptVec<A> {
#[inline(always)]
#[inline]
fn filter_to_vec(&self, pred: &fn(&A) -> bool) -> ~[A] {
old_iter::filter_to_vec(self, pred)
}
#[inline(always)]
#[inline]
fn to_vec(&self) -> ~[A] { old_iter::to_vec(self) }
#[inline(always)]
#[inline]
fn find(&self, f: &fn(&A) -> bool) -> Option<A> {
old_iter::find(self, f)
}

View file

@ -68,7 +68,7 @@ pub enum ObsoleteSyntax {
}
impl to_bytes::IterBytes for ObsoleteSyntax {
#[inline(always)]
#[inline]
fn iter_bytes(&self, lsb0: bool, f: to_bytes::Cb) -> bool {
(*self as uint).iter_bytes(lsb0, f)
}