Register new snapshots
This commit is contained in:
parent
94a95067e0
commit
fccf5a0005
56 changed files with 1059 additions and 4030 deletions
|
@ -264,7 +264,6 @@ impl BoxAny for Box<Any> {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(not(stage0))]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl BoxAny for Box<Any+Send> {
|
||||
#[inline]
|
||||
|
|
|
@ -8,10 +8,6 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#[cfg(stage0)]
|
||||
#[cfg(not(test))]
|
||||
use core::ptr::PtrExt;
|
||||
|
||||
// FIXME: #13996: mark the `allocate` and `reallocate` return value as `noalias`
|
||||
|
||||
/// Return a pointer to `size` bytes of memory aligned to `align`.
|
||||
|
|
|
@ -159,9 +159,6 @@ use core::nonzero::NonZero;
|
|||
use core::ops::{Deref, Drop};
|
||||
use core::option::Option;
|
||||
use core::option::Option::{Some, None};
|
||||
#[cfg(stage0)]
|
||||
use core::ptr::{self, PtrExt};
|
||||
#[cfg(not(stage0))]
|
||||
use core::ptr;
|
||||
use core::result::Result;
|
||||
use core::result::Result::{Ok, Err};
|
||||
|
|
|
@ -43,12 +43,8 @@ extern crate alloc;
|
|||
use std::cell::{Cell, RefCell};
|
||||
use std::cmp;
|
||||
use std::intrinsics;
|
||||
#[cfg(stage0)] // SNAP 270a677
|
||||
use std::intrinsics::{get_tydesc, TyDesc};
|
||||
use std::marker;
|
||||
use std::mem;
|
||||
#[cfg(stage0)]
|
||||
use std::num::{Int, UnsignedInt};
|
||||
use std::ptr;
|
||||
use std::rc::Rc;
|
||||
use std::rt::heap::{allocate, deallocate};
|
||||
|
@ -190,14 +186,12 @@ fn un_bitpack_tydesc_ptr(p: usize) -> (*const TyDesc, bool) {
|
|||
// HACK(eddyb) TyDesc replacement using a trait object vtable.
|
||||
// This could be replaced in the future with a custom DST layout,
|
||||
// or `&'static (drop_glue, size, align)` created by a `const fn`.
|
||||
#[cfg(not(stage0))] // SNAP 270a677
|
||||
struct TyDesc {
|
||||
drop_glue: fn(*const i8),
|
||||
size: usize,
|
||||
align: usize
|
||||
}
|
||||
|
||||
#[cfg(not(stage0))] // SNAP 270a677
|
||||
unsafe fn get_tydesc<T>() -> *const TyDesc {
|
||||
use std::raw::TraitObject;
|
||||
|
||||
|
|
|
@ -105,9 +105,6 @@ 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 {
|
||||
#[cfg(stage0)]
|
||||
use core::num::UnsignedInt;
|
||||
|
||||
assert!(target_alignment.is_power_of_two());
|
||||
(unrounded + target_alignment - 1) & !(target_alignment - 1)
|
||||
}
|
||||
|
|
|
@ -8,45 +8,6 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#[cfg(stage0)]
|
||||
/// Creates a `Vec` containing the arguments.
|
||||
///
|
||||
/// `vec!` allows `Vec`s to be defined with the same syntax as array expressions.
|
||||
/// There are two forms of this macro:
|
||||
///
|
||||
/// - Create a `Vec` containing a given list of elements:
|
||||
///
|
||||
/// ```
|
||||
/// let v = vec![1, 2, 3];
|
||||
/// assert_eq!(v[0], 1);
|
||||
/// assert_eq!(v[1], 2);
|
||||
/// assert_eq!(v[2], 3);
|
||||
/// ```
|
||||
///
|
||||
/// - Create a `Vec` from a given element and size:
|
||||
///
|
||||
/// ```
|
||||
/// let v = vec![1; 3];
|
||||
/// assert_eq!(v, [1, 1, 1]);
|
||||
/// ```
|
||||
///
|
||||
/// Note that unlike array expressions this syntax supports all elements
|
||||
/// which implement `Clone` and the number of elements doesn't have to be
|
||||
/// a constant.
|
||||
#[macro_export]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
macro_rules! vec {
|
||||
($elem:expr; $n:expr) => (
|
||||
$crate::vec::from_elem($elem, $n)
|
||||
);
|
||||
($($x:expr),*) => (
|
||||
<[_] as $crate::slice::SliceExt>::into_vec(
|
||||
$crate::boxed::Box::new([$($x),*]))
|
||||
);
|
||||
($($x:expr,)*) => (vec![$($x),*])
|
||||
}
|
||||
|
||||
#[cfg(not(stage0))]
|
||||
/// Creates a `Vec` containing the arguments.
|
||||
///
|
||||
/// `vec!` allows `Vec`s to be defined with the same syntax as array expressions.
|
||||
|
@ -84,11 +45,10 @@ macro_rules! vec {
|
|||
($($x:expr,)*) => (vec![$($x),*])
|
||||
}
|
||||
|
||||
// HACK(japaric): with cfg(test) the inherent `[T]::into_vec` method, which is required for this
|
||||
// macro definition, is not available. Instead use the `slice::into_vec` function which is only
|
||||
// available with cfg(test)
|
||||
// HACK(japaric): with cfg(test) the inherent `[T]::into_vec` method, which is
|
||||
// required for this macro definition, is not available. Instead use the
|
||||
// `slice::into_vec` function which is only available with cfg(test)
|
||||
// NB see the slice::hack module in slice.rs for more information
|
||||
#[cfg(not(stage0))]
|
||||
#[cfg(test)]
|
||||
macro_rules! vec {
|
||||
($elem:expr; $n:expr) => (
|
||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -85,23 +85,6 @@ impl String {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
/// Creates a new string buffer from the given string.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// let s = String::from_str("hello");
|
||||
/// assert_eq!(s.as_slice(), "hello");
|
||||
/// ```
|
||||
#[inline]
|
||||
#[unstable(feature = "collections",
|
||||
reason = "needs investigation to see if to_string() can match perf")]
|
||||
pub fn from_str(string: &str) -> String {
|
||||
String { vec: ::slice::SliceExt::to_vec(string.as_bytes()) }
|
||||
}
|
||||
|
||||
#[cfg(not(stage0))]
|
||||
/// Creates a new string buffer from the given string.
|
||||
///
|
||||
/// # Examples
|
||||
|
@ -118,9 +101,9 @@ impl String {
|
|||
String { vec: <[_]>::to_vec(string.as_bytes()) }
|
||||
}
|
||||
|
||||
// HACK(japaric): with cfg(test) the inherent `[T]::to_vec` method, which is required for this
|
||||
// method definition, is not available. Since we don't require this method for testing
|
||||
// purposes, I'll just stub it
|
||||
// HACK(japaric): with cfg(test) the inherent `[T]::to_vec` method, which is
|
||||
// required for this method definition, is not available. Since we don't
|
||||
// require this method for testing purposes, I'll just stub it
|
||||
// NB see the slice::hack module in slice.rs for more information
|
||||
#[inline]
|
||||
#[cfg(test)]
|
||||
|
|
|
@ -59,8 +59,6 @@ use core::intrinsics::assume;
|
|||
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;
|
||||
use core::ptr;
|
||||
|
@ -1283,18 +1281,13 @@ pub fn from_elem<T: Clone>(elem: T, n: usize) -> Vec<T> {
|
|||
|
||||
#[unstable(feature = "collections")]
|
||||
impl<T:Clone> Clone for Vec<T> {
|
||||
#[cfg(stage0)]
|
||||
fn clone(&self) -> Vec<T> { ::slice::SliceExt::to_vec(&**self) }
|
||||
|
||||
#[cfg(not(stage0))]
|
||||
#[cfg(not(test))]
|
||||
fn clone(&self) -> Vec<T> { <[T]>::to_vec(&**self) }
|
||||
|
||||
// HACK(japaric): with cfg(test) the inherent `[T]::to_vec` method, which is required for this
|
||||
// method definition, is not available. Instead use the `slice::to_vec` function which is only
|
||||
// available with cfg(test)
|
||||
// HACK(japaric): with cfg(test) the inherent `[T]::to_vec` method, which is
|
||||
// required for this method definition, is not available. Instead use the
|
||||
// `slice::to_vec` function which is only available with cfg(test)
|
||||
// NB see the slice::hack module in slice.rs for more information
|
||||
#[cfg(not(stage0))]
|
||||
#[cfg(test)]
|
||||
fn clone(&self) -> Vec<T> {
|
||||
::slice::to_vec(&**self)
|
||||
|
|
|
@ -25,8 +25,6 @@ use core::default::Default;
|
|||
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};
|
||||
use core::ptr::{self, Unique};
|
||||
|
|
|
@ -155,7 +155,6 @@ impl Any {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(not(stage0))]
|
||||
impl Any+Send {
|
||||
/// Forwards to the method defined on the type `Any`.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
|
|
|
@ -44,26 +44,6 @@
|
|||
|
||||
use marker::Sized;
|
||||
|
||||
#[cfg(stage0)] // SNAP 270a677
|
||||
pub type GlueFn = extern "Rust" fn(*const i8);
|
||||
|
||||
#[lang="ty_desc"]
|
||||
#[derive(Copy)]
|
||||
#[cfg(stage0)] // SNAP 270a677
|
||||
pub struct TyDesc {
|
||||
// sizeof(T)
|
||||
pub size: usize,
|
||||
|
||||
// alignof(T)
|
||||
pub align: usize,
|
||||
|
||||
// Called when a value of type `T` is no longer needed
|
||||
pub drop_glue: GlueFn,
|
||||
|
||||
// Name corresponding to the type
|
||||
pub name: &'static str,
|
||||
}
|
||||
|
||||
extern "rust-intrinsic" {
|
||||
|
||||
// NB: These intrinsics take unsafe pointers because they mutate aliased
|
||||
|
@ -198,12 +178,8 @@ extern "rust-intrinsic" {
|
|||
pub fn min_align_of<T>() -> usize;
|
||||
pub fn pref_align_of<T>() -> usize;
|
||||
|
||||
/// Get a static pointer to a type descriptor.
|
||||
#[cfg(stage0)] // SNAP 270a677
|
||||
pub fn get_tydesc<T: ?Sized>() -> *const TyDesc;
|
||||
|
||||
/// Gets a static string slice containing the name of a type.
|
||||
#[cfg(not(stage0))] // SNAP 270a677
|
||||
#[cfg(not(stage0))]
|
||||
pub fn type_name<T: ?Sized>() -> &'static str;
|
||||
|
||||
/// Gets an identifier which is globally unique to the specified type. This
|
||||
|
|
|
@ -437,13 +437,19 @@ macro_rules! uint_impl {
|
|||
fn max_value() -> $T { -1 }
|
||||
|
||||
#[inline]
|
||||
fn count_ones(self) -> u32 { unsafe { $ctpop(self as $ActualT) as u32 } }
|
||||
fn count_ones(self) -> u32 {
|
||||
unsafe { $ctpop(self as $ActualT) as u32 }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn leading_zeros(self) -> u32 { unsafe { $ctlz(self as $ActualT) as u32 } }
|
||||
fn leading_zeros(self) -> u32 {
|
||||
unsafe { $ctlz(self as $ActualT) as u32 }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn trailing_zeros(self) -> u32 { unsafe { $cttz(self as $ActualT) as u32 } }
|
||||
fn trailing_zeros(self) -> u32 {
|
||||
unsafe { $cttz(self as $ActualT) as u32 }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn rotate_left(self, n: u32) -> $T {
|
||||
|
@ -460,7 +466,9 @@ macro_rules! uint_impl {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
fn swap_bytes(self) -> $T { unsafe { $bswap(self as $ActualT) as $T } }
|
||||
fn swap_bytes(self) -> $T {
|
||||
unsafe { $bswap(self as $ActualT) as $T }
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn checked_add(self, other: $T) -> Option<$T> {
|
||||
|
@ -571,19 +579,29 @@ macro_rules! int_impl {
|
|||
fn count_ones(self) -> u32 { (self as $UnsignedT).count_ones() }
|
||||
|
||||
#[inline]
|
||||
fn leading_zeros(self) -> u32 { (self as $UnsignedT).leading_zeros() }
|
||||
fn leading_zeros(self) -> u32 {
|
||||
(self as $UnsignedT).leading_zeros()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn trailing_zeros(self) -> u32 { (self as $UnsignedT).trailing_zeros() }
|
||||
fn trailing_zeros(self) -> u32 {
|
||||
(self as $UnsignedT).trailing_zeros()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn rotate_left(self, n: u32) -> $T { (self as $UnsignedT).rotate_left(n) as $T }
|
||||
fn rotate_left(self, n: u32) -> $T {
|
||||
(self as $UnsignedT).rotate_left(n) as $T
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn rotate_right(self, n: u32) -> $T { (self as $UnsignedT).rotate_right(n) as $T }
|
||||
fn rotate_right(self, n: u32) -> $T {
|
||||
(self as $UnsignedT).rotate_right(n) as $T
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn swap_bytes(self) -> $T { (self as $UnsignedT).swap_bytes() as $T }
|
||||
fn swap_bytes(self) -> $T {
|
||||
(self as $UnsignedT).swap_bytes() as $T
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn checked_add(self, other: $T) -> Option<$T> {
|
||||
|
@ -708,74 +726,8 @@ signed_int_impl! { i32 }
|
|||
signed_int_impl! { i64 }
|
||||
signed_int_impl! { int }
|
||||
|
||||
#[cfg(stage0)]
|
||||
/// A built-in unsigned integer.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub trait UnsignedInt: Int + WrappingOps {
|
||||
/// Returns `true` iff `self == 2^k` for some `k`.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[inline]
|
||||
fn is_power_of_two(self) -> bool {
|
||||
(self.wrapping_sub(Int::one())) & self == Int::zero() && !(self == Int::zero())
|
||||
}
|
||||
|
||||
/// Returns the smallest power of two greater than or equal to `self`.
|
||||
/// Unspecified behavior on overflow.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[inline]
|
||||
fn next_power_of_two(self) -> Self {
|
||||
let bits = size_of::<Self>() * 8;
|
||||
let one: Self = Int::one();
|
||||
one << ((bits - self.wrapping_sub(one).leading_zeros() as usize) % bits)
|
||||
}
|
||||
|
||||
/// Returns the smallest power of two greater than or equal to `n`. If the
|
||||
/// next power of two is greater than the type's maximum value, `None` is
|
||||
/// returned, otherwise the power of two is wrapped in `Some`.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
fn checked_next_power_of_two(self) -> Option<Self> {
|
||||
let npot = self.next_power_of_two();
|
||||
if npot >= self {
|
||||
Some(npot)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl UnsignedInt for uint {}
|
||||
|
||||
#[cfg(stage0)]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl UnsignedInt for u8 {}
|
||||
|
||||
#[cfg(stage0)]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl UnsignedInt for u16 {}
|
||||
|
||||
#[cfg(stage0)]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl UnsignedInt for u32 {}
|
||||
|
||||
#[cfg(stage0)]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl UnsignedInt for u64 {}
|
||||
|
||||
// NB(japaric) I added this module to avoid adding several `cfg(not(stage0))`, and avoid name
|
||||
// clashes between macros. We should move all the items inside this module into the outer scope
|
||||
// once the `Int` trait is removed
|
||||
#[cfg(not(stage0))]
|
||||
mod inherent {
|
||||
use intrinsics;
|
||||
use mem::size_of;
|
||||
use option::Option::{self, Some, None};
|
||||
|
||||
use super::wrapping::{OverflowingOps, WrappingOps};
|
||||
|
||||
// `Int` + `SignedInt` implemented for signed integers
|
||||
macro_rules! int_impl {
|
||||
// `Int` + `SignedInt` implemented for signed integers
|
||||
macro_rules! int_impl {
|
||||
($T:ty = $ActualT:ty, $UnsignedT:ty, $BITS:expr,
|
||||
$add_with_overflow:path,
|
||||
$sub_with_overflow:path,
|
||||
|
@ -794,14 +746,16 @@ mod inherent {
|
|||
#[inline]
|
||||
pub fn one() -> $T { 1 }
|
||||
|
||||
/// Returns the smallest value that can be represented by this integer type.
|
||||
/// Returns the smallest value that can be represented by this integer
|
||||
/// type.
|
||||
// FIXME (#5527): Should be and associated constant
|
||||
#[unstable(feature = "core",
|
||||
reason = "unsure about its place in the world")]
|
||||
#[inline]
|
||||
pub fn min_value() -> $T { (-1 as $T) << ($BITS - 1) }
|
||||
|
||||
/// Returns the largest value that can be represented by this integer type.
|
||||
/// Returns the largest value that can be represented by this integer
|
||||
/// type.
|
||||
// FIXME (#5527): Should be and associated constant
|
||||
#[unstable(feature = "core",
|
||||
reason = "unsure about its place in the world")]
|
||||
|
@ -857,7 +811,9 @@ mod inherent {
|
|||
#[unstable(feature = "core",
|
||||
reason = "pending integer conventions")]
|
||||
#[inline]
|
||||
pub fn leading_zeros(self) -> u32 { (self as $UnsignedT).leading_zeros() }
|
||||
pub fn leading_zeros(self) -> u32 {
|
||||
(self as $UnsignedT).leading_zeros()
|
||||
}
|
||||
|
||||
/// Returns the number of trailing zeros in the binary representation
|
||||
/// of `self`.
|
||||
|
@ -874,10 +830,12 @@ mod inherent {
|
|||
#[unstable(feature = "core",
|
||||
reason = "pending integer conventions")]
|
||||
#[inline]
|
||||
pub fn trailing_zeros(self) -> u32 { (self as $UnsignedT).trailing_zeros() }
|
||||
pub fn trailing_zeros(self) -> u32 {
|
||||
(self as $UnsignedT).trailing_zeros()
|
||||
}
|
||||
|
||||
/// Shifts the bits to the left by a specified amount amount, `n`, wrapping
|
||||
/// the truncated bits to the end of the resulting integer.
|
||||
/// Shifts the bits to the left by a specified amount amount, `n`,
|
||||
/// wrapping the truncated bits to the end of the resulting integer.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
|
@ -892,10 +850,13 @@ mod inherent {
|
|||
#[unstable(feature = "core",
|
||||
reason = "pending integer conventions")]
|
||||
#[inline]
|
||||
pub fn rotate_left(self, n: u32) -> $T { (self as $UnsignedT).rotate_left(n) as $T }
|
||||
pub fn rotate_left(self, n: u32) -> $T {
|
||||
(self as $UnsignedT).rotate_left(n) as $T
|
||||
}
|
||||
|
||||
/// Shifts the bits to the right by a specified amount amount, `n`, wrapping
|
||||
/// the truncated bits to the beginning of the resulting integer.
|
||||
/// Shifts the bits to the right by a specified amount amount, `n`,
|
||||
/// wrapping the truncated bits to the beginning of the resulting
|
||||
/// integer.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
|
@ -910,7 +871,9 @@ mod inherent {
|
|||
#[unstable(feature = "core",
|
||||
reason = "pending integer conventions")]
|
||||
#[inline]
|
||||
pub fn rotate_right(self, n: u32) -> $T { (self as $UnsignedT).rotate_right(n) as $T }
|
||||
pub fn rotate_right(self, n: u32) -> $T {
|
||||
(self as $UnsignedT).rotate_right(n) as $T
|
||||
}
|
||||
|
||||
/// Reverses the byte order of the integer.
|
||||
///
|
||||
|
@ -926,11 +889,14 @@ mod inherent {
|
|||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[inline]
|
||||
pub fn swap_bytes(self) -> $T { (self as $UnsignedT).swap_bytes() as $T }
|
||||
pub fn swap_bytes(self) -> $T {
|
||||
(self as $UnsignedT).swap_bytes() as $T
|
||||
}
|
||||
|
||||
/// Convert an integer from big endian to the target's endianness.
|
||||
///
|
||||
/// On big endian this is a no-op. On little endian the bytes are swapped.
|
||||
/// On big endian this is a no-op. On little endian the bytes are
|
||||
/// swapped.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
|
@ -953,7 +919,8 @@ mod inherent {
|
|||
|
||||
/// Convert an integer from little endian to the target's endianness.
|
||||
///
|
||||
/// On little endian this is a no-op. On big endian the bytes are swapped.
|
||||
/// On little endian this is a no-op. On big endian the bytes are
|
||||
/// swapped.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
|
@ -976,7 +943,8 @@ mod inherent {
|
|||
|
||||
/// Convert `self` to big endian from the target's endianness.
|
||||
///
|
||||
/// On big endian this is a no-op. On little endian the bytes are swapped.
|
||||
/// On big endian this is a no-op. On little endian the bytes are
|
||||
/// swapped.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
|
@ -999,7 +967,8 @@ mod inherent {
|
|||
|
||||
/// Convert `self` to little endian from the target's endianness.
|
||||
///
|
||||
/// On little endian this is a no-op. On big endian the bytes are swapped.
|
||||
/// On little endian this is a no-op. On big endian the bytes are
|
||||
/// swapped.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
|
@ -1020,8 +989,8 @@ mod inherent {
|
|||
if cfg!(target_endian = "little") { self } else { self.swap_bytes() }
|
||||
}
|
||||
|
||||
/// Checked integer addition. Computes `self + other`, returning `None` if
|
||||
/// overflow occurred.
|
||||
/// Checked integer addition. Computes `self + other`, returning `None`
|
||||
/// if overflow occurred.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
|
@ -1037,8 +1006,8 @@ mod inherent {
|
|||
checked_op!($T, $ActualT, $add_with_overflow, self, other)
|
||||
}
|
||||
|
||||
/// Checked integer subtraction. Computes `self - other`, returning `None`
|
||||
/// if underflow occurred.
|
||||
/// Checked integer subtraction. Computes `self - other`, returning
|
||||
/// `None` if underflow occurred.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
|
@ -1071,8 +1040,8 @@ mod inherent {
|
|||
checked_op!($T, $ActualT, $mul_with_overflow, self, other)
|
||||
}
|
||||
|
||||
/// Checked integer division. Computes `self / other`, returning `None` if
|
||||
/// `other == 0` or the operation results in underflow or overflow.
|
||||
/// Checked integer division. Computes `self / other`, returning `None`
|
||||
/// if `other == 0` or the operation results in underflow or overflow.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
|
@ -1106,8 +1075,8 @@ mod inherent {
|
|||
}
|
||||
}
|
||||
|
||||
/// Saturating integer subtraction. Computes `self - other`, saturating at
|
||||
/// the numeric bounds instead of overflowing.
|
||||
/// Saturating integer subtraction. Computes `self - other`, saturating
|
||||
/// at the numeric bounds instead of overflowing.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[inline]
|
||||
pub fn saturating_sub(self, other: $T) -> $T {
|
||||
|
@ -1191,60 +1160,60 @@ mod inherent {
|
|||
#[inline]
|
||||
pub fn is_negative(self) -> bool { self < 0 }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[lang = "i8"]
|
||||
impl i8 {
|
||||
#[lang = "i8"]
|
||||
impl i8 {
|
||||
int_impl! { i8 = i8, u8, 8,
|
||||
intrinsics::i8_add_with_overflow,
|
||||
intrinsics::i8_sub_with_overflow,
|
||||
intrinsics::i8_mul_with_overflow }
|
||||
}
|
||||
}
|
||||
|
||||
#[lang = "i16"]
|
||||
impl i16 {
|
||||
#[lang = "i16"]
|
||||
impl i16 {
|
||||
int_impl! { i16 = i16, u16, 16,
|
||||
intrinsics::i16_add_with_overflow,
|
||||
intrinsics::i16_sub_with_overflow,
|
||||
intrinsics::i16_mul_with_overflow }
|
||||
}
|
||||
}
|
||||
|
||||
#[lang = "i32"]
|
||||
impl i32 {
|
||||
#[lang = "i32"]
|
||||
impl i32 {
|
||||
int_impl! { i32 = i32, u32, 32,
|
||||
intrinsics::i32_add_with_overflow,
|
||||
intrinsics::i32_sub_with_overflow,
|
||||
intrinsics::i32_mul_with_overflow }
|
||||
}
|
||||
}
|
||||
|
||||
#[lang = "i64"]
|
||||
impl i64 {
|
||||
#[lang = "i64"]
|
||||
impl i64 {
|
||||
int_impl! { i64 = i64, u64, 64,
|
||||
intrinsics::i64_add_with_overflow,
|
||||
intrinsics::i64_sub_with_overflow,
|
||||
intrinsics::i64_mul_with_overflow }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_pointer_width = "32")]
|
||||
#[lang = "isize"]
|
||||
impl isize {
|
||||
#[cfg(target_pointer_width = "32")]
|
||||
#[lang = "isize"]
|
||||
impl isize {
|
||||
int_impl! { int = i32, u32, 32,
|
||||
intrinsics::i32_add_with_overflow,
|
||||
intrinsics::i32_sub_with_overflow,
|
||||
intrinsics::i32_mul_with_overflow }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_pointer_width = "64")]
|
||||
#[lang = "isize"]
|
||||
impl isize {
|
||||
#[cfg(target_pointer_width = "64")]
|
||||
#[lang = "isize"]
|
||||
impl isize {
|
||||
int_impl! { int = i64, u64, 64,
|
||||
intrinsics::i64_add_with_overflow,
|
||||
intrinsics::i64_sub_with_overflow,
|
||||
intrinsics::i64_mul_with_overflow }
|
||||
}
|
||||
}
|
||||
|
||||
// `Int` + `UnsignedInt` implemented for signed integers
|
||||
macro_rules! uint_impl {
|
||||
// `Int` + `UnsignedInt` implemented for signed integers
|
||||
macro_rules! uint_impl {
|
||||
($T:ty = $ActualT:ty, $BITS:expr,
|
||||
$ctpop:path,
|
||||
$ctlz:path,
|
||||
|
@ -1267,14 +1236,16 @@ mod inherent {
|
|||
#[inline]
|
||||
pub fn one() -> $T { 1 }
|
||||
|
||||
/// Returns the smallest value that can be represented by this integer type.
|
||||
/// Returns the smallest value that can be represented by this integer
|
||||
/// type.
|
||||
// FIXME (#5527): Should be and associated constant
|
||||
#[unstable(feature = "core",
|
||||
reason = "unsure about its place in the world")]
|
||||
#[inline]
|
||||
pub fn min_value() -> $T { 0 }
|
||||
|
||||
/// Returns the largest value that can be represented by this integer type.
|
||||
/// Returns the largest value that can be represented by this integer
|
||||
/// type.
|
||||
// FIXME (#5527): Should be and associated constant
|
||||
#[unstable(feature = "core",
|
||||
reason = "unsure about its place in the world")]
|
||||
|
@ -1295,7 +1266,9 @@ mod inherent {
|
|||
#[unstable(feature = "core",
|
||||
reason = "pending integer conventions")]
|
||||
#[inline]
|
||||
pub fn count_ones(self) -> u32 { unsafe { $ctpop(self as $ActualT) as u32 } }
|
||||
pub fn count_ones(self) -> u32 {
|
||||
unsafe { $ctpop(self as $ActualT) as u32 }
|
||||
}
|
||||
|
||||
/// Returns the number of zeros in the binary representation of `self`.
|
||||
///
|
||||
|
@ -1330,7 +1303,9 @@ mod inherent {
|
|||
#[unstable(feature = "core",
|
||||
reason = "pending integer conventions")]
|
||||
#[inline]
|
||||
pub fn leading_zeros(self) -> u32 { unsafe { $ctlz(self as $ActualT) as u32 } }
|
||||
pub fn leading_zeros(self) -> u32 {
|
||||
unsafe { $ctlz(self as $ActualT) as u32 }
|
||||
}
|
||||
|
||||
/// Returns the number of trailing zeros in the binary representation
|
||||
/// of `self`.
|
||||
|
@ -1347,10 +1322,12 @@ mod inherent {
|
|||
#[unstable(feature = "core",
|
||||
reason = "pending integer conventions")]
|
||||
#[inline]
|
||||
pub fn trailing_zeros(self) -> u32 { unsafe { $cttz(self as $ActualT) as u32 } }
|
||||
pub fn trailing_zeros(self) -> u32 {
|
||||
unsafe { $cttz(self as $ActualT) as u32 }
|
||||
}
|
||||
|
||||
/// Shifts the bits to the left by a specified amount amount, `n`, wrapping
|
||||
/// the truncated bits to the end of the resulting integer.
|
||||
/// Shifts the bits to the left by a specified amount amount, `n`,
|
||||
/// wrapping the truncated bits to the end of the resulting integer.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
|
@ -1371,8 +1348,9 @@ mod inherent {
|
|||
(self << n) | (self >> (($BITS - n) % $BITS))
|
||||
}
|
||||
|
||||
/// Shifts the bits to the right by a specified amount amount, `n`, wrapping
|
||||
/// the truncated bits to the beginning of the resulting integer.
|
||||
/// Shifts the bits to the right by a specified amount amount, `n`,
|
||||
/// wrapping the truncated bits to the beginning of the resulting
|
||||
/// integer.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
|
@ -1407,11 +1385,14 @@ mod inherent {
|
|||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[inline]
|
||||
pub fn swap_bytes(self) -> $T { unsafe { $bswap(self as $ActualT) as $T } }
|
||||
pub fn swap_bytes(self) -> $T {
|
||||
unsafe { $bswap(self as $ActualT) as $T }
|
||||
}
|
||||
|
||||
/// Convert an integer from big endian to the target's endianness.
|
||||
///
|
||||
/// On big endian this is a no-op. On little endian the bytes are swapped.
|
||||
/// On big endian this is a no-op. On little endian the bytes are
|
||||
/// swapped.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
|
@ -1434,7 +1415,8 @@ mod inherent {
|
|||
|
||||
/// Convert an integer from little endian to the target's endianness.
|
||||
///
|
||||
/// On little endian this is a no-op. On big endian the bytes are swapped.
|
||||
/// On little endian this is a no-op. On big endian the bytes are
|
||||
/// swapped.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
|
@ -1457,7 +1439,8 @@ mod inherent {
|
|||
|
||||
/// Convert `self` to big endian from the target's endianness.
|
||||
///
|
||||
/// On big endian this is a no-op. On little endian the bytes are swapped.
|
||||
/// On big endian this is a no-op. On little endian the bytes are
|
||||
/// swapped.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
|
@ -1480,7 +1463,8 @@ mod inherent {
|
|||
|
||||
/// Convert `self` to little endian from the target's endianness.
|
||||
///
|
||||
/// On little endian this is a no-op. On big endian the bytes are swapped.
|
||||
/// On little endian this is a no-op. On big endian the bytes are
|
||||
/// swapped.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
|
@ -1501,8 +1485,8 @@ mod inherent {
|
|||
if cfg!(target_endian = "little") { self } else { self.swap_bytes() }
|
||||
}
|
||||
|
||||
/// Checked integer addition. Computes `self + other`, returning `None` if
|
||||
/// overflow occurred.
|
||||
/// Checked integer addition. Computes `self + other`, returning `None`
|
||||
/// if overflow occurred.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
|
@ -1518,8 +1502,8 @@ mod inherent {
|
|||
checked_op!($T, $ActualT, $add_with_overflow, self, other)
|
||||
}
|
||||
|
||||
/// Checked integer subtraction. Computes `self - other`, returning `None`
|
||||
/// if underflow occurred.
|
||||
/// Checked integer subtraction. Computes `self - other`, returning
|
||||
/// `None` if underflow occurred.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
|
@ -1552,8 +1536,8 @@ mod inherent {
|
|||
checked_op!($T, $ActualT, $mul_with_overflow, self, other)
|
||||
}
|
||||
|
||||
/// Checked integer division. Computes `self / other`, returning `None` if
|
||||
/// `other == 0` or the operation results in underflow or overflow.
|
||||
/// Checked integer division. Computes `self / other`, returning `None`
|
||||
/// if `other == 0` or the operation results in underflow or overflow.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
|
@ -1585,8 +1569,8 @@ mod inherent {
|
|||
}
|
||||
}
|
||||
|
||||
/// Saturating integer subtraction. Computes `self - other`, saturating at
|
||||
/// the numeric bounds instead of overflowing.
|
||||
/// Saturating integer subtraction. Computes `self - other`, saturating
|
||||
/// at the numeric bounds instead of overflowing.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[inline]
|
||||
pub fn saturating_sub(self, other: $T) -> $T {
|
||||
|
@ -1639,7 +1623,8 @@ mod inherent {
|
|||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[inline]
|
||||
pub fn is_power_of_two(self) -> bool {
|
||||
(self.wrapping_sub(<$T>::one())) & self == <$T>::zero() && !(self == <$T>::zero())
|
||||
(self.wrapping_sub(<$T>::one())) & self == <$T>::zero() &&
|
||||
!(self == <$T>::zero())
|
||||
}
|
||||
|
||||
/// Returns the smallest power of two greater than or equal to `self`.
|
||||
|
@ -1652,9 +1637,9 @@ mod inherent {
|
|||
one << ((bits - self.wrapping_sub(one).leading_zeros() as usize) % bits)
|
||||
}
|
||||
|
||||
/// Returns the smallest power of two greater than or equal to `n`. If the
|
||||
/// next power of two is greater than the type's maximum value, `None` is
|
||||
/// returned, otherwise the power of two is wrapped in `Some`.
|
||||
/// Returns the smallest power of two greater than or equal to `n`. If
|
||||
/// the next power of two is greater than the type's maximum value,
|
||||
/// `None` is returned, otherwise the power of two is wrapped in `Some`.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub fn checked_next_power_of_two(self) -> Option<$T> {
|
||||
let npot = self.next_power_of_two();
|
||||
|
@ -1665,14 +1650,10 @@ mod inherent {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Swapping a single byte is a no-op. This is marked as `unsafe` for
|
||||
/// consistency with the other `bswap` intrinsics.
|
||||
unsafe fn bswap8(x: u8) -> u8 { x }
|
||||
|
||||
#[lang = "u8"]
|
||||
impl u8 {
|
||||
#[lang = "u8"]
|
||||
impl u8 {
|
||||
uint_impl! { u8 = u8, 8,
|
||||
intrinsics::ctpop8,
|
||||
intrinsics::ctlz8,
|
||||
|
@ -1681,10 +1662,10 @@ mod inherent {
|
|||
intrinsics::u8_add_with_overflow,
|
||||
intrinsics::u8_sub_with_overflow,
|
||||
intrinsics::u8_mul_with_overflow }
|
||||
}
|
||||
}
|
||||
|
||||
#[lang = "u16"]
|
||||
impl u16 {
|
||||
#[lang = "u16"]
|
||||
impl u16 {
|
||||
uint_impl! { u16 = u16, 16,
|
||||
intrinsics::ctpop16,
|
||||
intrinsics::ctlz16,
|
||||
|
@ -1693,10 +1674,10 @@ mod inherent {
|
|||
intrinsics::u16_add_with_overflow,
|
||||
intrinsics::u16_sub_with_overflow,
|
||||
intrinsics::u16_mul_with_overflow }
|
||||
}
|
||||
}
|
||||
|
||||
#[lang = "u32"]
|
||||
impl u32 {
|
||||
#[lang = "u32"]
|
||||
impl u32 {
|
||||
uint_impl! { u32 = u32, 32,
|
||||
intrinsics::ctpop32,
|
||||
intrinsics::ctlz32,
|
||||
|
@ -1705,11 +1686,11 @@ mod inherent {
|
|||
intrinsics::u32_add_with_overflow,
|
||||
intrinsics::u32_sub_with_overflow,
|
||||
intrinsics::u32_mul_with_overflow }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[lang = "u64"]
|
||||
impl u64 {
|
||||
#[lang = "u64"]
|
||||
impl u64 {
|
||||
uint_impl! { u64 = u64, 64,
|
||||
intrinsics::ctpop64,
|
||||
intrinsics::ctlz64,
|
||||
|
@ -1718,11 +1699,11 @@ mod inherent {
|
|||
intrinsics::u64_add_with_overflow,
|
||||
intrinsics::u64_sub_with_overflow,
|
||||
intrinsics::u64_mul_with_overflow }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_pointer_width = "32")]
|
||||
#[lang = "usize"]
|
||||
impl usize {
|
||||
#[cfg(target_pointer_width = "32")]
|
||||
#[lang = "usize"]
|
||||
impl usize {
|
||||
uint_impl! { uint = u32, 32,
|
||||
intrinsics::ctpop32,
|
||||
intrinsics::ctlz32,
|
||||
|
@ -1731,11 +1712,11 @@ mod inherent {
|
|||
intrinsics::u32_add_with_overflow,
|
||||
intrinsics::u32_sub_with_overflow,
|
||||
intrinsics::u32_mul_with_overflow }
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_pointer_width = "64")]
|
||||
#[lang = "usize"]
|
||||
impl usize {
|
||||
#[cfg(target_pointer_width = "64")]
|
||||
#[lang = "usize"]
|
||||
impl usize {
|
||||
uint_impl! { uint = u64, 64,
|
||||
intrinsics::ctpop64,
|
||||
intrinsics::ctlz64,
|
||||
|
@ -1744,7 +1725,6 @@ mod inherent {
|
|||
intrinsics::u64_add_with_overflow,
|
||||
intrinsics::u64_sub_with_overflow,
|
||||
intrinsics::u64_mul_with_overflow }
|
||||
}
|
||||
}
|
||||
|
||||
/// A generic trait for converting a value to a number.
|
||||
|
|
|
@ -42,8 +42,6 @@ pub use iter::{Extend, IteratorExt};
|
|||
pub use iter::{Iterator, DoubleEndedIterator};
|
||||
pub use iter::{ExactSizeIterator};
|
||||
pub use option::Option::{self, Some, None};
|
||||
#[cfg(stage0)]
|
||||
pub use ptr::{PtrExt, MutPtrExt};
|
||||
pub use result::Result::{self, Ok, Err};
|
||||
pub use slice::{AsSlice, SliceExt};
|
||||
pub use str::{Str, StrExt};
|
||||
|
|
|
@ -262,145 +262,13 @@ pub unsafe fn write<T>(dst: *mut T, src: T) {
|
|||
intrinsics::move_val_init(&mut *dst, src)
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
/// Methods on raw pointers
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub trait PtrExt {
|
||||
/// The type which is being pointed at
|
||||
type Target: ?Sized;
|
||||
|
||||
/// Returns true if the pointer is null.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
fn is_null(self) -> bool;
|
||||
|
||||
/// Returns `None` if the pointer is null, or else returns a reference to
|
||||
/// the value wrapped in `Some`.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// While this method and its mutable counterpart are useful for
|
||||
/// null-safety, it is important to note that this is still an unsafe
|
||||
/// operation because the returned value could be pointing to invalid
|
||||
/// memory.
|
||||
#[unstable(feature = "core",
|
||||
reason = "Option is not clearly the right return type, and we may want \
|
||||
to tie the return lifetime to a borrow of the raw pointer")]
|
||||
unsafe fn as_ref<'a>(&self) -> Option<&'a Self::Target>;
|
||||
|
||||
/// Calculates the offset from a pointer. `count` is in units of T; e.g. a
|
||||
/// `count` of 3 represents a pointer offset of `3 * sizeof::<T>()` bytes.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// The offset must be in-bounds of the object, or one-byte-past-the-end.
|
||||
/// Otherwise `offset` invokes Undefined Behaviour, regardless of whether
|
||||
/// the pointer is used.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
unsafe fn offset(self, count: isize) -> Self where Self::Target: Sized;
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
/// Methods on mutable raw pointers
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub trait MutPtrExt {
|
||||
/// The type which is being pointed at
|
||||
type Target: ?Sized;
|
||||
|
||||
/// Returns `None` if the pointer is null, or else returns a mutable
|
||||
/// reference to the value wrapped in `Some`.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// As with `as_ref`, this is unsafe because it cannot verify the validity
|
||||
/// of the returned pointer.
|
||||
#[unstable(feature = "core",
|
||||
reason = "Option is not clearly the right return type, and we may want \
|
||||
to tie the return lifetime to a borrow of the raw pointer")]
|
||||
unsafe fn as_mut<'a>(&self) -> Option<&'a mut Self::Target>;
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl<T: ?Sized> PtrExt for *const T {
|
||||
type Target = T;
|
||||
|
||||
#[inline]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
fn is_null(self) -> bool { self == 0 as *const T }
|
||||
|
||||
#[inline]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
unsafe fn offset(self, count: isize) -> *const T where T: Sized {
|
||||
intrinsics::offset(self, count)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[unstable(feature = "core",
|
||||
reason = "return value does not necessarily convey all possible \
|
||||
information")]
|
||||
unsafe fn as_ref<'a>(&self) -> Option<&'a T> {
|
||||
if self.is_null() {
|
||||
None
|
||||
} else {
|
||||
Some(&**self)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl<T: ?Sized> PtrExt for *mut T {
|
||||
type Target = T;
|
||||
|
||||
#[inline]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
fn is_null(self) -> bool { self == 0 as *mut T }
|
||||
|
||||
#[inline]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
unsafe fn offset(self, count: isize) -> *mut T where T: Sized {
|
||||
intrinsics::offset(self, count) as *mut T
|
||||
}
|
||||
|
||||
#[inline]
|
||||
#[unstable(feature = "core",
|
||||
reason = "return value does not necessarily convey all possible \
|
||||
information")]
|
||||
unsafe fn as_ref<'a>(&self) -> Option<&'a T> {
|
||||
if self.is_null() {
|
||||
None
|
||||
} else {
|
||||
Some(&**self)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl<T: ?Sized> MutPtrExt for *mut T {
|
||||
type Target = T;
|
||||
|
||||
#[inline]
|
||||
#[unstable(feature = "core",
|
||||
reason = "return value does not necessarily convey all possible \
|
||||
information")]
|
||||
unsafe fn as_mut<'a>(&self) -> Option<&'a mut T> {
|
||||
if self.is_null() {
|
||||
None
|
||||
} else {
|
||||
Some(&mut **self)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(stage0))]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[lang = "const_ptr"]
|
||||
impl<T: ?Sized> *const T {
|
||||
/// Returns true if the pointer is null.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[inline]
|
||||
pub fn is_null(self) -> bool {
|
||||
pub fn is_null(self) -> bool where T: Sized {
|
||||
self == 0 as *const T
|
||||
}
|
||||
|
||||
|
@ -417,7 +285,7 @@ impl<T: ?Sized> *const T {
|
|||
reason = "Option is not clearly the right return type, and we may want \
|
||||
to tie the return lifetime to a borrow of the raw pointer")]
|
||||
#[inline]
|
||||
pub unsafe fn as_ref<'a>(&self) -> Option<&'a T> {
|
||||
pub unsafe fn as_ref<'a>(&self) -> Option<&'a T> where T: Sized {
|
||||
if self.is_null() {
|
||||
None
|
||||
} else {
|
||||
|
@ -440,14 +308,13 @@ impl<T: ?Sized> *const T {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(not(stage0))]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[lang = "mut_ptr"]
|
||||
impl<T: ?Sized> *mut T {
|
||||
/// Returns true if the pointer is null.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[inline]
|
||||
pub fn is_null(self) -> bool {
|
||||
pub fn is_null(self) -> bool where T: Sized {
|
||||
self == 0 as *mut T
|
||||
}
|
||||
|
||||
|
@ -464,7 +331,7 @@ impl<T: ?Sized> *mut T {
|
|||
reason = "Option is not clearly the right return type, and we may want \
|
||||
to tie the return lifetime to a borrow of the raw pointer")]
|
||||
#[inline]
|
||||
pub unsafe fn as_ref<'a>(&self) -> Option<&'a T> {
|
||||
pub unsafe fn as_ref<'a>(&self) -> Option<&'a T> where T: Sized {
|
||||
if self.is_null() {
|
||||
None
|
||||
} else {
|
||||
|
@ -497,7 +364,7 @@ impl<T: ?Sized> *mut T {
|
|||
reason = "return value does not necessarily convey all possible \
|
||||
information")]
|
||||
#[inline]
|
||||
pub unsafe fn as_mut<'a>(&self) -> Option<&'a mut T> {
|
||||
pub unsafe fn as_mut<'a>(&self) -> Option<&'a mut T> where T: Sized {
|
||||
if self.is_null() {
|
||||
None
|
||||
} else {
|
||||
|
|
|
@ -49,8 +49,6 @@ use option::Option::{None, Some};
|
|||
use result::Result;
|
||||
use result::Result::{Ok, Err};
|
||||
use ptr;
|
||||
#[cfg(stage0)]
|
||||
use ptr::PtrExt;
|
||||
use mem;
|
||||
use mem::size_of;
|
||||
use marker::{Send, Sized, Sync, self};
|
||||
|
|
|
@ -31,8 +31,6 @@ use mem;
|
|||
use num::Int;
|
||||
use ops::{Fn, FnMut};
|
||||
use option::Option::{self, None, Some};
|
||||
#[cfg(stage0)]
|
||||
use ptr::PtrExt;
|
||||
use raw::{Repr, Slice};
|
||||
use result::Result::{self, Ok, Err};
|
||||
use slice::{self, SliceExt};
|
||||
|
|
|
@ -27,8 +27,6 @@ use middle::ty;
|
|||
use std::cmp::Ordering;
|
||||
use std::fmt;
|
||||
use std::iter::{range_inclusive, AdditiveIterator, FromIterator, IntoIterator, repeat};
|
||||
#[cfg(stage0)]
|
||||
use std::num::Float;
|
||||
use std::slice;
|
||||
use syntax::ast::{self, DUMMY_NODE_ID, NodeId, Pat};
|
||||
use syntax::ast_util;
|
||||
|
|
|
@ -204,8 +204,6 @@ use std::io::prelude::*;
|
|||
use std::io;
|
||||
use std::mem::{swap};
|
||||
use std::num::FpCategory as Fp;
|
||||
#[cfg(stage0)]
|
||||
use std::num::{Float, Int};
|
||||
use std::ops::Index;
|
||||
use std::str::FromStr;
|
||||
use std::string;
|
||||
|
|
|
@ -23,8 +23,6 @@ use hash::{Hash, SipHasher};
|
|||
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};
|
||||
use rand::{self, Rng};
|
||||
|
|
|
@ -19,15 +19,10 @@ use iter::{Iterator, IteratorExt, ExactSizeIterator, count};
|
|||
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};
|
||||
use option::Option;
|
||||
use option::Option::{Some, None};
|
||||
#[cfg(stage0)]
|
||||
use ptr::{self, PtrExt, Unique};
|
||||
#[cfg(not(stage0))]
|
||||
use ptr::{self, Unique};
|
||||
use rt::heap::{allocate, deallocate, EMPTY};
|
||||
use collections::hash_state::HashState;
|
||||
|
|
|
@ -272,10 +272,6 @@ mod dl {
|
|||
use ptr;
|
||||
use result::Result;
|
||||
use result::Result::{Ok, Err};
|
||||
#[cfg(stage0)]
|
||||
use slice::SliceExt;
|
||||
#[cfg(stage0)]
|
||||
use str::StrExt;
|
||||
use str;
|
||||
use string::String;
|
||||
use vec::Vec;
|
||||
|
@ -294,10 +290,11 @@ mod dl {
|
|||
let err = os::errno();
|
||||
if err as libc::c_int == ERROR_CALL_NOT_IMPLEMENTED {
|
||||
use_thread_mode = false;
|
||||
// SetThreadErrorMode not found. use fallback solution: SetErrorMode()
|
||||
// Note that SetErrorMode is process-wide so this can cause race condition!
|
||||
// However, since even Windows APIs do not care of such problem (#20650),
|
||||
// we just assume SetErrorMode race is not a great deal.
|
||||
// SetThreadErrorMode not found. use fallback solution:
|
||||
// SetErrorMode() Note that SetErrorMode is process-wide so
|
||||
// this can cause race condition! However, since even
|
||||
// Windows APIs do not care of such problem (#20650), we
|
||||
// just assume SetErrorMode race is not a great deal.
|
||||
prev_error_mode = SetErrorMode(new_error_mode);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,12 +22,7 @@ use old_io;
|
|||
use ops::Deref;
|
||||
use option::Option::{self, Some, None};
|
||||
use result::Result::{self, Ok, Err};
|
||||
#[cfg(stage0)]
|
||||
use slice::{self, SliceExt};
|
||||
#[cfg(not(stage0))]
|
||||
use slice;
|
||||
#[cfg(stage0)]
|
||||
use str::StrExt;
|
||||
use string::String;
|
||||
use vec::Vec;
|
||||
|
||||
|
|
|
@ -20,18 +20,10 @@ use iter::Iterator;
|
|||
use marker::Sized;
|
||||
use ops::{Drop, FnOnce};
|
||||
use option::Option::{self, Some, None};
|
||||
#[cfg(stage0)]
|
||||
use ptr::PtrExt;
|
||||
use result::Result::{Ok, Err};
|
||||
use result;
|
||||
#[cfg(stage0)]
|
||||
use slice::{self, SliceExt};
|
||||
#[cfg(not(stage0))]
|
||||
use slice;
|
||||
use string::String;
|
||||
#[cfg(stage0)]
|
||||
use str::{self, StrExt};
|
||||
#[cfg(not(stage0))]
|
||||
use str;
|
||||
use vec::Vec;
|
||||
|
||||
|
|
|
@ -357,7 +357,6 @@ impl Float for f32 {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(not(stage0))]
|
||||
#[cfg(not(test))]
|
||||
#[lang = "f32"]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
|
|
|
@ -366,7 +366,6 @@ impl Float for f64 {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(not(stage0))]
|
||||
#[cfg(not(test))]
|
||||
#[lang = "f64"]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
|
|
|
@ -11,17 +11,6 @@
|
|||
#![unstable(feature = "std_misc")]
|
||||
#![doc(hidden)]
|
||||
|
||||
#[cfg(stage0)]
|
||||
macro_rules! assert_approx_eq {
|
||||
($a:expr, $b:expr) => ({
|
||||
use num::Float;
|
||||
let (a, b) = (&$a, &$b);
|
||||
assert!((*a - *b).abs() < 1.0e-6,
|
||||
"{} is not approximately equal to {}", *a, *b);
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(not(stage0))]
|
||||
macro_rules! assert_approx_eq {
|
||||
($a:expr, $b:expr) => ({
|
||||
let (a, b) = (&$a, &$b);
|
||||
|
|
|
@ -23,9 +23,6 @@ use marker::Copy;
|
|||
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};
|
||||
|
|
|
@ -16,17 +16,10 @@ use self::ExponentFormat::*;
|
|||
use self::SignificantDigits::*;
|
||||
use self::SignFormat::*;
|
||||
|
||||
#[cfg(stage0)]
|
||||
use char::{self, CharExt};
|
||||
#[cfg(not(stage0))]
|
||||
use char;
|
||||
use num::{self, Int, Float, ToPrimitive};
|
||||
use num::FpCategory as Fp;
|
||||
use ops::FnMut;
|
||||
#[cfg(stage0)]
|
||||
use slice::SliceExt;
|
||||
#[cfg(stage0)]
|
||||
use str::StrExt;
|
||||
use string::String;
|
||||
use vec::Vec;
|
||||
|
||||
|
|
|
@ -20,8 +20,6 @@ use ops::Drop;
|
|||
use option::Option;
|
||||
use option::Option::{Some, None};
|
||||
use result::Result::Ok;
|
||||
#[cfg(stage0)]
|
||||
use slice::{SliceExt};
|
||||
use slice;
|
||||
use vec::Vec;
|
||||
|
||||
|
|
|
@ -14,9 +14,6 @@ use sync::mpsc::{Sender, Receiver};
|
|||
use old_io;
|
||||
use option::Option::{None, Some};
|
||||
use result::Result::{Ok, Err};
|
||||
#[cfg(stage0)]
|
||||
use slice::{bytes, SliceExt};
|
||||
#[cfg(not(stage0))]
|
||||
use slice::bytes;
|
||||
use super::{Buffer, Reader, Writer, IoResult};
|
||||
use vec::Vec;
|
||||
|
|
|
@ -26,11 +26,7 @@ use num::Int;
|
|||
use ops::FnOnce;
|
||||
use option::Option;
|
||||
use option::Option::{Some, None};
|
||||
#[cfg(stage0)]
|
||||
use ptr::PtrExt;
|
||||
use result::Result::{Ok, Err};
|
||||
#[cfg(stage0)]
|
||||
use slice::SliceExt;
|
||||
|
||||
/// An iterator that reads a single byte on each iteration,
|
||||
/// until `.read_byte()` returns `EndOfFile`.
|
||||
|
@ -164,8 +160,6 @@ pub fn u64_to_be_bytes<T, F>(n: u64, size: uint, f: F) -> T where
|
|||
/// 32-bit value is parsed.
|
||||
pub fn u64_from_be_bytes(data: &[u8], start: uint, size: uint) -> u64 {
|
||||
use ptr::{copy_nonoverlapping_memory};
|
||||
#[cfg(stage0)]
|
||||
use slice::SliceExt;
|
||||
|
||||
assert!(size <= 8);
|
||||
|
||||
|
|
|
@ -64,8 +64,6 @@ use option::Option::{Some, None};
|
|||
use old_path::{Path, GenericPath};
|
||||
use old_path;
|
||||
use result::Result::{Err, Ok};
|
||||
#[cfg(stage0)]
|
||||
use slice::SliceExt;
|
||||
use string::String;
|
||||
use vec::Vec;
|
||||
|
||||
|
|
|
@ -17,9 +17,6 @@ use option::Option::None;
|
|||
use result::Result::{Err, Ok};
|
||||
use old_io;
|
||||
use old_io::{Reader, Writer, Seek, Buffer, IoError, SeekStyle, IoResult};
|
||||
#[cfg(stage0)]
|
||||
use slice::{self, SliceExt};
|
||||
#[cfg(not(stage0))]
|
||||
use slice;
|
||||
use vec::Vec;
|
||||
|
||||
|
|
|
@ -251,8 +251,6 @@ pub use self::FileMode::*;
|
|||
pub use self::FileAccess::*;
|
||||
pub use self::IoErrorKind::*;
|
||||
|
||||
#[cfg(stage0)]
|
||||
use char::CharExt;
|
||||
use default::Default;
|
||||
use error::Error;
|
||||
use fmt;
|
||||
|
@ -268,10 +266,6 @@ use boxed::Box;
|
|||
use result::Result;
|
||||
use result::Result::{Ok, Err};
|
||||
use sys;
|
||||
#[cfg(stage0)]
|
||||
use slice::SliceExt;
|
||||
#[cfg(stage0)]
|
||||
use str::StrExt;
|
||||
use str;
|
||||
use string::String;
|
||||
use usize;
|
||||
|
@ -935,8 +929,6 @@ impl<'a> Reader for &'a mut (Reader+'a) {
|
|||
// API yet. If so, it should be a method on Vec.
|
||||
unsafe fn slice_vec_capacity<'a, T>(v: &'a mut Vec<T>, start: uint, end: uint) -> &'a mut [T] {
|
||||
use slice;
|
||||
#[cfg(stage0)]
|
||||
use ptr::PtrExt;
|
||||
|
||||
assert!(start <= end);
|
||||
assert!(end <= v.capacity());
|
||||
|
|
|
@ -26,11 +26,6 @@ use ops::{FnOnce, FnMut};
|
|||
use option::Option;
|
||||
use option::Option::{None, Some};
|
||||
use result::Result::{self, Ok, Err};
|
||||
#[cfg(stage0)]
|
||||
use slice::SliceExt;
|
||||
#[cfg(stage0)]
|
||||
use str::{FromStr, StrExt};
|
||||
#[cfg(not(stage0))]
|
||||
use str::FromStr;
|
||||
use vec::Vec;
|
||||
|
||||
|
|
|
@ -43,10 +43,6 @@ use ops::{Deref, DerefMut, FnOnce};
|
|||
use ptr;
|
||||
use result::Result::{Ok, Err};
|
||||
use rt;
|
||||
#[cfg(stage0)]
|
||||
use slice::SliceExt;
|
||||
#[cfg(stage0)]
|
||||
use str::StrExt;
|
||||
use string::String;
|
||||
use sys::{fs, tty};
|
||||
use sync::{Arc, Mutex, MutexGuard, Once, ONCE_INIT};
|
||||
|
|
|
@ -21,8 +21,6 @@ use option::Option;
|
|||
use old_path::{Path, GenericPath};
|
||||
use rand::{Rng, thread_rng};
|
||||
use result::Result::{Ok, Err};
|
||||
#[cfg(stage0)]
|
||||
use str::StrExt;
|
||||
use string::String;
|
||||
|
||||
/// A wrapper for a path to temporary directory implementing automatic
|
||||
|
|
|
@ -72,11 +72,7 @@ use iter::IteratorExt;
|
|||
use option::Option;
|
||||
use option::Option::{None, Some};
|
||||
use str;
|
||||
#[cfg(stage0)]
|
||||
use str::StrExt;
|
||||
use string::{String, CowString};
|
||||
#[cfg(stage0)]
|
||||
use slice::SliceExt;
|
||||
use vec::Vec;
|
||||
|
||||
/// Typedef for POSIX file paths.
|
||||
|
|
|
@ -20,13 +20,7 @@ use iter::{Iterator, IteratorExt, Map};
|
|||
use marker::Sized;
|
||||
use option::Option::{self, Some, None};
|
||||
use result::Result::{self, Ok, Err};
|
||||
#[cfg(stage0)]
|
||||
use slice::{AsSlice, Split, SliceExt, SliceConcatExt};
|
||||
#[cfg(not(stage0))]
|
||||
use slice::{AsSlice, Split, SliceConcatExt};
|
||||
#[cfg(stage0)]
|
||||
use str::{self, FromStr, StrExt};
|
||||
#[cfg(not(stage0))]
|
||||
use str::{self, FromStr};
|
||||
use vec::Vec;
|
||||
|
||||
|
|
|
@ -15,8 +15,6 @@
|
|||
use self::PathPrefix::*;
|
||||
|
||||
use ascii::AsciiExt;
|
||||
#[cfg(stage0)]
|
||||
use char::CharExt;
|
||||
use clone::Clone;
|
||||
use cmp::{Ordering, Eq, Ord, PartialEq, PartialOrd};
|
||||
use fmt;
|
||||
|
@ -27,13 +25,7 @@ use iter::{Iterator, IteratorExt, Map, repeat};
|
|||
use mem;
|
||||
use option::Option::{self, Some, None};
|
||||
use result::Result::{self, Ok, Err};
|
||||
#[cfg(stage0)]
|
||||
use slice::{SliceExt, SliceConcatExt};
|
||||
#[cfg(not(stage0))]
|
||||
use slice::SliceConcatExt;
|
||||
#[cfg(stage0)]
|
||||
use str::{SplitTerminator, FromStr, StrExt};
|
||||
#[cfg(not(stage0))]
|
||||
use str::{SplitTerminator, FromStr};
|
||||
use string::{String, ToString};
|
||||
use vec::Vec;
|
||||
|
|
|
@ -52,18 +52,10 @@ use option::Option::{Some, None};
|
|||
use option::Option;
|
||||
use old_path::{Path, GenericPath, BytesContainer};
|
||||
use path::{self, PathBuf};
|
||||
#[cfg(stage0)]
|
||||
use ptr::PtrExt;
|
||||
use ptr;
|
||||
use result::Result::{Err, Ok};
|
||||
use result::Result;
|
||||
#[cfg(stage0)]
|
||||
use slice::{AsSlice, SliceExt};
|
||||
#[cfg(not(stage0))]
|
||||
use slice::AsSlice;
|
||||
#[cfg(stage0)]
|
||||
use str::{Str, StrExt};
|
||||
#[cfg(not(stage0))]
|
||||
use str::Str;
|
||||
use str;
|
||||
use string::{String, ToString};
|
||||
|
|
|
@ -159,8 +159,6 @@ mod platform {
|
|||
use core::prelude::*;
|
||||
use ascii::*;
|
||||
|
||||
#[cfg(stage0)]
|
||||
use char::CharExt as UnicodeCharExt;
|
||||
use super::{os_str_as_u8_slice, u8_slice_as_os_str, Prefix};
|
||||
use ffi::OsStr;
|
||||
|
||||
|
|
|
@ -25,9 +25,6 @@
|
|||
// Reexported types and traits
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[doc(no_inline)] pub use boxed::Box;
|
||||
#[cfg(stage0)]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[doc(no_inline)] pub use char::CharExt;
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[doc(no_inline)] pub use clone::Clone;
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
|
@ -40,21 +37,10 @@
|
|||
#[doc(no_inline)] pub use iter::{Iterator, IteratorExt, Extend};
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[doc(no_inline)] pub use option::Option::{self, Some, None};
|
||||
#[cfg(stage0)]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[doc(no_inline)] pub use ptr::{PtrExt, MutPtrExt};
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[doc(no_inline)] pub use result::Result::{self, Ok, Err};
|
||||
#[cfg(stage0)]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[doc(no_inline)] pub use slice::{SliceExt, SliceConcatExt, AsSlice};
|
||||
#[cfg(not(stage0))]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[doc(no_inline)] pub use slice::{SliceConcatExt, AsSlice};
|
||||
#[cfg(stage0)]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[doc(no_inline)] pub use str::{Str, StrExt};
|
||||
#[cfg(not(stage0))]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[doc(no_inline)] pub use str::Str;
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
|
|
|
@ -24,8 +24,6 @@ mod imp {
|
|||
use rand::Rng;
|
||||
use rand::reader::ReaderRng;
|
||||
use result::Result::Ok;
|
||||
#[cfg(stage0)]
|
||||
use slice::SliceExt;
|
||||
use mem;
|
||||
use os::errno;
|
||||
|
||||
|
@ -194,8 +192,6 @@ mod imp {
|
|||
use rand::Rng;
|
||||
use result::Result::{Ok};
|
||||
use self::libc::{c_int, size_t};
|
||||
#[cfg(stage0)]
|
||||
use slice::SliceExt;
|
||||
|
||||
/// A random number generator that retrieves randomness straight from
|
||||
/// the operating system. Platform sources:
|
||||
|
@ -265,8 +261,6 @@ mod imp {
|
|||
use result::Result::{Ok, Err};
|
||||
use self::libc::{DWORD, BYTE, LPCSTR, BOOL};
|
||||
use self::libc::types::os::arch::extra::{LONG_PTR};
|
||||
#[cfg(stage0)]
|
||||
use slice::SliceExt;
|
||||
|
||||
type HCRYPTPROV = LONG_PTR;
|
||||
|
||||
|
|
|
@ -13,8 +13,6 @@
|
|||
use old_io::Reader;
|
||||
use rand::Rng;
|
||||
use result::Result::{Ok, Err};
|
||||
#[cfg(stage0)]
|
||||
use slice::SliceExt;
|
||||
|
||||
/// An RNG that reads random bytes straight from a `Reader`. This will
|
||||
/// work best with an infinite reader, but this is not required.
|
||||
|
|
|
@ -12,9 +12,6 @@
|
|||
//!
|
||||
//! Documentation can be found on the `rt::at_exit` function.
|
||||
|
||||
#[cfg(stage0)]
|
||||
use core::prelude::*;
|
||||
|
||||
use boxed;
|
||||
use boxed::Box;
|
||||
use vec::Vec;
|
||||
|
|
|
@ -172,18 +172,6 @@ impl Wtf8Buf {
|
|||
Wtf8Buf { bytes: string.into_bytes() }
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
/// Create a WTF-8 string from an UTF-8 `&str` slice.
|
||||
///
|
||||
/// This copies the content of the slice.
|
||||
///
|
||||
/// Since WTF-8 is a superset of UTF-8, this always succeeds.
|
||||
#[inline]
|
||||
pub fn from_str(str: &str) -> Wtf8Buf {
|
||||
Wtf8Buf { bytes: slice::SliceExt::to_vec(str.as_bytes()) }
|
||||
}
|
||||
|
||||
#[cfg(not(stage0))]
|
||||
/// Create a WTF-8 string from an UTF-8 `&str` slice.
|
||||
///
|
||||
/// This copies the content of the slice.
|
||||
|
|
|
@ -16,8 +16,6 @@ use core::prelude::*;
|
|||
use borrow::Cow;
|
||||
use fmt::{self, Debug};
|
||||
use vec::Vec;
|
||||
#[cfg(stage0)]
|
||||
use slice::SliceExt as StdSliceExt;
|
||||
use str;
|
||||
use string::String;
|
||||
use mem;
|
||||
|
|
|
@ -128,8 +128,6 @@ impl Process {
|
|||
use env::split_paths;
|
||||
use mem;
|
||||
use iter::IteratorExt;
|
||||
#[cfg(stage0)]
|
||||
use str::StrExt;
|
||||
|
||||
// To have the spawning semantics of unix/windows stay the same, we need to
|
||||
// read the *child's* PATH if one is provided. See #15149 for more details.
|
||||
|
|
|
@ -78,8 +78,6 @@ use owned_slice::OwnedSlice;
|
|||
use std::collections::HashSet;
|
||||
use std::io::prelude::*;
|
||||
use std::mem;
|
||||
#[cfg(stage0)]
|
||||
use std::num::Float;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::rc::Rc;
|
||||
use std::slice;
|
||||
|
@ -5809,12 +5807,6 @@ impl<'a> Parser<'a> {
|
|||
None
|
||||
}
|
||||
|
||||
// HACK(eddyb) staging required for `quote_item!`.
|
||||
#[cfg(stage0)] // SNAP 270a677
|
||||
pub fn parse_item_with_outer_attributes(&mut self) -> Option<P<Item>> {
|
||||
self.parse_item()
|
||||
}
|
||||
|
||||
pub fn parse_item(&mut self) -> Option<P<Item>> {
|
||||
let attrs = self.parse_outer_attributes();
|
||||
self.parse_item_(attrs, true)
|
||||
|
|
|
@ -41,413 +41,6 @@ pub use normalize::{decompose_canonical, decompose_compatible, compose};
|
|||
pub use tables::normalization::canonical_combining_class;
|
||||
pub use tables::UNICODE_VERSION;
|
||||
|
||||
#[cfg(stage0)]
|
||||
/// Functionality for manipulating `char`.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub trait CharExt {
|
||||
/// Checks if a `char` parses as a numeric digit in the given radix.
|
||||
///
|
||||
/// Compared to `is_numeric()`, this function only recognizes the characters
|
||||
/// `0-9`, `a-z` and `A-Z`.
|
||||
///
|
||||
/// # Return value
|
||||
///
|
||||
/// Returns `true` if `c` is a valid digit under `radix`, and `false`
|
||||
/// otherwise.
|
||||
///
|
||||
/// # Panics
|
||||
///
|
||||
/// Panics if given a radix > 36.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// let c = '1';
|
||||
///
|
||||
/// assert!(c.is_digit(10));
|
||||
///
|
||||
/// assert!('f'.is_digit(16));
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
fn is_digit(self, radix: u32) -> bool;
|
||||
|
||||
/// Converts a character to the corresponding digit.
|
||||
///
|
||||
/// # Return value
|
||||
///
|
||||
/// If `c` is between '0' and '9', the corresponding value between 0 and
|
||||
/// 9. If `c` is 'a' or 'A', 10. If `c` is 'b' or 'B', 11, etc. Returns
|
||||
/// none if the character does not refer to a digit in the given radix.
|
||||
///
|
||||
/// # Panics
|
||||
///
|
||||
/// Panics if given a radix outside the range [0..36].
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// let c = '1';
|
||||
///
|
||||
/// assert_eq!(c.to_digit(10), Some(1));
|
||||
///
|
||||
/// assert_eq!('f'.to_digit(16), Some(15));
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
fn to_digit(self, radix: u32) -> Option<u32>;
|
||||
|
||||
/// Returns an iterator that yields the hexadecimal Unicode escape of a
|
||||
/// character, as `char`s.
|
||||
///
|
||||
/// All characters are escaped with Rust syntax of the form `\\u{NNNN}`
|
||||
/// where `NNNN` is the shortest hexadecimal representation of the code
|
||||
/// point.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// for i in '❤'.escape_unicode() {
|
||||
/// println!("{}", i);
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// This prints:
|
||||
///
|
||||
/// ```text
|
||||
/// \
|
||||
/// u
|
||||
/// {
|
||||
/// 2
|
||||
/// 7
|
||||
/// 6
|
||||
/// 4
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// Collecting into a `String`:
|
||||
///
|
||||
/// ```
|
||||
/// let heart: String = '❤'.escape_unicode().collect();
|
||||
///
|
||||
/// assert_eq!(heart, r"\u{2764}");
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
fn escape_unicode(self) -> EscapeUnicode;
|
||||
|
||||
/// Returns an iterator that yields the 'default' ASCII and
|
||||
/// C++11-like literal escape of a character, as `char`s.
|
||||
///
|
||||
/// The default is chosen with a bias toward producing literals that are
|
||||
/// legal in a variety of languages, including C++11 and similar C-family
|
||||
/// languages. The exact rules are:
|
||||
///
|
||||
/// * Tab, CR and LF are escaped as '\t', '\r' and '\n' respectively.
|
||||
/// * Single-quote, double-quote and backslash chars are backslash-
|
||||
/// escaped.
|
||||
/// * Any other chars in the range [0x20,0x7e] are not escaped.
|
||||
/// * Any other chars are given hex Unicode escapes; see `escape_unicode`.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// for i in '"'.escape_default() {
|
||||
/// println!("{}", i);
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// This prints:
|
||||
///
|
||||
/// ```text
|
||||
/// \
|
||||
/// "
|
||||
/// ```
|
||||
///
|
||||
/// Collecting into a `String`:
|
||||
///
|
||||
/// ```
|
||||
/// let quote: String = '"'.escape_default().collect();
|
||||
///
|
||||
/// assert_eq!(quote, "\\\"");
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
fn escape_default(self) -> EscapeDefault;
|
||||
|
||||
/// Returns the number of bytes this character would need if encoded in
|
||||
/// UTF-8.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// let n = 'ß'.len_utf8();
|
||||
///
|
||||
/// assert_eq!(n, 2);
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
fn len_utf8(self) -> usize;
|
||||
|
||||
/// Returns the number of 16-bit code units this character would need if
|
||||
/// encoded in UTF-16.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// let n = 'ß'.len_utf16();
|
||||
///
|
||||
/// assert_eq!(n, 1);
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
fn len_utf16(self) -> usize;
|
||||
|
||||
/// Encodes this character as UTF-8 into the provided byte buffer, and then
|
||||
/// returns the number of bytes written.
|
||||
///
|
||||
/// If the buffer is not large enough, nothing will be written into it and a
|
||||
/// `None` will be returned. A buffer of length four is large enough to
|
||||
/// encode any `char`.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// In both of these examples, 'ß' takes two bytes to encode.
|
||||
///
|
||||
/// ```
|
||||
/// let mut b = [0; 2];
|
||||
///
|
||||
/// let result = 'ß'.encode_utf8(&mut b);
|
||||
///
|
||||
/// assert_eq!(result, Some(2));
|
||||
/// ```
|
||||
///
|
||||
/// A buffer that's too small:
|
||||
///
|
||||
/// ```
|
||||
/// let mut b = [0; 1];
|
||||
///
|
||||
/// let result = 'ß'.encode_utf8(&mut b);
|
||||
///
|
||||
/// assert_eq!(result, None);
|
||||
/// ```
|
||||
#[unstable(feature = "unicode",
|
||||
reason = "pending decision about Iterator/Writer/Reader")]
|
||||
fn encode_utf8(self, dst: &mut [u8]) -> Option<usize>;
|
||||
|
||||
/// Encodes this character as UTF-16 into the provided `u16` buffer, and
|
||||
/// then returns the number of `u16`s written.
|
||||
///
|
||||
/// If the buffer is not large enough, nothing will be written into it and a
|
||||
/// `None` will be returned. A buffer of length 2 is large enough to encode
|
||||
/// any `char`.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// In both of these examples, 'ß' takes one `u16` to encode.
|
||||
///
|
||||
/// ```
|
||||
/// let mut b = [0; 1];
|
||||
///
|
||||
/// let result = 'ß'.encode_utf16(&mut b);
|
||||
///
|
||||
/// assert_eq!(result, Some(1));
|
||||
/// ```
|
||||
///
|
||||
/// A buffer that's too small:
|
||||
///
|
||||
/// ```
|
||||
/// let mut b = [0; 0];
|
||||
///
|
||||
/// let result = 'ß'.encode_utf8(&mut b);
|
||||
///
|
||||
/// assert_eq!(result, None);
|
||||
/// ```
|
||||
#[unstable(feature = "unicode",
|
||||
reason = "pending decision about Iterator/Writer/Reader")]
|
||||
fn encode_utf16(self, dst: &mut [u16]) -> Option<usize>;
|
||||
|
||||
/// Returns whether the specified character is considered a Unicode
|
||||
/// alphabetic code point.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
fn is_alphabetic(self) -> bool;
|
||||
|
||||
/// Returns whether the specified character satisfies the 'XID_Start'
|
||||
/// Unicode property.
|
||||
///
|
||||
/// 'XID_Start' is a Unicode Derived Property specified in
|
||||
/// [UAX #31](http://unicode.org/reports/tr31/#NFKC_Modifications),
|
||||
/// mostly similar to ID_Start but modified for closure under NFKx.
|
||||
#[unstable(feature = "unicode",
|
||||
reason = "mainly needed for compiler internals")]
|
||||
fn is_xid_start(self) -> bool;
|
||||
|
||||
/// Returns whether the specified `char` satisfies the 'XID_Continue'
|
||||
/// Unicode property.
|
||||
///
|
||||
/// 'XID_Continue' is a Unicode Derived Property specified in
|
||||
/// [UAX #31](http://unicode.org/reports/tr31/#NFKC_Modifications),
|
||||
/// mostly similar to 'ID_Continue' but modified for closure under NFKx.
|
||||
#[unstable(feature = "unicode",
|
||||
reason = "mainly needed for compiler internals")]
|
||||
fn is_xid_continue(self) -> bool;
|
||||
|
||||
/// Indicates whether a character is in lowercase.
|
||||
///
|
||||
/// This is defined according to the terms of the Unicode Derived Core
|
||||
/// Property `Lowercase`.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
fn is_lowercase(self) -> bool;
|
||||
|
||||
/// Indicates whether a character is in uppercase.
|
||||
///
|
||||
/// This is defined according to the terms of the Unicode Derived Core
|
||||
/// Property `Uppercase`.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
fn is_uppercase(self) -> bool;
|
||||
|
||||
/// Indicates whether a character is whitespace.
|
||||
///
|
||||
/// Whitespace is defined in terms of the Unicode Property `White_Space`.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
fn is_whitespace(self) -> bool;
|
||||
|
||||
/// Indicates whether a character is alphanumeric.
|
||||
///
|
||||
/// Alphanumericness is defined in terms of the Unicode General Categories
|
||||
/// 'Nd', 'Nl', 'No' and the Derived Core Property 'Alphabetic'.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
fn is_alphanumeric(self) -> bool;
|
||||
|
||||
/// Indicates whether a character is a control code point.
|
||||
///
|
||||
/// Control code points are defined in terms of the Unicode General
|
||||
/// Category `Cc`.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
fn is_control(self) -> bool;
|
||||
|
||||
/// Indicates whether the character is numeric (Nd, Nl, or No).
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
fn is_numeric(self) -> bool;
|
||||
|
||||
/// Converts a character to its lowercase equivalent.
|
||||
///
|
||||
/// The case-folding performed is the common or simple mapping. See
|
||||
/// `to_uppercase()` for references and more information.
|
||||
///
|
||||
/// # Return value
|
||||
///
|
||||
/// Returns an iterator which yields the characters corresponding to the
|
||||
/// lowercase equivalent of the character. If no conversion is possible then
|
||||
/// the input character is returned.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
fn to_lowercase(self) -> ToLowercase;
|
||||
|
||||
/// Converts a character to its uppercase equivalent.
|
||||
///
|
||||
/// The case-folding performed is the common or simple mapping: it maps
|
||||
/// one Unicode codepoint to its uppercase equivalent according to the
|
||||
/// Unicode database [1]. The additional [`SpecialCasing.txt`] is not yet
|
||||
/// considered here, but the iterator returned will soon support this form
|
||||
/// of case folding.
|
||||
///
|
||||
/// A full reference can be found here [2].
|
||||
///
|
||||
/// # Return value
|
||||
///
|
||||
/// Returns an iterator which yields the characters corresponding to the
|
||||
/// uppercase equivalent of the character. If no conversion is possible then
|
||||
/// the input character is returned.
|
||||
///
|
||||
/// [1]: ftp://ftp.unicode.org/Public/UNIDATA/UnicodeData.txt
|
||||
///
|
||||
/// [`SpecialCasing`.txt`]: ftp://ftp.unicode.org/Public/UNIDATA/SpecialCasing.txt
|
||||
///
|
||||
/// [2]: http://www.unicode.org/versions/Unicode4.0.0/ch03.pdf#G33992
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
fn to_uppercase(self) -> ToUppercase;
|
||||
|
||||
/// Returns this character's displayed width in columns, or `None` if it is a
|
||||
/// control character other than `'\x00'`.
|
||||
///
|
||||
/// `is_cjk` determines behavior for characters in the Ambiguous category:
|
||||
/// if `is_cjk` is `true`, these are 2 columns wide; otherwise, they are 1.
|
||||
/// In CJK contexts, `is_cjk` should be `true`, else it should be `false`.
|
||||
/// [Unicode Standard Annex #11](http://www.unicode.org/reports/tr11/)
|
||||
/// recommends that these characters be treated as 1 column (i.e.,
|
||||
/// `is_cjk` = `false`) if the context cannot be reliably determined.
|
||||
#[unstable(feature = "unicode",
|
||||
reason = "needs expert opinion. is_cjk flag stands out as ugly")]
|
||||
fn width(self, is_cjk: bool) -> Option<usize>;
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl CharExt for char {
|
||||
fn is_digit(self, radix: u32) -> bool { C::is_digit(self, radix) }
|
||||
fn to_digit(self, radix: u32) -> Option<u32> { C::to_digit(self, radix) }
|
||||
fn escape_unicode(self) -> EscapeUnicode { C::escape_unicode(self) }
|
||||
fn escape_default(self) -> EscapeDefault { C::escape_default(self) }
|
||||
fn len_utf8(self) -> usize { C::len_utf8(self) }
|
||||
fn len_utf16(self) -> usize { C::len_utf16(self) }
|
||||
fn encode_utf8(self, dst: &mut [u8]) -> Option<usize> { C::encode_utf8(self, dst) }
|
||||
fn encode_utf16(self, dst: &mut [u16]) -> Option<usize> { C::encode_utf16(self, dst) }
|
||||
|
||||
fn is_alphabetic(self) -> bool {
|
||||
match self {
|
||||
'a' ... 'z' | 'A' ... 'Z' => true,
|
||||
c if c > '\x7f' => derived_property::Alphabetic(c),
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
|
||||
fn is_xid_start(self) -> bool { derived_property::XID_Start(self) }
|
||||
|
||||
fn is_xid_continue(self) -> bool { derived_property::XID_Continue(self) }
|
||||
|
||||
fn is_lowercase(self) -> bool {
|
||||
match self {
|
||||
'a' ... 'z' => true,
|
||||
c if c > '\x7f' => derived_property::Lowercase(c),
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
|
||||
fn is_uppercase(self) -> bool {
|
||||
match self {
|
||||
'A' ... 'Z' => true,
|
||||
c if c > '\x7f' => derived_property::Uppercase(c),
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
|
||||
fn is_whitespace(self) -> bool {
|
||||
match self {
|
||||
' ' | '\x09' ... '\x0d' => true,
|
||||
c if c > '\x7f' => property::White_Space(c),
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
|
||||
fn is_alphanumeric(self) -> bool {
|
||||
self.is_alphabetic() || self.is_numeric()
|
||||
}
|
||||
|
||||
fn is_control(self) -> bool { general_category::Cc(self) }
|
||||
|
||||
fn is_numeric(self) -> bool {
|
||||
match self {
|
||||
'0' ... '9' => true,
|
||||
c if c > '\x7f' => general_category::N(c),
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
|
||||
fn to_lowercase(self) -> ToLowercase {
|
||||
ToLowercase(Some(conversions::to_lower(self)))
|
||||
}
|
||||
|
||||
fn to_uppercase(self) -> ToUppercase {
|
||||
ToUppercase(Some(conversions::to_upper(self)))
|
||||
}
|
||||
|
||||
fn width(self, is_cjk: bool) -> Option<usize> { charwidth::width(self, is_cjk) }
|
||||
}
|
||||
|
||||
/// An iterator over the lowercase mapping of a given character, returned from
|
||||
/// the `lowercase` method on characters.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
|
@ -470,7 +63,6 @@ impl Iterator for ToUppercase {
|
|||
fn next(&mut self) -> Option<char> { self.0.take() }
|
||||
}
|
||||
|
||||
#[cfg(not(stage0))]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[lang = "char"]
|
||||
impl char {
|
||||
|
|
|
@ -26,8 +26,6 @@ use core::num::Int;
|
|||
use core::slice;
|
||||
use core::str::Split;
|
||||
|
||||
#[cfg(stage0)]
|
||||
use char::CharExt as UCharExt; // conflicts with core::prelude::CharExt
|
||||
use tables::grapheme::GraphemeCat;
|
||||
|
||||
/// An iterator over the words of a string, separated by a sequence of whitespace
|
||||
|
@ -244,7 +242,7 @@ impl<'a> Iterator for Graphemes<'a> {
|
|||
}
|
||||
|
||||
self.cat = if take_curr {
|
||||
idx = idx + len_utf8(self.string.char_at(idx));
|
||||
idx = idx + self.string.char_at(idx).len_utf8();
|
||||
None
|
||||
} else {
|
||||
Some(cat)
|
||||
|
@ -256,11 +254,6 @@ impl<'a> Iterator for Graphemes<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(stage0)]
|
||||
fn len_utf8(c: char) -> usize { UCharExt::len_utf8(c) }
|
||||
#[cfg(not(stage0))]
|
||||
fn len_utf8(c: char) -> usize { c.len_utf8() }
|
||||
|
||||
impl<'a> DoubleEndedIterator for Graphemes<'a> {
|
||||
#[inline]
|
||||
fn next_back(&mut self) -> Option<&'a str> {
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#![feature(exit_status)]
|
||||
#![feature(rustdoc)]
|
||||
#![feature(rustc_private)]
|
||||
#![feature(path_relative_from)]
|
||||
|
||||
extern crate rustdoc;
|
||||
extern crate rustc_back;
|
||||
|
|
|
@ -1,3 +1,13 @@
|
|||
S 2015-03-17 c64d671
|
||||
bitrig-x86_64 4b2f11a96b1b5b3782d74bda707aca33bc179880
|
||||
freebsd-x86_64 14ced24e1339a4dd8baa9db69995daa52a948d54
|
||||
linux-i386 200450ad3cc56bc715ca105b9acae35204bf7351
|
||||
linux-x86_64 a54f50fee722ba6bc7281dec3e4d5121af7c15e3
|
||||
macos-i386 e33fd692f3808a0265e7b02fbc40e403080cdd4f
|
||||
macos-x86_64 9a89ed364ae71aeb9d659ad223eae5f5986fc03f
|
||||
winnt-i386 8911a28581e490d413b56467a6184545633ca04a
|
||||
winnt-x86_64 38ce4556b19472c23ccce28685e3a2ebefb9bfbc
|
||||
|
||||
S 2015-03-07 270a677
|
||||
bitrig-x86_64 4b2f11a96b1b5b3782d74bda707aca33bc179880
|
||||
freebsd-x86_64 3c147d8e4cfdcb02c2569f5aca689a1d8920d17b
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue