}
impl<T: Clone> Arc<T> {
- #[unstable(feature = "arc_make_unique", reason = "renamed to Arc::make_mut",
- issue = "27718")]
- #[rustc_deprecated(since = "1.4.0", reason = "renamed to Arc::make_mut")]
- pub fn make_unique(this: &mut Self) -> &mut T {
- Arc::make_mut(this)
- }
-
/// Make a mutable reference into the given `Arc<T>` by cloning the inner
/// data if the `Arc<T>` doesn't have one strong reference and no weak
/// references.
}
impl<T: Clone> Rc<T> {
- #[inline]
- #[unstable(feature = "rc_make_unique", reason = "renamed to Rc::make_mut",
- issue = "27718")]
- #[rustc_deprecated(since = "1.4.0", reason = "renamed to Rc::make_mut")]
- pub fn make_unique(&mut self) -> &mut T {
- Rc::make_mut(self)
- }
-
/// Make a mutable reference into the given `Rc<T>` by cloning the inner
/// data if the `Rc<T>` doesn't have one strong reference and no weak
/// references.
BinaryHeap { data: Vec::with_capacity(capacity) }
}
- /// Creates a `BinaryHeap` from a vector. This is sometimes called
- /// `heapifying` the vector.
- ///
- /// # Examples
- ///
- /// ```
- /// #![feature(binary_heap_extras)]
- /// # #![allow(deprecated)]
- ///
- /// use std::collections::BinaryHeap;
- /// let heap = BinaryHeap::from_vec(vec![9, 1, 2, 7, 3, 2]);
- /// ```
- #[unstable(feature = "binary_heap_extras",
- reason = "needs to be audited",
- issue = "28147")]
- #[rustc_deprecated(since = "1.5.0", reason = "use BinaryHeap::from instead")]
- pub fn from_vec(vec: Vec<T>) -> BinaryHeap<T> {
- BinaryHeap::from(vec)
- }
-
/// Returns an iterator visiting all values in the underlying vector, in
/// arbitrary order.
///
#[stable(feature = "rust1", since = "1.0.0")]
#[allow(deprecated)]
pub fn new() -> BTreeMap<K, V> {
- // FIXME(Gankro): Tune this as a function of size_of<K/V>?
- BTreeMap::with_b(6)
- }
-
- /// Makes a new empty BTreeMap with the given B.
- ///
- /// B cannot be less than 2.
- #[unstable(feature = "btree_b",
- reason = "probably want this to be on the type, eventually",
- issue = "27795")]
- #[rustc_deprecated(since = "1.4.0", reason = "niche API")]
- pub fn with_b(b: usize) -> BTreeMap<K, V> {
- assert!(b > 1, "B must be greater than 1");
BTreeMap {
length: 0,
depth: 1,
- root: Node::make_leaf_root(b),
- b: b,
+ root: Node::make_leaf_root(6),
+ // FIXME(Gankro): Tune this as a function of size_of<K/V>?
+ b: 6,
}
+
}
/// Clears the map, removing all values.
/// assert!(a.is_empty());
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
- #[allow(deprecated)]
pub fn clear(&mut self) {
- let b = self.b;
// avoid recursive destructors by manually traversing the tree
- for _ in mem::replace(self, BTreeMap::with_b(b)) {}
+ for _ in mem::replace(self, BTreeMap::new()) {}
}
// Searching in a B-Tree is pretty straightforward.
pub fn new() -> BTreeSet<T> {
BTreeSet { map: BTreeMap::new() }
}
-
- /// Makes a new BTreeSet with the given B.
- ///
- /// B cannot be less than 2.
- #[unstable(feature = "btree_b",
- reason = "probably want this to be on the type, eventually",
- issue = "27795")]
- #[rustc_deprecated(since = "1.4.0", reason = "niche API")]
- #[allow(deprecated)]
- pub fn with_b(b: usize) -> BTreeSet<T> {
- BTreeSet { map: BTreeMap::with_b(b) }
- }
}
impl<T> BTreeSet<T> {
pub use core::slice::{SplitMut, ChunksMut, Split};
#[stable(feature = "rust1", since = "1.0.0")]
pub use core::slice::{SplitN, RSplitN, SplitNMut, RSplitNMut};
-#[unstable(feature = "ref_slice", issue = "27774")]
-#[allow(deprecated)]
-pub use core::slice::{bytes, mut_ref_slice, ref_slice};
#[stable(feature = "rust1", since = "1.0.0")]
pub use core::slice::{from_raw_parts, from_raw_parts_mut};
let slice = self.vec.into_boxed_slice();
unsafe { mem::transmute::<Box<[u8]>, Box<str>>(slice) }
}
-
- /// Converts the string into `Box<str>`.
- ///
- /// Note that this will drop any excess capacity.
- #[unstable(feature = "box_str2",
- reason = "recently added, matches RFC",
- issue = "27785")]
- #[rustc_deprecated(since = "1.4.0", reason = "renamed to `into_boxed_str`")]
- pub fn into_boxed_slice(self) -> Box<str> {
- self.into_boxed_str()
- }
}
impl FromUtf8Error {
self.pop_back()
}
- /// deprecated
- #[unstable(feature = "deque_extras",
- reason = "the naming of this function may be altered",
- issue = "27788")]
- #[rustc_deprecated(since = "1.5.0", reason = "renamed to swap_remove_back")]
- pub fn swap_back_remove(&mut self, index: usize) -> Option<T> {
- self.swap_remove_back(index)
- }
-
/// Removes an element from anywhere in the `VecDeque` and returns it,
/// replacing it with the first element.
///
self.pop_front()
}
- /// deprecated
- #[unstable(feature = "deque_extras",
- reason = "the naming of this function may be altered",
- issue = "27788")]
- #[rustc_deprecated(since = "1.5.0", reason = "renamed to swap_remove_front")]
- pub fn swap_front_remove(&mut self, index: usize) -> Option<T> {
- self.swap_remove_front(index)
- }
-
/// Inserts an element at `index` within the `VecDeque`. Whichever
/// end is closer to the insertion point will be moved to make room,
/// and all the affected elements will be moved to new positions.
tester.push_front(i);
}
for i in 0..len {
- assert_eq!(tester.swap_back_remove(i), Some(len * 2 - 1 - i));
+ assert_eq!(tester.swap_remove_back(i), Some(len * 2 - 1 - i));
}
} else {
for i in 0..len * 2 {
}
for i in 0..len {
let idx = tester.len() - 1 - i;
- assert_eq!(tester.swap_front_remove(idx), Some(len * 2 - 1 - i));
+ assert_eq!(tester.swap_remove_front(idx), Some(len * 2 - 1 - i));
}
}
assert!(tester.tail < tester.cap());
fn test_iterator() {
let data = vec![5, 9, 3];
let iterout = [9, 5, 3];
- let heap = BinaryHeap::from_vec(data);
+ let heap = BinaryHeap::from(data);
let mut i = 0;
for el in &heap {
assert_eq!(*el, iterout[i]);
fn test_iterator_reverse() {
let data = vec![5, 9, 3];
let iterout = vec![3, 5, 9];
- let pq = BinaryHeap::from_vec(data);
+ let pq = BinaryHeap::from(data);
let v: Vec<_> = pq.iter().rev().cloned().collect();
assert_eq!(v, iterout);
fn test_move_iter() {
let data = vec![5, 9, 3];
let iterout = vec![9, 5, 3];
- let pq = BinaryHeap::from_vec(data);
+ let pq = BinaryHeap::from(data);
let v: Vec<_> = pq.into_iter().collect();
assert_eq!(v, iterout);
#[test]
fn test_move_iter_size_hint() {
let data = vec![5, 9];
- let pq = BinaryHeap::from_vec(data);
+ let pq = BinaryHeap::from(data);
let mut it = pq.into_iter();
fn test_move_iter_reverse() {
let data = vec![5, 9, 3];
let iterout = vec![3, 5, 9];
- let pq = BinaryHeap::from_vec(data);
+ let pq = BinaryHeap::from(data);
let v: Vec<_> = pq.into_iter().rev().collect();
assert_eq!(v, iterout);
let data = vec![2, 4, 6, 2, 1, 8, 10, 3, 5, 7, 0, 9, 1];
let mut sorted = data.clone();
sorted.sort();
- let mut heap = BinaryHeap::from_vec(data);
+ let mut heap = BinaryHeap::from(data);
while !heap.is_empty() {
assert_eq!(heap.peek().unwrap(), sorted.last().unwrap());
assert_eq!(heap.pop().unwrap(), sorted.pop().unwrap());
#[test]
fn test_push() {
- let mut heap = BinaryHeap::from_vec(vec![2, 4, 9]);
+ let mut heap = BinaryHeap::from(vec![2, 4, 9]);
assert_eq!(heap.len(), 3);
assert!(*heap.peek().unwrap() == 9);
heap.push(11);
#[test]
fn test_push_unique() {
- let mut heap = BinaryHeap::<Box<_>>::from_vec(vec![box 2, box 4, box 9]);
+ let mut heap = BinaryHeap::<Box<_>>::from(vec![box 2, box 4, box 9]);
assert_eq!(heap.len(), 3);
assert!(*heap.peek().unwrap() == box 9);
heap.push(box 11);
#[test]
fn test_push_pop() {
- let mut heap = BinaryHeap::from_vec(vec![5, 5, 2, 1, 3]);
+ let mut heap = BinaryHeap::from(vec![5, 5, 2, 1, 3]);
assert_eq!(heap.len(), 5);
assert_eq!(heap.push_pop(6), 6);
assert_eq!(heap.len(), 5);
#[test]
fn test_replace() {
- let mut heap = BinaryHeap::from_vec(vec![5, 5, 2, 1, 3]);
+ let mut heap = BinaryHeap::from(vec![5, 5, 2, 1, 3]);
assert_eq!(heap.len(), 5);
assert_eq!(heap.replace(6).unwrap(), 5);
assert_eq!(heap.len(), 5);
}
fn check_to_vec(mut data: Vec<i32>) {
- let heap = BinaryHeap::from_vec(data.clone());
+ let heap = BinaryHeap::from(data.clone());
let mut v = heap.clone().into_vec();
v.sort();
data.sort();
use std::collections::BTreeMap;
use std::collections::Bound::{Excluded, Included, Unbounded, self};
use std::collections::btree_map::Entry::{Occupied, Vacant};
-use std::iter::range_inclusive;
use std::rc::Rc;
#[test]
for i in 0..size {
for j in i..size {
let mut kvs = map.range(Included(&i), Included(&j)).map(|(&k, &v)| (k, v));
- let mut pairs = range_inclusive(i, j).map(|i| (i, i));
+ let mut pairs = (i..j+1).map(|i| (i, i));
for (kv, pair) in kvs.by_ref().zip(pairs.by_ref()) {
assert_eq!(kv, pair);
t!(Vec<i32>);
}
-#[test]
-fn test_bytes_set_memory() {
- use std::slice::bytes::MutableByteVector;
-
- let mut values = [1,2,3,4,5];
- values[0..5].set_memory(0xAB);
- assert!(values == [0xAB, 0xAB, 0xAB, 0xAB, 0xAB]);
- values[2..4].set_memory(0xFF);
- assert!(values == [0xAB, 0xAB, 0xFF, 0xFF, 0xAB]);
-}
-
#[test]
#[should_panic]
fn test_overflow_does_not_cause_segfault() {
pub fn once<T>(value: T) -> Once<T> {
Once { inner: Some(value).into_iter() }
}
-
-/// Functions for lexicographical ordering of sequences.
-///
-/// Lexicographical ordering through `<`, `<=`, `>=`, `>` requires
-/// that the elements implement both `PartialEq` and `PartialOrd`.
-///
-/// If two sequences are equal up until the point where one ends,
-/// the shorter sequence compares less.
-#[rustc_deprecated(since = "1.4.0", reason = "use the equivalent methods on `Iterator` instead")]
-#[unstable(feature = "iter_order_deprecated", reason = "needs review and revision",
- issue = "27737")]
-pub mod order {
- use cmp;
- use cmp::{Eq, Ord, PartialOrd, PartialEq};
- use option::Option;
- use super::Iterator;
-
- /// Compare `a` and `b` for equality using `Eq`
- pub fn equals<A, L, R>(a: L, b: R) -> bool where
- A: Eq,
- L: Iterator<Item=A>,
- R: Iterator<Item=A>,
- {
- a.eq(b)
- }
-
- /// Order `a` and `b` lexicographically using `Ord`
- pub fn cmp<A, L, R>(a: L, b: R) -> cmp::Ordering where
- A: Ord,
- L: Iterator<Item=A>,
- R: Iterator<Item=A>,
- {
- a.cmp(b)
- }
-
- /// Order `a` and `b` lexicographically using `PartialOrd`
- pub fn partial_cmp<L: Iterator, R: Iterator>(a: L, b: R) -> Option<cmp::Ordering> where
- L::Item: PartialOrd<R::Item>
- {
- a.partial_cmp(b)
- }
-
- /// Compare `a` and `b` for equality (Using partial equality, `PartialEq`)
- pub fn eq<L: Iterator, R: Iterator>(a: L, b: R) -> bool where
- L::Item: PartialEq<R::Item>,
- {
- a.eq(b)
- }
-
- /// Compares `a` and `b` for nonequality (Using partial equality, `PartialEq`)
- pub fn ne<L: Iterator, R: Iterator>(a: L, b: R) -> bool where
- L::Item: PartialEq<R::Item>,
- {
- a.ne(b)
- }
-
- /// Returns `a` < `b` lexicographically (Using partial order, `PartialOrd`)
- pub fn lt<L: Iterator, R: Iterator>(a: L, b: R) -> bool where
- L::Item: PartialOrd<R::Item>,
- {
- a.lt(b)
- }
-
- /// Returns `a` <= `b` lexicographically (Using partial order, `PartialOrd`)
- pub fn le<L: Iterator, R: Iterator>(a: L, b: R) -> bool where
- L::Item: PartialOrd<R::Item>,
- {
- a.le(b)
- }
-
- /// Returns `a` > `b` lexicographically (Using partial order, `PartialOrd`)
- pub fn gt<L: Iterator, R: Iterator>(a: L, b: R) -> bool where
- L::Item: PartialOrd<R::Item>,
- {
- a.gt(b)
- }
-
- /// Returns `a` >= `b` lexicographically (Using partial order, `PartialOrd`)
- pub fn ge<L: Iterator, R: Iterator>(a: L, b: R) -> bool where
- L::Item: PartialOrd<R::Item>,
- {
- a.ge(b)
- }
-}
pub mod raw;
pub mod result;
-#[cfg(stage0)]
-#[path = "simd_old.rs"]
-pub mod simd;
-#[cfg(not(stage0))]
-pub mod simd;
-
pub mod slice;
pub mod str;
pub mod hash;
#![stable(feature = "rust1", since = "1.0.0")]
-use prelude::v1::*;
-
use intrinsics;
use mem;
-use num::{Float, ParseFloatError};
+use num::Float;
use num::FpCategory as Fp;
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
fn one() -> f32 { 1.0 }
- from_str_radix_float_impl! { f32 }
-
/// Returns `true` if the number is NaN.
#[inline]
fn is_nan(self) -> bool { self != self }
#![stable(feature = "rust1", since = "1.0.0")]
-use prelude::v1::*;
-
use intrinsics;
use mem;
use num::FpCategory as Fp;
-use num::{Float, ParseFloatError};
+use num::Float;
#[stable(feature = "rust1", since = "1.0.0")]
#[allow(missing_docs)]
#[inline]
fn one() -> f64 { 1.0 }
- from_str_radix_float_impl! { f64 }
-
/// Returns `true` if the number is NaN.
#[inline]
fn is_nan(self) -> bool { self != self }
"{} is not approximately equal to {}", *a, *b);
})
}
-
-macro_rules! from_str_radix_float_impl {
- ($T:ty) => {
- fn from_str_radix(src: &str, radix: u32)
- -> Result<$T, ParseFloatError> {
- use num::dec2flt::{pfe_empty, pfe_invalid};
-
- // Special values
- match src {
- "inf" => return Ok(Float::infinity()),
- "-inf" => return Ok(Float::neg_infinity()),
- "NaN" => return Ok(Float::nan()),
- _ => {},
- }
-
- let (is_positive, src) = match src.slice_shift_char() {
- None => return Err(pfe_empty()),
- Some(('-', "")) => return Err(pfe_empty()),
- Some(('-', src)) => (false, src),
- Some((_, _)) => (true, src),
- };
-
- // The significand to accumulate
- let mut sig = if is_positive { 0.0 } else { -0.0 };
- // Necessary to detect overflow
- let mut prev_sig = sig;
- let mut cs = src.chars().enumerate();
- // Exponent prefix and exponent index offset
- let mut exp_info = None::<(char, usize)>;
-
- // Parse the integer part of the significand
- for (i, c) in cs.by_ref() {
- match c.to_digit(radix) {
- Some(digit) => {
- // shift significand one digit left
- sig = sig * (radix as $T);
-
- // add/subtract current digit depending on sign
- if is_positive {
- sig = sig + ((digit as isize) as $T);
- } else {
- sig = sig - ((digit as isize) as $T);
- }
-
- // Detect overflow by comparing to last value, except
- // if we've not seen any non-zero digits.
- if prev_sig != 0.0 {
- if is_positive && sig <= prev_sig
- { return Ok(Float::infinity()); }
- if !is_positive && sig >= prev_sig
- { return Ok(Float::neg_infinity()); }
-
- // Detect overflow by reversing the shift-and-add process
- if is_positive && (prev_sig != (sig - digit as $T) / radix as $T)
- { return Ok(Float::infinity()); }
- if !is_positive && (prev_sig != (sig + digit as $T) / radix as $T)
- { return Ok(Float::neg_infinity()); }
- }
- prev_sig = sig;
- },
- None => match c {
- 'e' | 'E' | 'p' | 'P' => {
- exp_info = Some((c, i + 1));
- break; // start of exponent
- },
- '.' => {
- break; // start of fractional part
- },
- _ => {
- return Err(pfe_invalid())
- },
- },
- }
- }
-
- // If we are not yet at the exponent parse the fractional
- // part of the significand
- if exp_info.is_none() {
- let mut power = 1.0;
- for (i, c) in cs.by_ref() {
- match c.to_digit(radix) {
- Some(digit) => {
- // Decrease power one order of magnitude
- power = power / (radix as $T);
- // add/subtract current digit depending on sign
- sig = if is_positive {
- sig + (digit as $T) * power
- } else {
- sig - (digit as $T) * power
- };
- // Detect overflow by comparing to last value
- if is_positive && sig < prev_sig
- { return Ok(Float::infinity()); }
- if !is_positive && sig > prev_sig
- { return Ok(Float::neg_infinity()); }
- prev_sig = sig;
- },
- None => match c {
- 'e' | 'E' | 'p' | 'P' => {
- exp_info = Some((c, i + 1));
- break; // start of exponent
- },
- _ => {
- return Err(pfe_invalid())
- },
- },
- }
- }
- }
-
- // Parse and calculate the exponent
- let exp = match exp_info {
- Some((c, offset)) => {
- let base = match c {
- 'E' | 'e' if radix == 10 => 10.0,
- 'P' | 'p' if radix == 16 => 2.0,
- _ => return Err(pfe_invalid()),
- };
-
- // Parse the exponent as decimal integer
- let src = &src[offset..];
- let (is_positive, exp) = match src.slice_shift_char() {
- Some(('-', src)) => (false, src.parse::<usize>()),
- Some(('+', src)) => (true, src.parse::<usize>()),
- Some((_, _)) => (true, src.parse::<usize>()),
- None => return Err(pfe_invalid()),
- };
-
- match (is_positive, exp) {
- (true, Ok(exp)) => base.powi(exp as i32),
- (false, Ok(exp)) => 1.0 / base.powi(exp as i32),
- (_, Err(_)) => return Err(pfe_invalid()),
- }
- },
- None => 1.0, // no exponent
- };
-
- Ok(sig * exp)
- }
- }
-}
#[unstable(feature = "float_extras", reason = "needs removal",
issue = "27752")]
fn one() -> Self;
- /// Parses the string `s` with the radix `r` as a float.
- #[unstable(feature = "float_from_str_radix", reason = "recently moved API",
- issue = "27736")]
- #[rustc_deprecated(since = "1.4.0",
- reason = "unclear how useful or correct this is")]
- fn from_str_radix(s: &str, r: u32) -> Result<Self, ParseFloatError>;
/// Returns true if this value is NaN and false otherwise.
#[stable(feature = "core", since = "1.6.0")]
use ops::FnOnce;
use result::Result::{Ok, Err};
use result::Result;
-use slice;
// Note that this is not a lang item per se, but it has a hidden dependency on
// `Iterator`, which is one. The compiler assumes that the `next` method of
}
}
- /// Converts from `Option<T>` to `&mut [T]` (without copying)
- ///
- /// # Examples
- ///
- /// ```
- /// #![feature(as_slice)]
- /// # #![allow(deprecated)]
- ///
- /// let mut x = Some("Diamonds");
- /// {
- /// let v = x.as_mut_slice();
- /// assert!(v == ["Diamonds"]);
- /// v[0] = "Dirt";
- /// assert!(v == ["Dirt"]);
- /// }
- /// assert_eq!(x, Some("Dirt"));
- /// ```
- #[inline]
- #[unstable(feature = "as_slice",
- reason = "waiting for mut conventions",
- issue = "27776")]
- #[rustc_deprecated(since = "1.4.0", reason = "niche API, unclear of usefulness")]
- #[allow(deprecated)]
- pub fn as_mut_slice(&mut self) -> &mut [T] {
- match *self {
- Some(ref mut x) => {
- let result: &mut [T] = slice::mut_ref_slice(x);
- result
- }
- None => {
- let result: &mut [T] = &mut [];
- result
- }
- }
- }
-
/////////////////////////////////////////////////////////////////////////
// Getting to contained values
/////////////////////////////////////////////////////////////////////////
pub fn take(&mut self) -> Option<T> {
mem::replace(self, None)
}
-
- /// Converts from `Option<T>` to `&[T]` (without copying)
- #[inline]
- #[unstable(feature = "as_slice", reason = "unsure of the utility here",
- issue = "27776")]
- #[rustc_deprecated(since = "1.4.0", reason = "niche API, unclear of usefulness")]
- #[allow(deprecated)]
- pub fn as_slice(&self) -> &[T] {
- match *self {
- Some(ref x) => slice::ref_slice(x),
- None => {
- let result: &[_] = &[];
- result
- }
- }
- }
}
impl<'a, T: Clone> Option<&'a T> {
use iter::{Iterator, DoubleEndedIterator, FromIterator, ExactSizeIterator, IntoIterator};
use ops::FnOnce;
use option::Option::{self, None, Some};
-use slice;
/// `Result` is a type that represents either success (`Ok`) or failure (`Err`).
///
}
}
- /// Converts from `Result<T, E>` to `&[T]` (without copying)
- #[inline]
- #[unstable(feature = "as_slice", reason = "unsure of the utility here",
- issue = "27776")]
- #[rustc_deprecated(since = "1.4.0", reason = "niche API, unclear of usefulness")]
- #[allow(deprecated)]
- pub fn as_slice(&self) -> &[T] {
- match *self {
- Ok(ref x) => slice::ref_slice(x),
- Err(_) => {
- // work around lack of implicit coercion from fixed-size array to slice
- let emp: &[_] = &[];
- emp
- }
- }
- }
-
- /// Converts from `Result<T, E>` to `&mut [T]` (without copying)
- ///
- /// ```
- /// #![feature(as_slice)]
- /// # #![allow(deprecated)]
- ///
- /// let mut x: Result<&str, u32> = Ok("Gold");
- /// {
- /// let v = x.as_mut_slice();
- /// assert!(v == ["Gold"]);
- /// v[0] = "Silver";
- /// assert!(v == ["Silver"]);
- /// }
- /// assert_eq!(x, Ok("Silver"));
- ///
- /// let mut x: Result<&str, u32> = Err(45);
- /// assert!(x.as_mut_slice().is_empty());
- /// ```
- #[inline]
- #[unstable(feature = "as_slice",
- reason = "waiting for mut conventions",
- issue = "27776")]
- #[rustc_deprecated(since = "1.4.0", reason = "niche API, unclear of usefulness")]
- #[allow(deprecated)]
- pub fn as_mut_slice(&mut self) -> &mut [T] {
- match *self {
- Ok(ref mut x) => slice::mut_ref_slice(x),
- Err(_) => {
- // work around lack of implicit coercion from fixed-size array to slice
- let emp: &mut [_] = &mut [];
- emp
- }
- }
- }
-
/////////////////////////////////////////////////////////////////////////
// Transforming contained values
/////////////////////////////////////////////////////////////////////////
+++ /dev/null
-// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-//! SIMD vectors.
-//!
-//! These types can be used for accessing basic SIMD operations. Currently
-//! comparison operators are not implemented. To use SSE3+, you must enable
-//! the features, like `-C target-feature=sse3,sse4.1,sse4.2`, or a more
-//! specific `target-cpu`. No other SIMD intrinsics or high-level wrappers are
-//! provided beyond this module.
-//!
-//! # Stability Note
-//!
-//! These are all experimental. The interface may change entirely, without
-//! warning.
-
-#![unstable(feature = "core_simd",
- reason = "needs an RFC to flesh out the design",
- issue = "27731")]
-#![rustc_deprecated(since = "1.3.0",
- reason = "use the external `simd` crate instead")]
-
-#![allow(non_camel_case_types)]
-#![allow(missing_docs)]
-#![allow(deprecated)]
-
-use ops::{Add, Sub, Mul, Div, Shl, Shr, BitAnd, BitOr, BitXor};
-
-// FIXME(stage0): the contents of macro can be inlined.
-// ABIs are verified as valid as soon as they are parsed, i.e. before
-// `cfg` stripping. The `platform-intrinsic` ABI is new, so stage0
-// doesn't know about it, but it still errors out when it hits it
-// (despite this being in a `cfg(not(stage0))` module).
-macro_rules! argh {
- () => {
- extern "platform-intrinsic" {
- fn simd_add<T>(x: T, y: T) -> T;
- fn simd_sub<T>(x: T, y: T) -> T;
- fn simd_mul<T>(x: T, y: T) -> T;
- fn simd_div<T>(x: T, y: T) -> T;
- fn simd_shl<T>(x: T, y: T) -> T;
- fn simd_shr<T>(x: T, y: T) -> T;
- fn simd_and<T>(x: T, y: T) -> T;
- fn simd_or<T>(x: T, y: T) -> T;
- fn simd_xor<T>(x: T, y: T) -> T;
- }
- }
-}
-argh!();
-
-#[repr(simd)]
-#[derive(Copy, Clone, Debug)]
-#[repr(C)]
-pub struct i8x16(pub i8, pub i8, pub i8, pub i8,
- pub i8, pub i8, pub i8, pub i8,
- pub i8, pub i8, pub i8, pub i8,
- pub i8, pub i8, pub i8, pub i8);
-
-#[repr(simd)]
-#[derive(Copy, Clone, Debug)]
-#[repr(C)]
-pub struct i16x8(pub i16, pub i16, pub i16, pub i16,
- pub i16, pub i16, pub i16, pub i16);
-
-#[repr(simd)]
-#[derive(Copy, Clone, Debug)]
-#[repr(C)]
-pub struct i32x4(pub i32, pub i32, pub i32, pub i32);
-
-#[repr(simd)]
-#[derive(Copy, Clone, Debug)]
-#[repr(C)]
-pub struct i64x2(pub i64, pub i64);
-
-#[repr(simd)]
-#[derive(Copy, Clone, Debug)]
-#[repr(C)]
-pub struct u8x16(pub u8, pub u8, pub u8, pub u8,
- pub u8, pub u8, pub u8, pub u8,
- pub u8, pub u8, pub u8, pub u8,
- pub u8, pub u8, pub u8, pub u8);
-
-#[repr(simd)]
-#[derive(Copy, Clone, Debug)]
-#[repr(C)]
-pub struct u16x8(pub u16, pub u16, pub u16, pub u16,
- pub u16, pub u16, pub u16, pub u16);
-
-#[repr(simd)]
-#[derive(Copy, Clone, Debug)]
-#[repr(C)]
-pub struct u32x4(pub u32, pub u32, pub u32, pub u32);
-
-#[repr(simd)]
-#[derive(Copy, Clone, Debug)]
-#[repr(C)]
-pub struct u64x2(pub u64, pub u64);
-
-#[repr(simd)]
-#[derive(Copy, Clone, Debug)]
-#[repr(C)]
-pub struct f32x4(pub f32, pub f32, pub f32, pub f32);
-
-#[repr(simd)]
-#[derive(Copy, Clone, Debug)]
-#[repr(C)]
-pub struct f64x2(pub f64, pub f64);
-
-macro_rules! impl_traits {
- ($($trayt: ident, $method: ident, $func: ident: $($ty: ty),*;)*) => {
- $($(
- impl $trayt<$ty> for $ty {
- type Output = Self;
- fn $method(self, other: Self) -> Self {
- unsafe {
- $func(self, other)
- }
- }
- }
- )*)*
- }
-}
-
-impl_traits! {
- Add, add, simd_add: u8x16, u16x8, u32x4, u64x2, i8x16, i16x8, i32x4, i64x2, f32x4, f64x2;
- Sub, sub, simd_sub: u8x16, u16x8, u32x4, u64x2, i8x16, i16x8, i32x4, i64x2, f32x4, f64x2;
- Mul, mul, simd_mul: u8x16, u16x8, u32x4, u64x2, i8x16, i16x8, i32x4, i64x2, f32x4, f64x2;
-
- Div, div, simd_div: f32x4, f64x2;
-
- Shl, shl, simd_shl: u8x16, u16x8, u32x4, u64x2, i8x16, i16x8, i32x4, i64x2;
- Shr, shr, simd_shr: u8x16, u16x8, u32x4, u64x2, i8x16, i16x8, i32x4, i64x2;
- BitAnd, bitand, simd_and: u8x16, u16x8, u32x4, u64x2, i8x16, i16x8, i32x4, i64x2;
- BitOr, bitor, simd_or: u8x16, u16x8, u32x4, u64x2, i8x16, i16x8, i32x4, i64x2;
- BitXor, bitxor, simd_xor: u8x16, u16x8, u32x4, u64x2, i8x16, i16x8, i32x4, i64x2;
-}
+++ /dev/null
-// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-//! SIMD vectors.
-//!
-//! These types can be used for accessing basic SIMD operations. Each of them
-//! implements the standard arithmetic operator traits (Add, Sub, Mul, Div,
-//! Rem, Shl, Shr) through compiler magic, rather than explicitly. Currently
-//! comparison operators are not implemented. To use SSE3+, you must enable
-//! the features, like `-C target-feature=sse3,sse4.1,sse4.2`, or a more
-//! specific `target-cpu`. No other SIMD intrinsics or high-level wrappers are
-//! provided beyond this module.
-//!
-//! ```rust
-//! # #![feature(core_simd)]
-//! fn main() {
-//! use std::simd::f32x4;
-//! let a = f32x4(40.0, 41.0, 42.0, 43.0);
-//! let b = f32x4(1.0, 1.1, 3.4, 9.8);
-//! println!("{:?}", a + b);
-//! }
-//! ```
-//!
-//! # Stability Note
-//!
-//! These are all experimental. The interface may change entirely, without
-//! warning.
-
-#![unstable(feature = "core_simd",
- reason = "needs an RFC to flesh out the design")]
-
-#![allow(non_camel_case_types)]
-#![allow(missing_docs)]
-
-#[simd]
-#[derive(Copy, Clone, Debug)]
-#[repr(C)]
-pub struct i8x16(pub i8, pub i8, pub i8, pub i8,
- pub i8, pub i8, pub i8, pub i8,
- pub i8, pub i8, pub i8, pub i8,
- pub i8, pub i8, pub i8, pub i8);
-
-#[simd]
-#[derive(Copy, Clone, Debug)]
-#[repr(C)]
-pub struct i16x8(pub i16, pub i16, pub i16, pub i16,
- pub i16, pub i16, pub i16, pub i16);
-
-#[simd]
-#[derive(Copy, Clone, Debug)]
-#[repr(C)]
-pub struct i32x4(pub i32, pub i32, pub i32, pub i32);
-
-#[simd]
-#[derive(Copy, Clone, Debug)]
-#[repr(C)]
-pub struct i64x2(pub i64, pub i64);
-
-#[simd]
-#[derive(Copy, Clone, Debug)]
-#[repr(C)]
-pub struct u8x16(pub u8, pub u8, pub u8, pub u8,
- pub u8, pub u8, pub u8, pub u8,
- pub u8, pub u8, pub u8, pub u8,
- pub u8, pub u8, pub u8, pub u8);
-
-#[simd]
-#[derive(Copy, Clone, Debug)]
-#[repr(C)]
-pub struct u16x8(pub u16, pub u16, pub u16, pub u16,
- pub u16, pub u16, pub u16, pub u16);
-
-#[simd]
-#[derive(Copy, Clone, Debug)]
-#[repr(C)]
-pub struct u32x4(pub u32, pub u32, pub u32, pub u32);
-
-#[simd]
-#[derive(Copy, Clone, Debug)]
-#[repr(C)]
-pub struct u64x2(pub u64, pub u64);
-
-#[simd]
-#[derive(Copy, Clone, Debug)]
-#[repr(C)]
-pub struct f32x4(pub f32, pub f32, pub f32, pub f32);
-
-#[simd]
-#[derive(Copy, Clone, Debug)]
-#[repr(C)]
-pub struct f64x2(pub f64, pub f64);
// Free functions
//
-/// Converts a reference to A into a slice of length 1 (without copying).
-#[unstable(feature = "ref_slice", issue = "27774")]
-#[rustc_deprecated(since = "1.5.0", reason = "unclear whether belongs in libstd")]
-pub fn ref_slice<A>(s: &A) -> &[A] {
- unsafe {
- from_raw_parts(s, 1)
- }
-}
-
-/// Converts a reference to A into a slice of length 1 (without copying).
-#[unstable(feature = "ref_slice", issue = "27774")]
-#[rustc_deprecated(since = "1.5.0", reason = "unclear whether belongs in libstd")]
-pub fn mut_ref_slice<A>(s: &mut A) -> &mut [A] {
- unsafe {
- from_raw_parts_mut(s, 1)
- }
-}
-
/// Forms a slice from a pointer and a length.
///
/// The `len` argument is the number of **elements**, not the number of bytes.
(isize::MAX as usize + 2, Some(isize::MAX as usize + 2)));
}
-#[test]
-fn test_range_inclusive() {
- assert!(range_inclusive(0, 5).collect::<Vec<isize>>() ==
- vec![0, 1, 2, 3, 4, 5]);
- assert!(range_inclusive(0, 5).rev().collect::<Vec<isize>>() ==
- vec![5, 4, 3, 2, 1, 0]);
- assert_eq!(range_inclusive(200, -5).count(), 0);
- assert_eq!(range_inclusive(200, -5).rev().count(), 0);
- assert_eq!(range_inclusive(200, 200).collect::<Vec<isize>>(), [200]);
- assert_eq!(range_inclusive(200, 200).rev().collect::<Vec<isize>>(), [200]);
-}
-
#[test]
fn test_range_step() {
assert_eq!((0..20).step_by(5).collect::<Vec<isize>>(), [0, 5, 10, 15]);
#![feature(unboxed_closures)]
#![feature(unicode)]
#![feature(unique)]
+#![feature(clone_from_slice)]
extern crate core;
extern crate test;
use std::prelude::v1::*;
use std::{str, mem, i16, f32, f64, fmt};
-use std::slice::bytes;
use std::__rand as rand;
use rand::{Rand, XorShiftRng};
use rand::distributions::{IndependentSample, Range};
// check significant digits
for i in 1..cut.unwrap_or(expected.len() - 1) {
- bytes::copy_memory(&expected[..i], &mut expected_);
+ expected_.clone_from_slice(&expected[..i]);
let mut expectedk_ = expectedk;
if expected[i] >= b'5' {
// check if this is a rounding-to-even case.
// check infinite zero digits
if let Some(cut) = cut {
for i in cut..expected.len()-1 {
- bytes::copy_memory(&expected[..cut], &mut expected_);
+ expected_.clone_from_slice(&expected[..cut]);
for c in &mut expected_[cut..i] { *c = b'0'; }
try_exact!(f(&decoded) => &mut buf, &expected_[..i], expectedk;
use core::option::Option::{Some, None};
use core::num::Float;
- #[test]
- fn from_str_issue7588() {
- let u : Option<u8> = u8::from_str_radix("1000", 10).ok();
- assert_eq!(u, None);
- let s : Option<i16> = i16::from_str_radix("80000", 10).ok();
- assert_eq!(s, None);
- let s = "10000000000000000000000000000000000000000";
- let f : Option<f32> = f32::from_str_radix(s, 10).ok();
- assert_eq!(f, Some(Float::infinity()));
- let fe : Option<f32> = f32::from_str_radix("1e40", 10).ok();
- assert_eq!(fe, Some(Float::infinity()));
- }
-
- #[test]
- fn test_from_str_radix_float() {
- let x1 : Option<f64> = f64::from_str_radix("-123.456", 10).ok();
- assert_eq!(x1, Some(-123.456));
- let x2 : Option<f32> = f32::from_str_radix("123.456", 10).ok();
- assert_eq!(x2, Some(123.456));
- let x3 : Option<f32> = f32::from_str_radix("-0.0", 10).ok();
- assert_eq!(x3, Some(-0.0));
- let x4 : Option<f32> = f32::from_str_radix("0.0", 10).ok();
- assert_eq!(x4, Some(0.0));
- let x4 : Option<f32> = f32::from_str_radix("1.0", 10).ok();
- assert_eq!(x4, Some(1.0));
- let x5 : Option<f32> = f32::from_str_radix("-1.0", 10).ok();
- assert_eq!(x5, Some(-1.0));
- }
-
#[test]
fn test_int_from_str_overflow() {
let mut i8_val: i8 = 127;
mod tests {
use std::prelude::v1::*;
- use core::iter::order;
use {Rng, SeedableRng};
use super::ChaChaRng;
let s = ::test::rng().gen_iter::<u32>().take(8).collect::<Vec<u32>>();
let mut ra: ChaChaRng = SeedableRng::from_seed(&*s);
let mut rb: ChaChaRng = SeedableRng::from_seed(&*s);
- assert!(order::equals(ra.gen_ascii_chars().take(100),
- rb.gen_ascii_chars().take(100)));
+ assert!(ra.gen_ascii_chars().take(100)
+ .eq(rb.gen_ascii_chars().take(100)));
}
#[test]
let seed: &[_] = &[0, 1, 2, 3, 4, 5, 6, 7];
let mut ra: ChaChaRng = SeedableRng::from_seed(seed);
let mut rb: ChaChaRng = SeedableRng::from_seed(seed);
- assert!(order::equals(ra.gen_ascii_chars().take(100),
- rb.gen_ascii_chars().take(100)));
+ assert!(ra.gen_ascii_chars().take(100)
+ .eq(rb.gen_ascii_chars().take(100)));
}
#[test]
mod tests {
use std::prelude::v1::*;
- use core::iter::order;
use {Rng, SeedableRng};
use super::{IsaacRng, Isaac64Rng};
let s = ::test::rng().gen_iter::<u32>().take(256).collect::<Vec<u32>>();
let mut ra: IsaacRng = SeedableRng::from_seed(&s[..]);
let mut rb: IsaacRng = SeedableRng::from_seed(&s[..]);
- assert!(order::equals(ra.gen_ascii_chars().take(100),
- rb.gen_ascii_chars().take(100)));
+ assert!(ra.gen_ascii_chars().take(100)
+ .eq(rb.gen_ascii_chars().take(100)));
}
#[test]
fn test_rng_64_rand_seeded() {
let s = ::test::rng().gen_iter::<u64>().take(256).collect::<Vec<u64>>();
let mut ra: Isaac64Rng = SeedableRng::from_seed(&s[..]);
let mut rb: Isaac64Rng = SeedableRng::from_seed(&s[..]);
- assert!(order::equals(ra.gen_ascii_chars().take(100),
- rb.gen_ascii_chars().take(100)));
+ assert!(ra.gen_ascii_chars().take(100)
+ .eq(rb.gen_ascii_chars().take(100)));
}
#[test]
let seed: &[_] = &[1, 23, 456, 7890, 12345];
let mut ra: IsaacRng = SeedableRng::from_seed(seed);
let mut rb: IsaacRng = SeedableRng::from_seed(seed);
- assert!(order::equals(ra.gen_ascii_chars().take(100),
- rb.gen_ascii_chars().take(100)));
+ assert!(ra.gen_ascii_chars().take(100)
+ .eq(rb.gen_ascii_chars().take(100)));
}
#[test]
fn test_rng_64_seeded() {
let seed: &[_] = &[1, 23, 456, 7890, 12345];
let mut ra: Isaac64Rng = SeedableRng::from_seed(seed);
let mut rb: Isaac64Rng = SeedableRng::from_seed(seed);
- assert!(order::equals(ra.gen_ascii_chars().take(100),
- rb.gen_ascii_chars().take(100)));
+ assert!(ra.gen_ascii_chars().take(100)
+ .eq(rb.gen_ascii_chars().take(100)));
}
#[test]
mod tests {
use std::prelude::v1::*;
- use core::iter::order;
use super::{ReseedingRng, ReseedWithDefault};
use {SeedableRng, Rng};
fn test_rng_seeded() {
let mut ra: MyRng = SeedableRng::from_seed((ReseedWithDefault, 2));
let mut rb: MyRng = SeedableRng::from_seed((ReseedWithDefault, 2));
- assert!(order::equals(ra.gen_ascii_chars().take(100),
- rb.gen_ascii_chars().take(100)));
+ assert!(ra.gen_ascii_chars().take(100)
+ .eq(rb.gen_ascii_chars().take(100)));
}
#[test]
#[allow(deprecated)]
pub mod str {
pub use u_str::{UnicodeStr, SplitWhitespace};
- pub use u_str::{utf8_char_width, is_utf16, Utf16Items, Utf16Item};
- pub use u_str::{utf16_items, Utf16Encoder};
+ pub use u_str::{utf8_char_width, is_utf16};
+ pub use u_str::{Utf16Encoder};
}
// For use in libcollections, not re-exported in libstd.
//! This module provides functionality to `str` that requires the Unicode
//! methods provided by the unicode parts of the CharExt trait.
-use char::{DecodeUtf16, decode_utf16};
use core::char;
-use core::iter::{Cloned, Filter};
-use core::slice;
+use core::iter::Filter;
use core::str::Split;
/// An iterator over the non-whitespace substrings of a string,
}
}
-/// An iterator that decodes UTF-16 encoded codepoints from a vector
-/// of `u16`s.
-#[rustc_deprecated(since = "1.4.0", reason = "renamed to `char::DecodeUtf16`")]
-#[unstable(feature = "decode_utf16", reason = "not exposed in std", issue = "27830")]
-#[allow(deprecated)]
-#[derive(Clone)]
-pub struct Utf16Items<'a> {
- decoder: DecodeUtf16<Cloned<slice::Iter<'a, u16>>>,
-}
-
-/// The possibilities for values decoded from a `u16` stream.
-#[rustc_deprecated(since = "1.4.0",
- reason = "`char::DecodeUtf16` uses `Result<char, u16>` instead")]
-#[unstable(feature = "decode_utf16", reason = "not exposed in std", issue = "27830")]
-#[allow(deprecated)]
-#[derive(Copy, PartialEq, Eq, Clone, Debug)]
-pub enum Utf16Item {
- /// A valid codepoint.
- ScalarValue(char),
- /// An invalid surrogate without its pair.
- LoneSurrogate(u16),
-}
-
-#[allow(deprecated)]
-impl Utf16Item {
- /// Convert `self` to a `char`, taking `LoneSurrogate`s to the
- /// replacement character (U+FFFD).
- #[inline]
- pub fn to_char_lossy(&self) -> char {
- match *self {
- Utf16Item::ScalarValue(c) => c,
- Utf16Item::LoneSurrogate(_) => '\u{FFFD}',
- }
- }
-}
-
-#[rustc_deprecated(since = "1.4.0", reason = "use `char::DecodeUtf16` instead")]
-#[unstable(feature = "decode_utf16", reason = "not exposed in std", issue = "27830")]
-#[allow(deprecated)]
-impl<'a> Iterator for Utf16Items<'a> {
- type Item = Utf16Item;
-
- fn next(&mut self) -> Option<Utf16Item> {
- self.decoder.next().map(|result| {
- match result {
- Ok(c) => Utf16Item::ScalarValue(c),
- Err(s) => Utf16Item::LoneSurrogate(s),
- }
- })
- }
-
- #[inline]
- fn size_hint(&self) -> (usize, Option<usize>) {
- self.decoder.size_hint()
- }
-}
-
-/// Create an iterator over the UTF-16 encoded codepoints in `v`,
-/// returning invalid surrogates as `LoneSurrogate`s.
-///
-/// # Examples
-///
-/// ```
-/// #![feature(unicode, decode_utf16)]
-/// # #![allow(deprecated)]
-///
-/// extern crate rustc_unicode;
-///
-/// use rustc_unicode::str::Utf16Item::{ScalarValue, LoneSurrogate};
-///
-/// fn main() {
-/// // 𝄞mus<invalid>ic<invalid>
-/// let v = [0xD834, 0xDD1E, 0x006d, 0x0075,
-/// 0x0073, 0xDD1E, 0x0069, 0x0063,
-/// 0xD834];
-///
-/// assert_eq!(rustc_unicode::str::utf16_items(&v).collect::<Vec<_>>(),
-/// vec![ScalarValue('𝄞'),
-/// ScalarValue('m'), ScalarValue('u'), ScalarValue('s'),
-/// LoneSurrogate(0xDD1E),
-/// ScalarValue('i'), ScalarValue('c'),
-/// LoneSurrogate(0xD834)]);
-/// }
-/// ```
-#[rustc_deprecated(since = "1.4.0", reason = "renamed to `char::decode_utf16`")]
-#[unstable(feature = "decode_utf16", reason = "not exposed in std", issue = "27830")]
-#[allow(deprecated)]
-pub fn utf16_items<'a>(v: &'a [u16]) -> Utf16Items<'a> {
- Utf16Items { decoder: decode_utf16(v.iter().cloned()) }
-}
-
/// Iterator adaptor for encoding `char`s to UTF-16.
#[derive(Clone)]
pub struct Utf16Encoder<I> {
use prelude::v1::*;
use self::test::Bencher;
-use iter::range_inclusive;
#[bench]
fn new_drop(b : &mut Bencher) {
let mut m = HashMap::new();
- for i in range_inclusive(1, 1000) {
+ for i in 1..1001 {
m.insert(i, i);
}
let mut m = HashMap::new();
- for i in range_inclusive(1, 1000) {
+ for i in 1..1001 {
m.insert(i, i);
}
b.iter(|| {
- for i in range_inclusive(1, 1000) {
+ for i in 1..1001 {
m.contains_key(&i);
}
});
let mut m = HashMap::new();
- for i in range_inclusive(1, 1000) {
+ for i in 1..1001 {
m.insert(i, i);
}
b.iter(|| {
- for i in range_inclusive(1001, 2000) {
+ for i in 1001..2001 {
m.contains_key(&i);
}
});
let mut m = HashMap::new();
- for i in range_inclusive(1, 1000) {
+ for i in 1..1001 {
m.insert(i, i);
}
let mut m = HashMap::new();
- for i in range_inclusive(1, 1000) {
+ for i in 1..1001 {
m.insert(i, i);
}
use super::HashMap;
use super::Entry::{Occupied, Vacant};
- use iter::range_inclusive;
use cell::RefCell;
use rand::{thread_rng, Rng};
for _ in 0..10 {
assert!(m.is_empty());
- for i in range_inclusive(1, 1000) {
+ for i in 1..1001 {
assert!(m.insert(i, i).is_none());
- for j in range_inclusive(1, i) {
+ for j in 1..i+1 {
let r = m.get(&j);
assert_eq!(r, Some(&j));
}
- for j in range_inclusive(i+1, 1000) {
+ for j in i+1..1001 {
let r = m.get(&j);
assert_eq!(r, None);
}
}
- for i in range_inclusive(1001, 2000) {
+ for i in 1001..2001 {
assert!(!m.contains_key(&i));
}
// remove forwards
- for i in range_inclusive(1, 1000) {
+ for i in 1..1001 {
assert!(m.remove(&i).is_some());
- for j in range_inclusive(1, i) {
+ for j in 1..i+1 {
assert!(!m.contains_key(&j));
}
- for j in range_inclusive(i+1, 1000) {
+ for j in i+1..1001 {
assert!(m.contains_key(&j));
}
}
- for i in range_inclusive(1, 1000) {
+ for i in 1..1001 {
assert!(!m.contains_key(&i));
}
- for i in range_inclusive(1, 1000) {
+ for i in 1..1001 {
assert!(m.insert(i, i).is_none());
}
for i in (1..1001).rev() {
assert!(m.remove(&i).is_some());
- for j in range_inclusive(i, 1000) {
+ for j in i..1001 {
assert!(!m.contains_key(&j));
}
- for j in range_inclusive(1, i-1) {
+ for j in 1..i {
assert!(m.contains_key(&j));
}
}
CString { inner: v.into_boxed_slice() }
}
- /// Retakes ownership of a CString that was transferred to C.
- ///
- /// The only appropriate argument is a pointer obtained by calling
- /// `into_raw`. The length of the string will be recalculated
- /// using the pointer.
- #[unstable(feature = "cstr_memory2", reason = "recently added",
- issue = "27769")]
- #[rustc_deprecated(since = "1.4.0", reason = "renamed to from_raw")]
- pub unsafe fn from_ptr(ptr: *const c_char) -> CString {
- CString::from_raw(ptr as *mut _)
- }
-
/// Retakes ownership of a CString that was transferred to C.
///
/// The only appropriate argument is a pointer obtained by calling
CString { inner: mem::transmute(slice) }
}
- /// Transfers ownership of the string to a C caller.
- ///
- /// The pointer must be returned to Rust and reconstituted using
- /// `from_raw` to be properly deallocated. Specifically, one
- /// should *not* use the standard C `free` function to deallocate
- /// this string.
- ///
- /// Failure to call `from_raw` will lead to a memory leak.
- #[unstable(feature = "cstr_memory2", reason = "recently added",
- issue = "27769")]
- #[rustc_deprecated(since = "1.4.0", reason = "renamed to into_raw")]
- pub fn into_ptr(self) -> *const c_char {
- self.into_raw() as *const _
- }
-
/// Transfers ownership of the string to a C caller.
///
/// The pointer must be returned to Rust and reconstituted using
}
}
-/// Utility methods for paths.
-#[unstable(feature = "path_ext_deprecated",
- reason = "The precise set of methods exposed on this trait may \
- change and some methods may be removed. For stable code, \
- see the std::fs::metadata function.",
- issue = "27725")]
-#[rustc_deprecated(since = "1.5.0", reason = "replaced with inherent methods")]
-pub trait PathExt {
- /// Gets information on the file, directory, etc at this path.
- ///
- /// Consult the `fs::metadata` documentation for more info.
- ///
- /// This call preserves identical runtime/error semantics with
- /// `fs::metadata`.
- fn metadata(&self) -> io::Result<Metadata>;
-
- /// Gets information on the file, directory, etc at this path.
- ///
- /// Consult the `fs::symlink_metadata` documentation for more info.
- ///
- /// This call preserves identical runtime/error semantics with
- /// `fs::symlink_metadata`.
- fn symlink_metadata(&self) -> io::Result<Metadata>;
-
- /// Returns the canonical form of a path, normalizing all components and
- /// eliminate all symlinks.
- ///
- /// This call preserves identical runtime/error semantics with
- /// `fs::canonicalize`.
- fn canonicalize(&self) -> io::Result<PathBuf>;
-
- /// Reads the symlink at this path.
- ///
- /// For more information see `fs::read_link`.
- fn read_link(&self) -> io::Result<PathBuf>;
-
- /// Reads the directory at this path.
- ///
- /// For more information see `fs::read_dir`.
- fn read_dir(&self) -> io::Result<ReadDir>;
-
- /// Boolean value indicator whether the underlying file exists on the local
- /// filesystem. Returns false in exactly the cases where `fs::metadata`
- /// fails.
- fn exists(&self) -> bool;
-
- /// Whether the underlying implementation (be it a file path, or something
- /// else) points at a "regular file" on the FS. Will return false for paths
- /// to non-existent locations or directories or other non-regular files
- /// (named pipes, etc). Follows links when making this determination.
- fn is_file(&self) -> bool;
-
- /// Whether the underlying implementation (be it a file path, or something
- /// else) is pointing at a directory in the underlying FS. Will return
- /// false for paths to non-existent locations or if the item is not a
- /// directory (eg files, named pipes, etc). Follows links when making this
- /// determination.
- fn is_dir(&self) -> bool;
-}
-
-#[allow(deprecated)]
-#[unstable(feature = "path_ext_deprecated", issue = "27725")]
-impl PathExt for Path {
- fn metadata(&self) -> io::Result<Metadata> { metadata(self) }
- fn symlink_metadata(&self) -> io::Result<Metadata> { symlink_metadata(self) }
- fn canonicalize(&self) -> io::Result<PathBuf> { canonicalize(self) }
- fn read_link(&self) -> io::Result<PathBuf> { read_link(self) }
- fn read_dir(&self) -> io::Result<ReadDir> { read_dir(self) }
- fn exists(&self) -> bool { metadata(self).is_ok() }
-
- fn is_file(&self) -> bool {
- metadata(self).map(|s| s.is_file()).unwrap_or(false)
- }
-
- fn is_dir(&self) -> bool {
- metadata(self).map(|s| s.is_dir()).unwrap_or(false)
- }
-}
-
/// Changes the permissions found on a file or a directory.
///
/// # Examples
#[stable(feature = "rust1", since = "1.0.0")]
pub use super::{Read, Write, BufRead, Seek};
-#[allow(deprecated)]
-#[unstable(feature = "path_ext_deprecated", issue = "27725")]
-pub use fs::PathExt;
#![feature(const_fn)]
#![feature(core_float)]
#![feature(core_intrinsics)]
-#![feature(core_simd)]
#![feature(decode_utf16)]
#![feature(drop_in_place)]
#![feature(dropck_parametricity)]
#![feature(rand)]
#![feature(range_inclusive)]
#![feature(raw)]
+#![feature(repr_simd)]
#![feature(reflect_marker)]
#![feature(shared)]
#![feature(slice_bytes)]
#[stable(feature = "rust1", since = "1.0.0")]
pub use core::raw;
#[stable(feature = "rust1", since = "1.0.0")]
-#[allow(deprecated)]
-pub use core::simd;
-#[stable(feature = "rust1", since = "1.0.0")]
pub use core::result;
#[stable(feature = "rust1", since = "1.0.0")]
pub use core::option;
use core::num;
use intrinsics;
use libc::c_int;
-use num::{FpCategory, ParseFloatError};
+use num::FpCategory;
#[stable(feature = "rust1", since = "1.0.0")]
pub use core::f32::{RADIX, MANTISSA_DIGITS, DIGITS, EPSILON};
#[cfg(not(test))]
#[lang = "f32"]
impl f32 {
- /// Parses a float as with a given radix
- #[unstable(feature = "float_from_str_radix", reason = "recently moved API",
- issue = "27736")]
- #[rustc_deprecated(since = "1.4.0",
- reason = "unclear how useful or correct this is")]
- #[allow(deprecated)]
- pub fn from_str_radix(s: &str, radix: u32) -> Result<f32, ParseFloatError> {
- num::Float::from_str_radix(s, radix)
- }
-
/// Returns `true` if this value is `NaN` and false otherwise.
///
/// ```
#[test]
fn test_ldexp() {
- // We have to use from_str until base-2 exponents
- // are supported in floating-point literals
- let f1: f32 = f32::from_str_radix("1p-123", 16).unwrap();
- let f2: f32 = f32::from_str_radix("1p-111", 16).unwrap();
- let f3: f32 = f32::from_str_radix("1.Cp-12", 16).unwrap();
+ let f1 = 2.0f32.powi(-123);
+ let f2 = 2.0f32.powi(-111);
+ let f3 = 1.75 * 2.0f32.powi(-12);
assert_eq!(f32::ldexp(1f32, -123), f1);
assert_eq!(f32::ldexp(1f32, -111), f2);
assert_eq!(f32::ldexp(1.75f32, -12), f3);
#[test]
fn test_frexp() {
- // We have to use from_str until base-2 exponents
- // are supported in floating-point literals
- let f1: f32 = f32::from_str_radix("1p-123", 16).unwrap();
- let f2: f32 = f32::from_str_radix("1p-111", 16).unwrap();
- let f3: f32 = f32::from_str_radix("1.Cp-123", 16).unwrap();
+ let f1 = 2.0f32.powi(-123);
+ let f2 = 2.0f32.powi(-111);
+ let f3 = 1.75 * 2.0f32.powi(-123);
let (x1, exp1) = f1.frexp();
let (x2, exp2) = f2.frexp();
let (x3, exp3) = f3.frexp();
use core::num;
use intrinsics;
use libc::c_int;
-use num::{FpCategory, ParseFloatError};
+use num::FpCategory;
#[stable(feature = "rust1", since = "1.0.0")]
pub use core::f64::{RADIX, MANTISSA_DIGITS, DIGITS, EPSILON};
#[cfg(not(test))]
#[lang = "f64"]
impl f64 {
- /// Parses a float as with a given radix
- #[unstable(feature = "float_from_str_radix", reason = "recently moved API",
- issue = "27736")]
- #[rustc_deprecated(since = "1.4.0",
- reason = "unclear how useful or correct this is")]
- #[allow(deprecated)]
- pub fn from_str_radix(s: &str, radix: u32) -> Result<f64, ParseFloatError> {
- num::Float::from_str_radix(s, radix)
- }
-
/// Returns `true` if this value is `NaN` and false otherwise.
///
/// ```
#[test]
fn test_ldexp() {
- // We have to use from_str until base-2 exponents
- // are supported in floating-point literals
- let f1: f64 = f64::from_str_radix("1p-123", 16).unwrap();
- let f2: f64 = f64::from_str_radix("1p-111", 16).unwrap();
- let f3: f64 = f64::from_str_radix("1.Cp-12", 16).unwrap();
+ let f1 = 2.0f64.powi(-123);
+ let f2 = 2.0f64.powi(-111);
+ let f3 = 1.75 * 2.0f64.powi(-12);
assert_eq!(f64::ldexp(1f64, -123), f1);
assert_eq!(f64::ldexp(1f64, -111), f2);
assert_eq!(f64::ldexp(1.75f64, -12), f3);
#[test]
fn test_frexp() {
- // We have to use from_str until base-2 exponents
- // are supported in floating-point literals
- let f1: f64 = f64::from_str_radix("1p-123", 16).unwrap();
- let f2: f64 = f64::from_str_radix("1p-111", 16).unwrap();
- let f3: f64 = f64::from_str_radix("1.Cp-123", 16).unwrap();
+ let f1 = 2.0f64.powi(-123);
+ let f2 = 2.0f64.powi(-111);
+ let f3 = 1.75 * 2.0f64.powi(-123);
let (x1, exp1) = f1.frexp();
let (x2, exp2) = f2.frexp();
let (x3, exp3) = f3.frexp();
use os::raw::{c_char, c_short, c_ulonglong};
use libc::{wchar_t, size_t, c_void};
use ptr;
-use simd;
+
+#[cfg_attr(not(stage0), repr(simd))]
+#[repr(C)]
+struct u64x2(u64, u64);
pub use self::GET_FILEEX_INFO_LEVELS::*;
pub use self::FILE_INFO_BY_HANDLE_CLASS::*;
#[cfg(target_arch = "x86_64")]
#[repr(C)]
pub struct CONTEXT {
- _align_hack: [simd::u64x2; 0], // FIXME align on 16-byte
+ _align_hack: [u64x2; 0], // FIXME align on 16-byte
pub P1Home: DWORDLONG,
pub P2Home: DWORDLONG,
pub P3Home: DWORDLONG,
#[cfg(target_arch = "x86_64")]
#[repr(C)]
pub struct M128A {
- _align_hack: [simd::u64x2; 0], // FIXME align on 16-byte
+ _align_hack: [u64x2; 0], // FIXME align on 16-byte
pub Low: c_ulonglong,
pub High: c_longlong
}
#[cfg(target_arch = "x86_64")]
#[repr(C)]
pub struct FLOATING_SAVE_AREA {
- _align_hack: [simd::u64x2; 0], // FIXME align on 16-byte
+ _align_hack: [u64x2; 0], // FIXME align on 16-byte
_Dummy: [u8; 512] // FIXME: Fill this out
}
+++ /dev/null
-// The Computer Language Benchmarks Game
-// http://benchmarksgame.alioth.debian.org/
-//
-// contributed by the Rust Project Developers
-
-// Copyright (c) 2012-2014 The Rust Project Developers
-//
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions
-// are met:
-//
-// - Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//
-// - Redistributions in binary form must reproduce the above copyright
-// notice, this list of conditions and the following disclaimer in
-// the documentation and/or other materials provided with the
-// distribution.
-//
-// - Neither the name of "The Computer Language Benchmarks Game" nor
-// the name of "The Computer Language Shootout Benchmarks" nor the
-// names of its contributors may be used to endorse or promote
-// products derived from this software without specific prior
-// written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
-// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-// COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
-// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
-// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
-// OF THE POSSIBILITY OF SUCH DAMAGE.
-
-#![feature(core_simd, core)]
-
-// ignore-pretty very bad with line comments
-
-use std::env;
-use std::io::prelude::*;
-use std::io;
-use std::simd::f64x2;
-use std::sync::Arc;
-use std::thread;
-
-const ITER: usize = 50;
-const LIMIT: f64 = 2.0;
-const WORKERS: usize = 16;
-
-fn mandelbrot<W: Write>(w: usize, mut out: W) -> io::Result<()> {
- assert_eq!(WORKERS % 2, 0);
-
- // Ensure w and h are multiples of 8.
- let w = (w + 7) / 8 * 8;
- let h = w;
-
- let chunk_size = h / WORKERS;
-
- // Account for remainders in workload division, e.g. 1000 / 16 = 62.5
- let last_chunk_size = if h % WORKERS != 0 {
- chunk_size + h % WORKERS
- } else {
- chunk_size
- };
-
- // precalc values
- let inverse_w_doubled = 2.0 / w as f64;
- let inverse_h_doubled = 2.0 / h as f64;
- let v_inverses = f64x2(inverse_w_doubled, inverse_h_doubled);
- let v_consts = f64x2(1.5, 1.0);
-
- // A lot of this code assumes this (so do other lang benchmarks)
- assert_eq!(w, h);
- let mut precalc_r = Vec::with_capacity(w);
- let mut precalc_i = Vec::with_capacity(h);
-
- let precalc_futures = (0..WORKERS).map(|i| {
- thread::spawn(move|| {
- let mut rs = Vec::with_capacity(w / WORKERS);
- let mut is = Vec::with_capacity(w / WORKERS);
-
- let start = i * chunk_size;
- let end = if i == (WORKERS - 1) {
- start + last_chunk_size
- } else {
- (i + 1) * chunk_size
- };
-
- // This assumes w == h
- for x in start..end {
- let xf = x as f64;
- let xy = f64x2(xf, xf);
-
- let f64x2(r, i) = xy * v_inverses - v_consts;
- rs.push(r);
- is.push(i);
- }
-
- (rs, is)
- })
- }).collect::<Vec<_>>();
-
- for res in precalc_futures {
- let (rs, is) = res.join().unwrap();
- precalc_r.extend(rs);
- precalc_i.extend(is);
- }
-
- assert_eq!(precalc_r.len(), w);
- assert_eq!(precalc_i.len(), h);
-
- let arc_init_r = Arc::new(precalc_r);
- let arc_init_i = Arc::new(precalc_i);
-
- let data = (0..WORKERS).map(|i| {
- let vec_init_r = arc_init_r.clone();
- let vec_init_i = arc_init_i.clone();
-
- thread::spawn(move|| {
- let mut res: Vec<u8> = Vec::with_capacity((chunk_size * w) / 8);
- let init_r_slice = vec_init_r;
-
- let start = i * chunk_size;
- let end = if i == (WORKERS - 1) {
- start + last_chunk_size
- } else {
- (i + 1) * chunk_size
- };
-
- for &init_i in &vec_init_i[start..end] {
- write_line(init_i, &init_r_slice, &mut res);
- }
-
- res
- })
- }).collect::<Vec<_>>();
-
- try!(writeln!(&mut out, "P4\n{} {}", w, h));
- for res in data {
- try!(out.write_all(&res.join().unwrap()));
- }
- out.flush()
-}
-
-fn write_line(init_i: f64, vec_init_r: &[f64], res: &mut Vec<u8>) {
- let v_init_i : f64x2 = f64x2(init_i, init_i);
- let v_2 : f64x2 = f64x2(2.0, 2.0);
- const LIMIT_SQUARED: f64 = LIMIT * LIMIT;
-
- for chunk_init_r in vec_init_r.chunks(8) {
- let mut cur_byte = 0xff;
- let mut i = 0;
-
- while i < 8 {
- let v_init_r = f64x2(chunk_init_r[i], chunk_init_r[i + 1]);
- let mut cur_r = v_init_r;
- let mut cur_i = v_init_i;
- let mut r_sq = v_init_r * v_init_r;
- let mut i_sq = v_init_i * v_init_i;
-
- let mut b = 0;
- for _ in 0..ITER {
- let r = cur_r;
- let i = cur_i;
-
- cur_i = v_2 * r * i + v_init_i;
- cur_r = r_sq - i_sq + v_init_r;
-
- let f64x2(bit1, bit2) = r_sq + i_sq;
-
- if bit1 > LIMIT_SQUARED {
- b |= 2;
- if b == 3 { break; }
- }
-
- if bit2 > LIMIT_SQUARED {
- b |= 1;
- if b == 3 { break; }
- }
-
- r_sq = cur_r * cur_r;
- i_sq = cur_i * cur_i;
- }
-
- cur_byte = (cur_byte << 2) + b;
- i += 2;
- }
-
- res.push(cur_byte^!0);
- }
-}
-
-fn main() {
- let mut args = env::args();
- let res = if args.len() < 2 {
- println!("Test mode: do not dump the image because it's not utf8, \
- which interferes with the test runner.");
- mandelbrot(1000, io::sink())
- } else {
- mandelbrot(args.nth(1).unwrap().parse().unwrap(), io::stdout())
- };
- res.unwrap();
-}
+++ /dev/null
-// The Computer Language Benchmarks Game
-// http://benchmarksgame.alioth.debian.org/
-//
-// contributed by the Rust Project Developers
-
-// Copyright (c) 2012-2014 The Rust Project Developers
-//
-// All rights reserved.
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions
-// are met:
-//
-// - Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//
-// - Redistributions in binary form must reproduce the above copyright
-// notice, this list of conditions and the following disclaimer in
-// the documentation and/or other materials provided with the
-// distribution.
-//
-// - Neither the name of "The Computer Language Benchmarks Game" nor
-// the name of "The Computer Language Shootout Benchmarks" nor the
-// names of its contributors may be used to endorse or promote
-// products derived from this software without specific prior
-// written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
-// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-// COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
-// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
-// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
-// OF THE POSSIBILITY OF SUCH DAMAGE.
-
-// no-pretty-expanded FIXME #15189
-
-#![allow(non_snake_case)]
-#![feature(unboxed_closures, iter_arith, core_simd, scoped)]
-
-use std::thread;
-use std::env;
-use std::simd::f64x2;
-
-fn main() {
- let mut args = env::args();
- let answer = spectralnorm(if env::var_os("RUST_BENCH").is_some() {
- 5500
- } else if args.len() < 2 {
- 2000
- } else {
- args.nth(1).unwrap().parse().unwrap()
- });
- println!("{:.9}", answer);
-}
-
-fn spectralnorm(n: usize) -> f64 {
- assert!(n % 2 == 0, "only even lengths are accepted");
- let mut u = vec![1.0; n];
- let mut v = u.clone();
- let mut tmp = v.clone();
- for _ in 0..10 {
- mult_AtAv(&u, &mut v, &mut tmp);
- mult_AtAv(&v, &mut u, &mut tmp);
- }
- (dot(&u, &v) / dot(&v, &v)).sqrt()
-}
-
-fn mult_AtAv(v: &[f64], out: &mut [f64], tmp: &mut [f64]) {
- mult_Av(v, tmp);
- mult_Atv(tmp, out);
-}
-
-fn mult_Av(v: &[f64], out: &mut [f64]) {
- parallel(out, |start, out| mult(v, out, start, |i, j| A(i, j)));
-}
-
-fn mult_Atv(v: &[f64], out: &mut [f64]) {
- parallel(out, |start, out| mult(v, out, start, |i, j| A(j, i)));
-}
-
-fn mult<F>(v: &[f64], out: &mut [f64], start: usize, a: F)
- where F: Fn(usize, usize) -> f64 {
- for (i, slot) in out.iter_mut().enumerate().map(|(i, s)| (i + start, s)) {
- let mut sum = f64x2(0.0, 0.0);
- for (j, chunk) in v.chunks(2).enumerate().map(|(j, s)| (2 * j, s)) {
- let top = f64x2(chunk[0], chunk[1]);
- let bot = f64x2(a(i, j), a(i, j + 1));
- sum = sum + top / bot;
- }
- let f64x2(a, b) = sum;
- *slot = a + b;
- }
-}
-
-fn A(i: usize, j: usize) -> f64 {
- ((i + j) * (i + j + 1) / 2 + i + 1) as f64
-}
-
-fn dot(v: &[f64], u: &[f64]) -> f64 {
- v.iter().zip(u).map(|(a, b)| *a * *b).sum()
-}
-
-
-// Executes a closure in parallel over the given mutable slice. The closure `f`
-// is run in parallel and yielded the starting index within `v` as well as a
-// sub-slice of `v`.
-fn parallel<'a,T, F>(v: &mut [T], ref f: F)
- where T: Send + Sync + 'a,
- F: Fn(usize, &mut [T]) + Sync + 'a {
- // FIXME: pick a more appropriate parallel factor
- // FIXME: replace with thread::scoped when it exists again
- let parallelism = 4;
- let size = v.len() / parallelism + 1;
- v.chunks_mut(size).enumerate().map(|(i, chunk)| {
- f(i * size, chunk)
- }).collect::<Vec<_>>();
-}
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-#![feature(repr_simd, core_simd)]
-#![allow(dead_code, deprecated)]
+#![feature(repr_simd)]
+#![allow(dead_code)]
-use std::simd::f32x4;
-
-#[repr(simd)] #[derive(Copy, Clone)] #[repr(C)] struct LocalSimd(u8, u8);
+#[repr(simd)]
+#[derive(Copy, Clone)]
+#[repr(C)]
+struct LocalSimd(u8, u8);
extern {
- fn foo() -> f32x4; //~ ERROR use of SIMD type
- fn bar(x: f32x4); //~ ERROR use of SIMD type
-
fn baz() -> LocalSimd; //~ ERROR use of SIMD type
fn qux(x: LocalSimd); //~ ERROR use of SIMD type
}
#![allow(unused_variables)]
#![feature(omit_gdb_pretty_printer_section)]
#![omit_gdb_pretty_printer_section]
-#![feature(core_simd)]
+#![feature(repr_simd)]
-use std::simd::{i8x16, i16x8,i32x4,i64x2,u8x16,u16x8,u32x4,u64x2,f32x4,f64x2};
+#[repr(simd)]
+struct i8x16(i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8);
+#[repr(simd)]
+struct i16x8(i16, i16, i16, i16, i16, i16, i16, i16);
+#[repr(simd)]
+struct i32x4(i32, i32, i32, i32);
+#[repr(simd)]
+struct i64x2(i64, i64);
+#[repr(simd)]
+struct u8x16(u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8);
+#[repr(simd)]
+struct u16x8(u16, u16, u16, u16, u16, u16, u16, u16);
+#[repr(simd)]
+struct u32x4(u32, u32, u32, u32);
+#[repr(simd)]
+struct u64x2(u64, u64);
+#[repr(simd)]
+struct f32x4(f32, f32, f32, f32);
+#[repr(simd)]
+struct f64x2(f64, f64);
fn main() {
// type is `&mut [u8]`, passes in a pointer to the lvalue and not a
// temporary. Issue #19147.
-
-#![feature(slice_bytes)]
+#![feature(clone_from_slice)]
use std::slice;
impl<'a> MyWriter for &'a mut [u8] {
fn my_write(&mut self, buf: &[u8]) -> Result<(), ()> {
- slice::bytes::copy_memory(buf, *self);
+ self.clone_from_slice(buf);
let write_len = buf.len();
unsafe {
+++ /dev/null
-// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// pretty-expanded FIXME #23616
-
-#![feature(core_simd)]
-
-pub fn main() {
- let _o = None::<std::simd::i32x4>;
-}
#![feature(iter_empty)]
#![feature(iter_once)]
#![feature(iter_unfold)]
-#![feature(range_inclusive)]
#![feature(step_by)]
#![feature(str_escape)]
-use std::iter::{empty, once, range_inclusive, repeat};
+use std::iter::{empty, once, repeat};
fn is_sync<T>(_: T) where T: Sync {}
fn is_send<T>(_: T) where T: Send {}
inspect(|_| ()));
is_sync_send!((1..).step_by(2));
- is_sync_send!(range_inclusive(1, 1));
is_sync_send!((1..2).step_by(2));
is_sync_send!((1..2));
is_sync_send!((1..));
use std::collections::BinaryHeap;
fn make_pq() -> BinaryHeap<isize> {
- BinaryHeap::from_vec(vec![1,2,3])
+ BinaryHeap::from(vec![1,2,3])
}
pub fn main() {