impl {i,u}{8,16,32,64,size}

This commit is contained in:
Jorge Aparicio 2015-03-10 23:13:40 -05:00
parent 8afcaabee3
commit 3ff84fc5fd
9 changed files with 1004 additions and 3 deletions

View File

@ -46,6 +46,7 @@
use std::intrinsics;
use std::marker;
use std::mem;
#[cfg(stage0)]
use std::num::{Int, UnsignedInt};
use std::ptr;
use std::rc::Rc;

View File

@ -23,7 +23,7 @@
use core::marker::PhantomData;
use core::ops::{Deref, DerefMut, Index, IndexMut};
use core::ptr::Unique;
use core::{slice, mem, ptr, cmp, num, raw};
use core::{slice, mem, ptr, cmp, raw};
use alloc::heap::{self, EMPTY};
use borrow::Borrow;
@ -105,7 +105,10 @@ struct MutNodeSlice<'a, K: 'a, V: 'a> {
/// Fails if `target_alignment` is not a power of two.
#[inline]
fn round_up_to_next(unrounded: usize, target_alignment: usize) -> usize {
assert!(num::UnsignedInt::is_power_of_two(target_alignment));
#[cfg(stage0)]
use core::num::UnsignedInt;
assert!(target_alignment.is_power_of_two());
(unrounded + target_alignment - 1) & !(target_alignment - 1)
}

View File

@ -59,6 +59,7 @@
use core::iter::{repeat, FromIterator, IntoIterator};
use core::marker::PhantomData;
use core::mem;
#[cfg(stage0)]
use core::num::{Int, UnsignedInt};
use core::ops::{Index, IndexMut, Deref, Add};
use core::ops;

View File

@ -25,6 +25,7 @@
use core::fmt;
use core::iter::{self, repeat, FromIterator, IntoIterator, RandomAccessIterator};
use core::mem;
#[cfg(stage0)]
use core::num::{Int, UnsignedInt};
use core::num::wrapping::WrappingOps;
use core::ops::{Index, IndexMut};

File diff suppressed because it is too large Load Diff

View File

@ -123,7 +123,7 @@ pub fn new(items: &'a mut [Weighted<T>]) -> WeightedChoice<'a, T> {
// strictly speaking, this is subsumed by the total weight == 0 case
assert!(!items.is_empty(), "WeightedChoice::new called with no items");
let mut running_total = 0;
let mut running_total = 0_usize;
// we convert the list from individual weights to cumulative
// weights so we can binary search. This *could* drop elements

View File

@ -23,6 +23,7 @@
use iter::{self, Iterator, ExactSizeIterator, IntoIterator, IteratorExt, FromIterator, Extend, Map};
use marker::Sized;
use mem::{self, replace};
#[cfg(stage0)]
use num::{Int, UnsignedInt};
use ops::{Deref, FnMut, Index, IndexMut};
use option::Option::{self, Some, None};

View File

@ -19,6 +19,7 @@
use marker::{Copy, Send, Sync, Sized, self};
use mem::{min_align_of, size_of};
use mem;
#[cfg(stage0)]
use num::{Int, UnsignedInt};
use num::wrapping::{OverflowingOps, WrappingOps};
use ops::{Deref, DerefMut, Drop};

View File

@ -23,7 +23,10 @@
use clone::Clone;
use cmp::{PartialOrd, PartialEq};
#[cfg(stage0)]
pub use core::num::{Int, SignedInt, UnsignedInt};
#[cfg(not(stage0))]
pub use core::num::{Int, SignedInt};
pub use core::num::{cast, FromPrimitive, NumCast, ToPrimitive};
pub use core::num::{from_int, from_i8, from_i16, from_i32, from_i64};
pub use core::num::{from_uint, from_u8, from_u16, from_u32, from_u64};