std: Stabilize APIs for the 1.6 release

This commit is the standard API stabilization commit for the 1.6 release cycle.
The list of issues and APIs below have all been through their cycle-long FCP and
the libs team decisions are listed below

Stabilized APIs

* `Read::read_exact`
* `ErrorKind::UnexpectedEof` (renamed from `UnexpectedEOF`)
* libcore -- this was a bit of a nuanced stabilization, the crate itself is now
  marked as `#[stable]` and the methods appearing via traits for primitives like
  `char` and `str` are now also marked as stable. Note that the extension traits
  themeselves are marked as unstable as they're imported via the prelude. The
  `try!` macro was also moved from the standard library into libcore to have the
  same interface. Otherwise the functions all have copied stability from the
  standard library now.
* The `#![no_std]` attribute
* `fs::DirBuilder`
* `fs::DirBuilder::new`
* `fs::DirBuilder::recursive`
* `fs::DirBuilder::create`
* `os::unix::fs::DirBuilderExt`
* `os::unix::fs::DirBuilderExt::mode`
* `vec::Drain`
* `vec::Vec::drain`
* `string::Drain`
* `string::String::drain`
* `vec_deque::Drain`
* `vec_deque::VecDeque::drain`
* `collections::hash_map::Drain`
* `collections::hash_map::HashMap::drain`
* `collections::hash_set::Drain`
* `collections::hash_set::HashSet::drain`
* `collections::binary_heap::Drain`
* `collections::binary_heap::BinaryHeap::drain`
* `Vec::extend_from_slice` (renamed from `push_all`)
* `Mutex::get_mut`
* `Mutex::into_inner`
* `RwLock::get_mut`
* `RwLock::into_inner`
* `Iterator::min_by_key` (renamed from `min_by`)
* `Iterator::max_by_key` (renamed from `max_by`)

Deprecated APIs

* `ErrorKind::UnexpectedEOF` (renamed to `UnexpectedEof`)
* `OsString::from_bytes`
* `OsStr::to_cstring`
* `OsStr::to_bytes`
* `fs::walk_dir` and `fs::WalkDir`
* `path::Components::peek`
* `slice::bytes::MutableByteVector`
* `slice::bytes::copy_memory`
* `Vec::push_all` (renamed to `extend_from_slice`)
* `Duration::span`
* `IpAddr`
* `SocketAddr::ip`
* `Read::tee`
* `io::Tee`
* `Write::broadcast`
* `io::Broadcast`
* `Iterator::min_by` (renamed to `min_by_key`)
* `Iterator::max_by` (renamed to `max_by_key`)
* `net::lookup_addr`

New APIs (still unstable)

* `<[T]>::sort_by_key` (added to mirror `min_by_key`)

Closes #27585
Closes #27704
Closes #27707
Closes #27710
Closes #27711
Closes #27727
Closes #27740
Closes #27744
Closes #27799
Closes #27801
cc #27801 (doesn't close as `Chars` is still unstable)
Closes #28968
This commit is contained in:
Alex Crichton 2015-12-02 17:31:49 -08:00
parent ac0e845224
commit 464cdff102
165 changed files with 712 additions and 718 deletions

View File

@ -16,8 +16,6 @@
#![feature(rustc_private)]
#![feature(str_char)]
#![feature(test)]
#![feature(vec_push_all)]
#![feature(path_components_peek)]
#![deny(warnings)]

View File

@ -1009,15 +1009,12 @@ fn check_expected_errors(expected_errors: Vec<errors::ExpectedError>,
}
}
fn is_compiler_error_or_warning(mut line: &str) -> bool {
// Remove initial prefix which may contain a colon
let mut components = Path::new(line).components();
if let Some(Component::Prefix(_)) = components.peek() {
components.next();
}
// Safe as path was originally constructed from a &str ^
line = components.as_path().to_str().unwrap();
fn is_compiler_error_or_warning(line: &str) -> bool {
let mut c = Path::new(line).components();
let line = match c.next() {
Some(Component::Prefix(_)) => c.as_path().to_str().unwrap(),
_ => line,
};
let mut i = 0;
return
@ -1314,7 +1311,7 @@ fn make_compile_args<F>(config: &Config,
"-L".to_owned(),
config.build_base.to_str().unwrap().to_owned(),
format!("--target={}", target));
args.push_all(&extras);
args.extend_from_slice(&extras);
if !props.no_prefer_dynamic {
args.push("-C".to_owned());
args.push("prefer-dynamic".to_owned());

View File

@ -83,7 +83,6 @@ annotated version of `alloc_system`
// Allocators are not allowed to depend on the standard library which in turn
// requires an allocator in order to avoid circular dependencies. This crate,
// however, can use all of libcore.
#![feature(no_std)]
#![no_std]
// Let's give a unique name to our custom allocator

View File

@ -16,7 +16,7 @@ and one for deallocation. A freestanding program that uses the `Box`
sugar for dynamic allocations via `malloc` and `free`:
```rust
#![feature(lang_items, box_syntax, start, no_std, libc)]
#![feature(lang_items, box_syntax, start, libc)]
#![no_std]
extern crate libc;

View File

@ -16,7 +16,6 @@ in the same format as C:
# #![feature(libc)]
#![feature(lang_items)]
#![feature(start)]
#![feature(no_std)]
#![no_std]
// Pull in the system libc library for what crt0.o likely requires
@ -46,7 +45,6 @@ compiler's name mangling too:
```rust
# #![feature(libc)]
#![feature(no_std)]
#![feature(lang_items)]
#![feature(start)]
#![no_std]
@ -104,9 +102,6 @@ vectors provided from C, using idiomatic Rust practices.
# #![feature(libc)]
#![feature(lang_items)]
#![feature(start)]
#![feature(no_std)]
#![feature(core)]
#![feature(core_slice_ext)]
#![feature(raw)]
#![no_std]

View File

@ -315,7 +315,6 @@ def emit_bsearch_range_table(f):
f.write("""
fn bsearch_range_table(c: char, r: &'static [(char, char)]) -> bool {
use core::cmp::Ordering::{Equal, Less, Greater};
use core::slice::SliceExt;
r.binary_search_by(|&(lo, hi)| {
if lo <= c && c <= hi {
Equal
@ -358,7 +357,6 @@ def emit_conversions_module(f, to_upper, to_lower, to_title):
f.write("pub mod conversions {")
f.write("""
use core::cmp::Ordering::{Equal, Less, Greater};
use core::slice::SliceExt;
use core::option::Option;
use core::option::Option::{Some, None};
use core::result::Result::{Ok, Err};
@ -404,7 +402,6 @@ def emit_charwidth_module(f, width_table):
f.write("pub mod charwidth {\n")
f.write(" use core::option::Option;\n")
f.write(" use core::option::Option::{Some, None};\n")
f.write(" use core::slice::SliceExt;\n")
f.write(" use core::result::Result::{Ok, Err};\n")
f.write("""
fn bsearch_range_value_table(c: char, is_cjk: bool, r: &'static [(char, char, u8, u8)]) -> u8 {

View File

@ -104,7 +104,6 @@ pub struct ExchangeHeapSingleton {
/// See the [module-level documentation](../../std/boxed/index.html) for more.
#[lang = "owned_box"]
#[stable(feature = "rust1", since = "1.0.0")]
#[fundamental]
pub struct Box<T: ?Sized>(Unique<T>);
/// `IntermediateBox` represents uninitialized backing storage for `Box`.

View File

@ -75,17 +75,15 @@
#![cfg_attr(not(stage0), needs_allocator)]
#![cfg_attr(stage0, feature(rustc_attrs))]
#![cfg_attr(stage0, feature(no_std))]
#![cfg_attr(stage0, allow(unused_attributes))]
#![feature(allocator)]
#![feature(box_syntax)]
#![feature(coerce_unsized)]
#![feature(core)]
#![feature(core_intrinsics)]
#![feature(core_slice_ext)]
#![feature(custom_attribute)]
#![feature(fundamental)]
#![feature(lang_items)]
#![feature(no_std)]
#![feature(nonzero)]
#![feature(num_bits_bytes)]
#![feature(optin_builtin_traits)]
@ -103,9 +101,8 @@
#![allow(unused_attributes)]
#![feature(dropck_parametricity)]
#![feature(unsize)]
#![feature(core_slice_ext)]
#![feature(core_str_ext)]
#![feature(drop_in_place)]
#![feature(fn_traits)]
#![cfg_attr(stage0, feature(alloc_system))]
#![cfg_attr(not(stage0), feature(needs_allocator))]

View File

@ -10,7 +10,7 @@
use core::ptr::Unique;
use core::mem;
use core::slice::{self, SliceExt};
use core::slice;
use heap;
use super::oom;
use super::boxed::Box;

View File

@ -21,8 +21,8 @@
issue = "27783")]
#![feature(allocator)]
#![feature(libc)]
#![feature(no_std)]
#![feature(staged_api)]
#![cfg_attr(stage0, feature(no_std))]
extern crate libc;

View File

@ -21,8 +21,8 @@
issue = "27783")]
#![feature(allocator)]
#![feature(libc)]
#![feature(no_std)]
#![feature(staged_api)]
#![cfg_attr(stage0, feature(no_std))]
extern crate libc;

View File

@ -581,10 +581,7 @@ impl<T: Ord> BinaryHeap<T> {
///
/// The elements are removed in arbitrary order.
#[inline]
#[unstable(feature = "drain",
reason = "matches collection reform specification, \
waiting for dust to settle",
issue = "27711")]
#[stable(feature = "drain", since = "1.6.0")]
pub fn drain(&mut self) -> Drain<T> {
Drain { iter: self.data.drain(..) }
}
@ -738,7 +735,7 @@ impl<T> DoubleEndedIterator for IntoIter<T> {
impl<T> ExactSizeIterator for IntoIter<T> {}
/// An iterator that drains a `BinaryHeap`.
#[unstable(feature = "drain", reason = "recent addition", issue = "27711")]
#[stable(feature = "drain", since = "1.6.0")]
pub struct Drain<'a, T: 'a> {
iter: vec::Drain<'a, T>,
}

View File

@ -43,8 +43,6 @@
#![feature(box_patterns)]
#![feature(box_syntax)]
#![feature(core_intrinsics)]
#![feature(core_slice_ext)]
#![feature(core_str_ext)]
#![feature(fmt_internals)]
#![feature(fmt_radix)]
#![feature(heap_api)]
@ -68,9 +66,10 @@
#![feature(unsafe_no_drop_flag, filling_drop)]
#![feature(decode_utf16)]
#![feature(drop_in_place)]
#![feature(clone_from_slice)]
#![cfg_attr(test, feature(clone_from_slice, rand, test))]
#![feature(no_std)]
#![cfg_attr(stage0, feature(no_std))]
#![no_std]
extern crate rustc_unicode;

View File

@ -160,7 +160,7 @@ mod hack {
where T: Clone
{
let mut vector = Vec::with_capacity(s.len());
vector.push_all(s);
vector.extend_from_slice(s);
vector
}
}
@ -777,6 +777,33 @@ impl<T> [T] {
self.sort_by(|a, b| a.cmp(b))
}
/// Sorts the slice, in place, using `key` to extract a key by which to
/// order the sort by.
///
/// This sort is `O(n log n)` worst-case and stable, but allocates
/// approximately `2 * n`, where `n` is the length of `self`.
///
/// This is a stable sort.
///
/// # Examples
///
/// ```rust
/// #![feature(slice_sort_by_key)]
///
/// let mut v = [-5i32, 4, 1, -3, 2];
///
/// v.sort_by_key(|k| k.abs());
/// assert!(v == [1, 2, -3, 4, -5]);
/// ```
#[unstable(feature = "slice_sort_by_key", reason = "recently added",
issue = "27724")]
#[inline]
pub fn sort_by_key<B, F>(&mut self, mut f: F)
where F: FnMut(&T) -> B, B: Ord
{
self.sort_by(|a, b| f(a).cmp(&f(b)))
}
/// Sorts the slice, in place, using `compare` to compare
/// elements.
///
@ -906,7 +933,7 @@ impl<T: Clone, V: Borrow<[T]>> SliceConcatExt<T> for [V] {
let size = self.iter().fold(0, |acc, v| acc + v.borrow().len());
let mut result = Vec::with_capacity(size);
for v in self {
result.push_all(v.borrow())
result.extend_from_slice(v.borrow())
}
result
}
@ -921,7 +948,7 @@ impl<T: Clone, V: Borrow<[T]>> SliceConcatExt<T> for [V] {
} else {
result.push(sep.clone())
}
result.push_all(v.borrow())
result.extend_from_slice(v.borrow())
}
result
}

View File

@ -482,7 +482,7 @@ impl String {
let mut res = String::with_capacity(total);
if i > 0 {
unsafe { res.as_mut_vec().push_all(&v[..i]) };
unsafe { res.as_mut_vec().extend_from_slice(&v[..i]) };
}
// subseqidx is the index of the first byte of the subsequence we're
@ -498,10 +498,10 @@ impl String {
macro_rules! error { () => ({
unsafe {
if subseqidx != i_ {
res.as_mut_vec().push_all(&v[subseqidx..i_]);
res.as_mut_vec().extend_from_slice(&v[subseqidx..i_]);
}
subseqidx = i;
res.as_mut_vec().push_all(REPLACEMENT);
res.as_mut_vec().extend_from_slice(REPLACEMENT);
}
})}
@ -566,7 +566,7 @@ impl String {
}
}
if subseqidx < total {
unsafe { res.as_mut_vec().push_all(&v[subseqidx..total]) };
unsafe { res.as_mut_vec().extend_from_slice(&v[subseqidx..total]) };
}
Cow::Owned(res)
}
@ -699,7 +699,7 @@ impl String {
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn push_str(&mut self, string: &str) {
self.vec.push_all(string.as_bytes())
self.vec.extend_from_slice(string.as_bytes())
}
/// Returns the number of bytes that this string buffer can hold without
@ -1026,8 +1026,6 @@ impl String {
/// # Examples
///
/// ```
/// #![feature(drain)]
///
/// let mut s = String::from("α is alpha, β is beta");
/// let beta_offset = s.find('β').unwrap_or(s.len());
///
@ -1040,9 +1038,7 @@ impl String {
/// s.drain(..);
/// assert_eq!(s, "");
/// ```
#[unstable(feature = "drain",
reason = "recently added, matches RFC",
issue = "27711")]
#[stable(feature = "drain", since = "1.6.0")]
pub fn drain<R>(&mut self, range: R) -> Drain
where R: RangeArgument<usize>
{
@ -1600,7 +1596,7 @@ impl fmt::Write for String {
}
/// A draining iterator for `String`.
#[unstable(feature = "drain", reason = "recently added", issue = "27711")]
#[stable(feature = "drain", since = "1.6.0")]
pub struct Drain<'a> {
/// Will be used as &'a mut String in the destructor
string: *mut String,
@ -1612,12 +1608,12 @@ pub struct Drain<'a> {
iter: Chars<'a>,
}
#[unstable(feature = "drain", reason = "recently added", issue = "27711")]
#[stable(feature = "drain", since = "1.6.0")]
unsafe impl<'a> Sync for Drain<'a> {}
#[unstable(feature = "drain", reason = "recently added", issue = "27711")]
#[stable(feature = "drain", since = "1.6.0")]
unsafe impl<'a> Send for Drain<'a> {}
#[unstable(feature = "drain", reason = "recently added", issue = "27711")]
#[stable(feature = "drain", since = "1.6.0")]
impl<'a> Drop for Drain<'a> {
fn drop(&mut self) {
unsafe {
@ -1631,7 +1627,7 @@ impl<'a> Drop for Drain<'a> {
}
}
#[unstable(feature = "drain", reason = "recently added", issue = "27711")]
#[stable(feature = "drain", since = "1.6.0")]
impl<'a> Iterator for Drain<'a> {
type Item = char;
@ -1645,7 +1641,7 @@ impl<'a> Iterator for Drain<'a> {
}
}
#[unstable(feature = "drain", reason = "recently added", issue = "27711")]
#[stable(feature = "drain", since = "1.6.0")]
impl<'a> DoubleEndedIterator for Drain<'a> {
#[inline]
fn next_back(&mut self) -> Option<char> {

View File

@ -739,17 +739,13 @@ impl<T> Vec<T> {
/// # Examples
///
/// ```
/// #![feature(drain)]
///
/// // Draining using `..` clears the whole vector.
/// let mut v = vec![1, 2, 3];
/// let u: Vec<_> = v.drain(..).collect();
/// assert_eq!(v, &[]);
/// assert_eq!(u, &[1, 2, 3]);
/// ```
#[unstable(feature = "drain",
reason = "recently added, matches RFC",
issue = "27711")]
#[stable(feature = "drain", since = "1.6.0")]
pub fn drain<R>(&mut self, range: R) -> Drain<T>
where R: RangeArgument<usize>
{
@ -933,6 +929,7 @@ impl<T: Clone> Vec<T> {
///
/// ```
/// #![feature(vec_push_all)]
/// #![allow(deprecated)]
///
/// let mut vec = vec![1];
/// vec.push_all(&[2, 3, 4]);
@ -942,7 +939,31 @@ impl<T: Clone> Vec<T> {
#[unstable(feature = "vec_push_all",
reason = "likely to be replaced by a more optimized extend",
issue = "27744")]
#[rustc_deprecated(reason = "renamed to extend_from_slice",
since = "1.6.0")]
pub fn push_all(&mut self, other: &[T]) {
self.extend_from_slice(other)
}
/// Appends all elements in a slice to the `Vec`.
///
/// Iterates over the slice `other`, clones each element, and then appends
/// it to this `Vec`. The `other` vector is traversed in-order.
///
/// Note that this function is same as `extend` except that it is
/// specialized to work with slices instead. If and when Rust gets
/// specialization this function will likely be deprecated (but still
/// available).
///
/// # Examples
///
/// ```
/// let mut vec = vec![1];
/// vec.extend_from_slice(&[2, 3, 4]);
/// assert_eq!(vec, [1, 2, 3, 4]);
/// ```
#[stable(feature = "vec_extend_from_slice", since = "1.6.0")]
pub fn extend_from_slice(&mut self, other: &[T]) {
self.reserve(other.len());
for i in 0..other.len() {
@ -1103,7 +1124,7 @@ impl<T: Clone> Clone for Vec<T> {
// self.len <= other.len due to the truncate above, so the
// slice here is always in-bounds.
self.push_all(&other[len..]);
self.extend_from_slice(&other[len..]);
}
}
@ -1350,6 +1371,21 @@ impl<'a, T: 'a + Copy> Extend<&'a T> for Vec<T> {
}
}
macro_rules! __impl_slice_eq1 {
($Lhs: ty, $Rhs: ty) => {
__impl_slice_eq1! { $Lhs, $Rhs, Sized }
};
($Lhs: ty, $Rhs: ty, $Bound: ident) => {
#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, 'b, A: $Bound, B> PartialEq<$Rhs> for $Lhs where A: PartialEq<B> {
#[inline]
fn eq(&self, other: &$Rhs) -> bool { self[..] == other[..] }
#[inline]
fn ne(&self, other: &$Rhs) -> bool { self[..] != other[..] }
}
}
}
__impl_slice_eq1! { Vec<A>, Vec<B> }
__impl_slice_eq1! { Vec<A>, &'b [B] }
__impl_slice_eq1! { Vec<A>, &'b mut [B] }
@ -1605,7 +1641,7 @@ impl<T> Drop for IntoIter<T> {
}
/// A draining iterator for `Vec<T>`.
#[unstable(feature = "drain", reason = "recently added", issue = "27711")]
#[stable(feature = "drain", since = "1.6.0")]
pub struct Drain<'a, T: 'a> {
/// Index of tail to preserve
tail_start: usize,
@ -1616,9 +1652,9 @@ pub struct Drain<'a, T: 'a> {
vec: *mut Vec<T>,
}
#[unstable(feature = "drain", reason = "recently added", issue = "27711")]
#[stable(feature = "drain", since = "1.6.0")]
unsafe impl<'a, T: Sync> Sync for Drain<'a, T> {}
#[unstable(feature = "drain", reason = "recently added", issue = "27711")]
#[stable(feature = "drain", since = "1.6.0")]
unsafe impl<'a, T: Send> Send for Drain<'a, T> {}
#[stable(feature = "rust1", since = "1.0.0")]

View File

@ -778,8 +778,6 @@ impl<T> VecDeque<T> {
/// # Examples
///
/// ```
/// #![feature(drain)]
///
/// use std::collections::VecDeque;
///
/// // draining using `..` clears the whole deque.
@ -789,9 +787,7 @@ impl<T> VecDeque<T> {
/// assert!(v.is_empty());
/// ```
#[inline]
#[unstable(feature = "drain",
reason = "matches collection reform specification, waiting for dust to settle",
issue = "27711")]
#[stable(feature = "drain", since = "1.6.0")]
pub fn drain<R>(&mut self, range: R) -> Drain<T>
where R: RangeArgument<usize>
{
@ -1893,9 +1889,7 @@ impl<T> DoubleEndedIterator for IntoIter<T> {
impl<T> ExactSizeIterator for IntoIter<T> {}
/// A draining VecDeque iterator
#[unstable(feature = "drain",
reason = "matches collection reform specification, waiting for dust to settle",
issue = "27711")]
#[stable(feature = "drain", since = "1.6.0")]
pub struct Drain<'a, T: 'a> {
after_tail: usize,
after_head: usize,
@ -1903,9 +1897,9 @@ pub struct Drain<'a, T: 'a> {
deque: *mut VecDeque<T>,
}
#[unstable(feature = "drain", issue = "27711")]
#[stable(feature = "drain", since = "1.6.0")]
unsafe impl<'a, T: Sync> Sync for Drain<'a, T> {}
#[unstable(feature = "drain", issue = "27711")]
#[stable(feature = "drain", since = "1.6.0")]
unsafe impl<'a, T: Send> Send for Drain<'a, T> {}
#[stable(feature = "rust1", since = "1.0.0")]

View File

@ -15,7 +15,7 @@
#![feature(collections)]
#![feature(collections_bound)]
#![feature(const_fn)]
#![feature(core)]
#![feature(fn_traits)]
#![feature(deque_extras)]
#![feature(drain)]
#![feature(enumset)]

View File

@ -62,6 +62,38 @@ unsafe impl<T, A: Unsize<[T]>> FixedSizeArray<T> for A {
}
}
macro_rules! __impl_slice_eq1 {
($Lhs: ty, $Rhs: ty) => {
__impl_slice_eq1! { $Lhs, $Rhs, Sized }
};
($Lhs: ty, $Rhs: ty, $Bound: ident) => {
#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, 'b, A: $Bound, B> PartialEq<$Rhs> for $Lhs where A: PartialEq<B> {
#[inline]
fn eq(&self, other: &$Rhs) -> bool { self[..] == other[..] }
#[inline]
fn ne(&self, other: &$Rhs) -> bool { self[..] != other[..] }
}
}
}
macro_rules! __impl_slice_eq2 {
($Lhs: ty, $Rhs: ty) => {
__impl_slice_eq2! { $Lhs, $Rhs, Sized }
};
($Lhs: ty, $Rhs: ty, $Bound: ident) => {
__impl_slice_eq1!($Lhs, $Rhs, $Bound);
#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, 'b, A: $Bound, B> PartialEq<$Lhs> for $Rhs where B: PartialEq<A> {
#[inline]
fn eq(&self, other: &$Lhs) -> bool { self[..] == other[..] }
#[inline]
fn ne(&self, other: &$Lhs) -> bool { self[..] != other[..] }
}
}
}
// macro for implementing n-ary tuple functions and operations
macro_rules! array_impls {
($($N:expr)+) => {

View File

@ -257,19 +257,25 @@ pub fn from_digit(num: u32, radix: u32) -> Option<char> {
reason = "the stable interface is `impl char` in later crate",
issue = "27701")]
pub trait CharExt {
#[stable(feature = "core", since = "1.6.0")]
fn is_digit(self, radix: u32) -> bool;
#[stable(feature = "core", since = "1.6.0")]
fn to_digit(self, radix: u32) -> Option<u32>;
#[stable(feature = "core", since = "1.6.0")]
fn escape_unicode(self) -> EscapeUnicode;
#[stable(feature = "core", since = "1.6.0")]
fn escape_default(self) -> EscapeDefault;
#[stable(feature = "core", since = "1.6.0")]
fn len_utf8(self) -> usize;
#[stable(feature = "core", since = "1.6.0")]
fn len_utf16(self) -> usize;
#[stable(feature = "core", since = "1.6.0")]
fn encode_utf8(self, dst: &mut [u8]) -> Option<usize>;
#[stable(feature = "core", since = "1.6.0")]
fn encode_utf16(self, dst: &mut [u16]) -> Option<usize>;
}
#[unstable(feature = "core_char_ext",
reason = "the stable interface is `impl char` in later crate",
issue = "27701")]
#[stable(feature = "core", since = "1.6.0")]
impl CharExt for char {
#[inline]
fn is_digit(self, radix: u32) -> bool {

View File

@ -1,47 +0,0 @@
// Copyright 2015 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.
// Utility macros for implementing PartialEq on slice-like types
#![doc(hidden)]
#[macro_export]
macro_rules! __impl_slice_eq1 {
($Lhs: ty, $Rhs: ty) => {
__impl_slice_eq1! { $Lhs, $Rhs, Sized }
};
($Lhs: ty, $Rhs: ty, $Bound: ident) => {
#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, 'b, A: $Bound, B> PartialEq<$Rhs> for $Lhs where A: PartialEq<B> {
#[inline]
fn eq(&self, other: &$Rhs) -> bool { self[..] == other[..] }
#[inline]
fn ne(&self, other: &$Rhs) -> bool { self[..] != other[..] }
}
}
}
#[macro_export]
macro_rules! __impl_slice_eq2 {
($Lhs: ty, $Rhs: ty) => {
__impl_slice_eq2! { $Lhs, $Rhs, Sized }
};
($Lhs: ty, $Rhs: ty, $Bound: ident) => {
__impl_slice_eq1!($Lhs, $Rhs, $Bound);
#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, 'b, A: $Bound, B> PartialEq<$Lhs> for $Rhs where B: PartialEq<A> {
#[inline]
fn eq(&self, other: &$Lhs) -> bool { self[..] == other[..] }
#[inline]
fn ne(&self, other: &$Lhs) -> bool { self[..] != other[..] }
}
}
}

View File

@ -878,7 +878,7 @@ impl<'a> Formatter<'a> {
let mut prefixed = false;
if self.alternate() {
prefixed = true; width += prefix.char_len();
prefixed = true; width += prefix.chars().count();
}
// Writes the sign if it exists, and then the prefix if it was requested
@ -942,18 +942,13 @@ impl<'a> Formatter<'a> {
}
// The `precision` field can be interpreted as a `max-width` for the
// string being formatted
match self.precision {
Some(max) => {
// If there's a maximum width and our string is longer than
// that, then we must always have truncation. This is the only
// case where the maximum length will matter.
let char_len = s.char_len();
if char_len >= max {
let nchars = ::cmp::min(max, char_len);
return self.buf.write_str(s.slice_chars(0, nchars));
}
if let Some(max) = self.precision {
// If there's a maximum width and our string is longer than
// that, then we must always have truncation. This is the only
// case where the maximum length will matter.
if let Some((i, _)) = s.char_indices().skip(max).next() {
return self.buf.write_str(&s[..i])
}
None => {}
}
// The `width` field is more of a `min-width` parameter at this point.
match self.width {
@ -962,13 +957,13 @@ impl<'a> Formatter<'a> {
None => self.buf.write_str(s),
// If we're under the maximum width, check if we're over the minimum
// width, if so it's as easy as just emitting the string.
Some(width) if s.char_len() >= width => {
Some(width) if s.chars().count() >= width => {
self.buf.write_str(s)
}
// If we're under both the maximum and the minimum width, then fill
// up the minimum width with the specified string + some alignment.
Some(width) => {
self.with_padding(width - s.char_len(), Alignment::Left, |me| {
self.with_padding(width - s.chars().count(), Alignment::Left, |me| {
me.buf.write_str(s)
})
}

View File

@ -1903,6 +1903,7 @@ pub trait Iterator {
///
/// ```
/// #![feature(iter_cmp)]
/// #![allow(deprecated)]
///
/// let a = [-3_i32, 0, 1, 5, -10];
/// assert_eq!(*a.iter().max_by(|x| x.abs()).unwrap(), -10);
@ -1911,9 +1912,30 @@ pub trait Iterator {
#[unstable(feature = "iter_cmp",
reason = "may want to produce an Ordering directly; see #15311",
issue = "27724")]
#[rustc_deprecated(reason = "renamed to max_by_key", since = "1.6.0")]
fn max_by<B: Ord, F>(self, f: F) -> Option<Self::Item> where
Self: Sized,
F: FnMut(&Self::Item) -> B,
{
self.max_by_key(f)
}
/// Returns the element that gives the maximum value from the
/// specified function.
///
/// Returns the rightmost element if the comparison determines two elements
/// to be equally maximum.
///
/// # Examples
///
/// ```
/// let a = [-3_i32, 0, 1, 5, -10];
/// assert_eq!(*a.iter().max_by_key(|x| x.abs()).unwrap(), -10);
/// ```
#[inline]
#[stable(feature = "iter_cmp_by_key", since = "1.6.0")]
fn max_by_key<B: Ord, F>(self, f: F) -> Option<Self::Item>
where Self: Sized, F: FnMut(&Self::Item) -> B,
{
select_fold1(self,
f,
@ -1933,6 +1955,7 @@ pub trait Iterator {
///
/// ```
/// #![feature(iter_cmp)]
/// #![allow(deprecated)]
///
/// let a = [-3_i32, 0, 1, 5, -10];
/// assert_eq!(*a.iter().min_by(|x| x.abs()).unwrap(), 0);
@ -1941,9 +1964,29 @@ pub trait Iterator {
#[unstable(feature = "iter_cmp",
reason = "may want to produce an Ordering directly; see #15311",
issue = "27724")]
#[rustc_deprecated(reason = "renamed to min_by_key", since = "1.6.0")]
fn min_by<B: Ord, F>(self, f: F) -> Option<Self::Item> where
Self: Sized,
F: FnMut(&Self::Item) -> B,
{
self.min_by_key(f)
}
/// Returns the element that gives the minimum value from the
/// specified function.
///
/// Returns the latest element if the comparison determines two elements
/// to be equally minimum.
///
/// # Examples
///
/// ```
/// let a = [-3_i32, 0, 1, 5, -10];
/// assert_eq!(*a.iter().min_by_key(|x| x.abs()).unwrap(), 0);
/// ```
#[stable(feature = "iter_cmp_by_key", since = "1.6.0")]
fn min_by_key<B: Ord, F>(self, f: F) -> Option<Self::Item>
where Self: Sized, F: FnMut(&Self::Item) -> B,
{
select_fold1(self,
f,
@ -3588,7 +3631,7 @@ impl<I: Iterator> Peekable<I> {
/// Basic usage:
///
/// ```
/// #![feature(core)]
/// #![feature(peekable_is_empty)]
///
/// let xs = [1, 2, 3];
///
@ -3604,7 +3647,7 @@ impl<I: Iterator> Peekable<I> {
///
/// assert_eq!(iter.is_empty(), true);
/// ```
#[unstable(feature = "core", issue = "27701")]
#[unstable(feature = "peekable_is_empty", issue = "27701")]
#[inline]
pub fn is_empty(&mut self) -> bool {
self.peek().is_none()

View File

@ -52,18 +52,16 @@
// Do not remove on snapshot creation. Needed for bootstrap. (Issue #22364)
#![cfg_attr(stage0, feature(custom_attribute))]
#![crate_name = "core"]
#![unstable(feature = "core",
reason = "the libcore library has not yet been scrutinized for \
stabilization in terms of structure and naming",
issue = "27701")]
#![stable(feature = "core", since = "1.6.0")]
#![cfg_attr(stage0, staged_api)]
#![crate_type = "rlib"]
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
html_root_url = "https://doc.rust-lang.org/nightly/",
html_playground_url = "https://play.rust-lang.org/",
issue_tracker_base_url = "https://github.com/rust-lang/rust/issues/")]
#![doc(test(no_crate_inject, attr(allow(unused_variables), deny(warnings))))]
issue_tracker_base_url = "https://github.com/rust-lang/rust/issues/",
test(no_crate_inject, attr(deny(warnings))),
test(attr(allow(dead_code, deprecated, unused_variables, unused_mut))))]
#![no_core]
#![deny(missing_docs)]
@ -91,9 +89,6 @@
#[macro_use]
mod macros;
#[macro_use]
mod cmp_macros;
#[path = "num/float_macros.rs"]
#[macro_use]
mod float_macros;

View File

@ -11,6 +11,7 @@
/// Entry point of thread panic, for details, see std::macros
#[macro_export]
#[allow_internal_unstable]
#[stable(feature = "core", since = "1.6.0")]
macro_rules! panic {
() => (
panic!("explicit panic")
@ -154,21 +155,47 @@ macro_rules! debug_assert {
/// debug_assert_eq!(a, b);
/// ```
#[macro_export]
#[stable(feature = "rust1", since = "1.0.0")]
macro_rules! debug_assert_eq {
($($arg:tt)*) => (if cfg!(debug_assertions) { assert_eq!($($arg)*); })
}
/// Short circuiting evaluation on Err
/// Helper macro for unwrapping `Result` values while returning early with an
/// error if the value of the expression is `Err`. Can only be used in
/// functions that return `Result` because of the early return of `Err` that
/// it provides.
///
/// `libstd` contains a more general `try!` macro that uses `From<E>`.
/// # Examples
///
/// ```
/// use std::io;
/// use std::fs::File;
/// use std::io::prelude::*;
///
/// fn write_to_file_using_try() -> Result<(), io::Error> {
/// let mut file = try!(File::create("my_best_friends.txt"));
/// try!(file.write_all(b"This is a list of my best friends."));
/// println!("I wrote to the file");
/// Ok(())
/// }
/// // This is equivalent to:
/// fn write_to_file_using_match() -> Result<(), io::Error> {
/// let mut file = try!(File::create("my_best_friends.txt"));
/// match file.write_all(b"This is a list of my best friends.") {
/// Ok(_) => (),
/// Err(e) => return Err(e),
/// }
/// println!("I wrote to the file");
/// Ok(())
/// }
/// ```
#[macro_export]
#[stable(feature = "rust1", since = "1.0.0")]
macro_rules! try {
($e:expr) => ({
use $crate::result::Result::{Ok, Err};
match $e {
Ok(e) => e,
Err(e) => return Err(e),
($expr:expr) => (match $expr {
$crate::result::Result::Ok(val) => val,
$crate::result::Result::Err(err) => {
return $crate::result::Result::Err($crate::convert::From::from(err))
}
})
}
@ -194,6 +221,7 @@ macro_rules! try {
/// assert_eq!(w, b"testformatted arguments");
/// ```
#[macro_export]
#[stable(feature = "core", since = "1.6.0")]
macro_rules! write {
($dst:expr, $($arg:tt)*) => ($dst.write_fmt(format_args!($($arg)*)))
}
@ -271,9 +299,7 @@ macro_rules! writeln {
/// }
/// ```
#[macro_export]
#[unstable(feature = "core",
reason = "relationship with panic is unclear",
issue = "27701")]
#[stable(feature = "core", since = "1.6.0")]
macro_rules! unreachable {
() => ({
panic!("internal error: entered unreachable code")
@ -334,9 +360,7 @@ macro_rules! unreachable {
/// }
/// ```
#[macro_export]
#[unstable(feature = "core",
reason = "relationship with panic is unclear",
issue = "27701")]
#[stable(feature = "core", since = "1.6.0")]
macro_rules! unimplemented {
() => (panic!("not yet implemented"))
}

View File

@ -243,14 +243,14 @@ impl Float for f32 {
/// Returns `true` if `self` is positive, including `+0.0` and
/// `Float::infinity()`.
#[inline]
fn is_positive(self) -> bool {
fn is_sign_positive(self) -> bool {
self > 0.0 || (1.0 / self) == Float::infinity()
}
/// Returns `true` if `self` is negative, including `-0.0` and
/// `Float::neg_infinity()`.
#[inline]
fn is_negative(self) -> bool {
fn is_sign_negative(self) -> bool {
self < 0.0 || (1.0 / self) == Float::neg_infinity()
}

View File

@ -243,14 +243,14 @@ impl Float for f64 {
/// Returns `true` if `self` is positive, including `+0.0` and
/// `Float::infinity()`.
#[inline]
fn is_positive(self) -> bool {
fn is_sign_positive(self) -> bool {
self > 0.0 || (1.0 / self) == Float::infinity()
}
/// Returns `true` if `self` is negative, including `-0.0` and
/// `Float::neg_infinity()`.
#[inline]
fn is_negative(self) -> bool {
fn is_sign_negative(self) -> bool {
self < 0.0 || (1.0 / self) == Float::neg_infinity()
}

View File

@ -132,7 +132,6 @@ functions.
use prelude::v1::*;
use i16;
use slice::bytes;
pub use self::decoder::{decode, DecodableFloat, FullDecoded, Decoded};
pub mod estimator;
@ -211,7 +210,7 @@ impl<'a> Part<'a> {
}
}
Part::Copy(buf) => {
bytes::copy_memory(buf, out);
out.clone_from_slice(buf);
}
}
Some(len)
@ -246,7 +245,7 @@ impl<'a> Formatted<'a> {
/// (It may still leave partially written bytes in the buffer; do not rely on that.)
pub fn write(&self, out: &mut [u8]) -> Option<usize> {
if out.len() < self.sign.len() { return None; }
bytes::copy_memory(self.sign, out);
out.clone_from_slice(self.sign);
let mut written = self.sign.len();
for part in self.parts {

View File

@ -1748,62 +1748,96 @@ pub enum FpCategory {
issue = "27702")]
pub trait Float: Sized {
/// Returns the NaN value.
#[unstable(feature = "float_extras", reason = "needs removal",
issue = "27752")]
fn nan() -> Self;
/// Returns the infinite value.
#[unstable(feature = "float_extras", reason = "needs removal",
issue = "27752")]
fn infinity() -> Self;
/// Returns the negative infinite value.
#[unstable(feature = "float_extras", reason = "needs removal",
issue = "27752")]
fn neg_infinity() -> Self;
/// Returns -0.0.
#[unstable(feature = "float_extras", reason = "needs removal",
issue = "27752")]
fn neg_zero() -> Self;
/// Returns 0.0.
#[unstable(feature = "float_extras", reason = "needs removal",
issue = "27752")]
fn zero() -> Self;
/// Returns 1.0.
#[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")]
fn is_nan(self) -> bool;
/// Returns true if this value is positive infinity or negative infinity and
/// false otherwise.
#[stable(feature = "core", since = "1.6.0")]
fn is_infinite(self) -> bool;
/// Returns true if this number is neither infinite nor NaN.
#[stable(feature = "core", since = "1.6.0")]
fn is_finite(self) -> bool;
/// Returns true if this number is neither zero, infinite, denormal, or NaN.
#[stable(feature = "core", since = "1.6.0")]
fn is_normal(self) -> bool;
/// Returns the category that this number falls into.
#[stable(feature = "core", since = "1.6.0")]
fn classify(self) -> FpCategory;
/// Returns the mantissa, exponent and sign as integers, respectively.
#[unstable(feature = "float_extras", reason = "signature is undecided",
issue = "27752")]
fn integer_decode(self) -> (u64, i16, i8);
/// Computes the absolute value of `self`. Returns `Float::nan()` if the
/// number is `Float::nan()`.
#[stable(feature = "core", since = "1.6.0")]
fn abs(self) -> Self;
/// Returns a number that represents the sign of `self`.
///
/// - `1.0` if the number is positive, `+0.0` or `Float::infinity()`
/// - `-1.0` if the number is negative, `-0.0` or `Float::neg_infinity()`
/// - `Float::nan()` if the number is `Float::nan()`
#[stable(feature = "core", since = "1.6.0")]
fn signum(self) -> Self;
/// Returns `true` if `self` is positive, including `+0.0` and
/// `Float::infinity()`.
fn is_positive(self) -> bool;
#[stable(feature = "core", since = "1.6.0")]
fn is_sign_positive(self) -> bool;
/// Returns `true` if `self` is negative, including `-0.0` and
/// `Float::neg_infinity()`.
fn is_negative(self) -> bool;
#[stable(feature = "core", since = "1.6.0")]
fn is_sign_negative(self) -> bool;
/// Take the reciprocal (inverse) of a number, `1/x`.
#[stable(feature = "core", since = "1.6.0")]
fn recip(self) -> Self;
/// Raise a number to an integer power.
///
/// Using this function is generally faster than using `powf`
#[stable(feature = "core", since = "1.6.0")]
fn powi(self, n: i32) -> Self;
/// Convert radians to degrees.
#[unstable(feature = "float_extras", reason = "desirability is unclear",
issue = "27752")]
fn to_degrees(self) -> Self;
/// Convert degrees to radians.
#[unstable(feature = "float_extras", reason = "desirability is unclear",
issue = "27752")]
fn to_radians(self) -> Self;
}

View File

@ -1732,7 +1732,7 @@ impl<'a, T: ?Sized> DerefMut for &'a mut T {
#[fundamental] // so that regex can rely that `&str: !FnMut`
pub trait Fn<Args> : FnMut<Args> {
/// This is called when the call operator is used.
#[unstable(feature = "core", issue = "27701")]
#[unstable(feature = "fn_traits", issue = "29625")]
extern "rust-call" fn call(&self, args: Args) -> Self::Output;
}
@ -1743,7 +1743,7 @@ pub trait Fn<Args> : FnMut<Args> {
#[fundamental] // so that regex can rely that `&str: !FnMut`
pub trait FnMut<Args> : FnOnce<Args> {
/// This is called when the call operator is used.
#[unstable(feature = "core", issue = "27701")]
#[unstable(feature = "fn_traits", issue = "29625")]
extern "rust-call" fn call_mut(&mut self, args: Args) -> Self::Output;
}
@ -1754,11 +1754,11 @@ pub trait FnMut<Args> : FnOnce<Args> {
#[fundamental] // so that regex can rely that `&str: !FnMut`
pub trait FnOnce<Args> {
/// The returned type after the call operator is used.
#[unstable(feature = "core", issue = "27701")]
#[unstable(feature = "fn_traits", issue = "29625")]
type Output;
/// This is called when the call operator is used.
#[unstable(feature = "core", issue = "27701")]
#[unstable(feature = "fn_traits", issue = "29625")]
extern "rust-call" fn call_once(self, args: Args) -> Self::Output;
}

View File

@ -61,72 +61,98 @@ use raw::Slice as RawSlice;
//
/// Extension methods for slices.
#[allow(missing_docs)] // docs in libcollections
#[doc(hidden)]
#[unstable(feature = "core_slice_ext",
reason = "stable interface provided by `impl [T]` in later crates",
issue = "27701")]
#[allow(missing_docs)] // documented elsewhere
pub trait SliceExt {
type Item;
#[stable(feature = "core", since = "1.6.0")]
fn split_at(&self, mid: usize) -> (&[Self::Item], &[Self::Item]);
#[stable(feature = "core", since = "1.6.0")]
fn iter(&self) -> Iter<Self::Item>;
#[stable(feature = "core", since = "1.6.0")]
fn split<P>(&self, pred: P) -> Split<Self::Item, P>
where P: FnMut(&Self::Item) -> bool;
#[stable(feature = "core", since = "1.6.0")]
fn splitn<P>(&self, n: usize, pred: P) -> SplitN<Self::Item, P>
where P: FnMut(&Self::Item) -> bool;
#[stable(feature = "core", since = "1.6.0")]
fn rsplitn<P>(&self, n: usize, pred: P) -> RSplitN<Self::Item, P>
where P: FnMut(&Self::Item) -> bool;
#[stable(feature = "core", since = "1.6.0")]
fn windows(&self, size: usize) -> Windows<Self::Item>;
#[stable(feature = "core", since = "1.6.0")]
fn chunks(&self, size: usize) -> Chunks<Self::Item>;
#[stable(feature = "core", since = "1.6.0")]
fn get(&self, index: usize) -> Option<&Self::Item>;
#[stable(feature = "core", since = "1.6.0")]
fn first(&self) -> Option<&Self::Item>;
fn tail(&self) -> &[Self::Item];
fn init(&self) -> &[Self::Item];
#[stable(feature = "core", since = "1.6.0")]
fn split_first(&self) -> Option<(&Self::Item, &[Self::Item])>;
#[stable(feature = "core", since = "1.6.0")]
fn split_last(&self) -> Option<(&Self::Item, &[Self::Item])>;
#[stable(feature = "core", since = "1.6.0")]
fn last(&self) -> Option<&Self::Item>;
#[stable(feature = "core", since = "1.6.0")]
unsafe fn get_unchecked(&self, index: usize) -> &Self::Item;
#[stable(feature = "core", since = "1.6.0")]
fn as_ptr(&self) -> *const Self::Item;
fn binary_search_by<F>(&self, f: F) -> Result<usize, usize> where
F: FnMut(&Self::Item) -> Ordering;
#[stable(feature = "core", since = "1.6.0")]
fn binary_search(&self, x: &Self::Item) -> Result<usize, usize>
where Self::Item: Ord;
#[stable(feature = "core", since = "1.6.0")]
fn binary_search_by<F>(&self, f: F) -> Result<usize, usize>
where F: FnMut(&Self::Item) -> Ordering;
#[stable(feature = "core", since = "1.6.0")]
fn len(&self) -> usize;
#[stable(feature = "core", since = "1.6.0")]
fn is_empty(&self) -> bool { self.len() == 0 }
#[stable(feature = "core", since = "1.6.0")]
fn get_mut(&mut self, index: usize) -> Option<&mut Self::Item>;
#[stable(feature = "core", since = "1.6.0")]
fn iter_mut(&mut self) -> IterMut<Self::Item>;
#[stable(feature = "core", since = "1.6.0")]
fn first_mut(&mut self) -> Option<&mut Self::Item>;
fn tail_mut(&mut self) -> &mut [Self::Item];
fn init_mut(&mut self) -> &mut [Self::Item];
#[stable(feature = "core", since = "1.6.0")]
fn split_first_mut(&mut self) -> Option<(&mut Self::Item, &mut [Self::Item])>;
#[stable(feature = "core", since = "1.6.0")]
fn split_last_mut(&mut self) -> Option<(&mut Self::Item, &mut [Self::Item])>;
#[stable(feature = "core", since = "1.6.0")]
fn last_mut(&mut self) -> Option<&mut Self::Item>;
#[stable(feature = "core", since = "1.6.0")]
fn split_mut<P>(&mut self, pred: P) -> SplitMut<Self::Item, P>
where P: FnMut(&Self::Item) -> bool;
#[stable(feature = "core", since = "1.6.0")]
fn splitn_mut<P>(&mut self, n: usize, pred: P) -> SplitNMut<Self::Item, P>
where P: FnMut(&Self::Item) -> bool;
#[stable(feature = "core", since = "1.6.0")]
fn rsplitn_mut<P>(&mut self, n: usize, pred: P) -> RSplitNMut<Self::Item, P>
where P: FnMut(&Self::Item) -> bool;
#[stable(feature = "core", since = "1.6.0")]
fn chunks_mut(&mut self, chunk_size: usize) -> ChunksMut<Self::Item>;
#[stable(feature = "core", since = "1.6.0")]
fn swap(&mut self, a: usize, b: usize);
#[stable(feature = "core", since = "1.6.0")]
fn split_at_mut(&mut self, mid: usize) -> (&mut [Self::Item], &mut [Self::Item]);
#[stable(feature = "core", since = "1.6.0")]
fn reverse(&mut self);
#[stable(feature = "core", since = "1.6.0")]
unsafe fn get_unchecked_mut(&mut self, index: usize) -> &mut Self::Item;
#[stable(feature = "core", since = "1.6.0")]
fn as_mut_ptr(&mut self) -> *mut Self::Item;
fn position_elem(&self, t: &Self::Item) -> Option<usize> where Self::Item: PartialEq;
fn rposition_elem(&self, t: &Self::Item) -> Option<usize> where Self::Item: PartialEq;
#[stable(feature = "core", since = "1.6.0")]
fn contains(&self, x: &Self::Item) -> bool where Self::Item: PartialEq;
#[stable(feature = "core", since = "1.6.0")]
fn starts_with(&self, needle: &[Self::Item]) -> bool where Self::Item: PartialEq;
#[stable(feature = "core", since = "1.6.0")]
fn ends_with(&self, needle: &[Self::Item]) -> bool where Self::Item: PartialEq;
fn binary_search(&self, x: &Self::Item) -> Result<usize, usize> where Self::Item: Ord;
fn next_permutation(&mut self) -> bool where Self::Item: Ord;
fn prev_permutation(&mut self) -> bool where Self::Item: Ord;
#[unstable(feature = "clone_from_slice", issue= "27750")]
fn clone_from_slice(&mut self, &[Self::Item]) -> usize where Self::Item: Clone;
}
@ -241,17 +267,11 @@ impl<T> SliceExt for [T] {
if self.is_empty() { None } else { Some(&self[0]) }
}
#[inline]
fn tail(&self) -> &[T] { &self[1..] }
#[inline]
fn split_first(&self) -> Option<(&T, &[T])> {
if self.is_empty() { None } else { Some((&self[0], &self[1..])) }
}
#[inline]
fn init(&self) -> &[T] { &self[..self.len() - 1] }
#[inline]
fn split_last(&self) -> Option<(&T, &[T])> {
let len = self.len();
@ -346,9 +366,6 @@ impl<T> SliceExt for [T] {
if self.is_empty() { None } else { Some(&mut self[0]) }
}
#[inline]
fn tail_mut(&mut self) -> &mut [T] { &mut self[1 ..] }
#[inline]
fn split_first_mut(&mut self) -> Option<(&mut T, &mut [T])> {
if self.is_empty() { None } else {
@ -357,12 +374,6 @@ impl<T> SliceExt for [T] {
}
}
#[inline]
fn init_mut(&mut self) -> &mut [T] {
let len = self.len();
&mut self[.. (len - 1)]
}
#[inline]
fn split_last_mut(&mut self) -> Option<(&mut T, &mut [T])> {
let len = self.len();
@ -444,16 +455,6 @@ impl<T> SliceExt for [T] {
self.repr().data as *mut T
}
#[inline]
fn position_elem(&self, x: &T) -> Option<usize> where T: PartialEq {
self.iter().position(|y| *x == *y)
}
#[inline]
fn rposition_elem(&self, t: &T) -> Option<usize> where T: PartialEq {
self.iter().rposition(|x| *x == *t)
}
#[inline]
fn contains(&self, x: &T) -> bool where T: PartialEq {
self.iter().any(|elt| *x == *elt)
@ -475,66 +476,6 @@ impl<T> SliceExt for [T] {
self.binary_search_by(|p| p.cmp(x))
}
fn next_permutation(&mut self) -> bool where T: Ord {
// These cases only have 1 permutation each, so we can't do anything.
if self.len() < 2 { return false; }
// Step 1: Identify the longest, rightmost weakly decreasing part of the vector
let mut i = self.len() - 1;
while i > 0 && self[i-1] >= self[i] {
i -= 1;
}
// If that is the entire vector, this is the last-ordered permutation.
if i == 0 {
return false;
}
// Step 2: Find the rightmost element larger than the pivot (i-1)
let mut j = self.len() - 1;
while j >= i && self[j] <= self[i-1] {
j -= 1;
}
// Step 3: Swap that element with the pivot
self.swap(j, i-1);
// Step 4: Reverse the (previously) weakly decreasing part
self[i..].reverse();
true
}
fn prev_permutation(&mut self) -> bool where T: Ord {
// These cases only have 1 permutation each, so we can't do anything.
if self.len() < 2 { return false; }
// Step 1: Identify the longest, rightmost weakly increasing part of the vector
let mut i = self.len() - 1;
while i > 0 && self[i-1] <= self[i] {
i -= 1;
}
// If that is the entire vector, this is the first-ordered permutation.
if i == 0 {
return false;
}
// Step 2: Reverse the weakly increasing part
self[i..].reverse();
// Step 3: Find the rightmost element equal to or bigger than the pivot (i-1)
let mut j = self.len() - 1;
while j >= i && self[j-1] < self[i-1] {
j -= 1;
}
// Step 4: Swap that element with the pivot
self.swap(i-1, j);
true
}
#[inline]
fn clone_from_slice(&mut self, src: &[T]) -> usize where T: Clone {
let min = cmp::min(self.len(), src.len());
@ -1514,6 +1455,9 @@ pub unsafe fn from_raw_parts_mut<'a, T>(p: *mut T, len: usize) -> &'a mut [T] {
/// Operations on `[u8]`.
#[unstable(feature = "slice_bytes", reason = "needs review",
issue = "27740")]
#[rustc_deprecated(reason = "unidiomatic functions not pulling their weight",
since = "1.6.0")]
#[allow(deprecated)]
pub mod bytes {
use ptr;
use slice::SliceExt;

View File

@ -1385,58 +1385,120 @@ pub trait StrExt {
// NB there are no docs here are they're all located on the StrExt trait in
// libcollections, not here.
#[stable(feature = "core", since = "1.6.0")]
fn contains<'a, P: Pattern<'a>>(&'a self, pat: P) -> bool;
fn contains_char<'a, P: Pattern<'a>>(&'a self, pat: P) -> bool;
#[stable(feature = "core", since = "1.6.0")]
fn chars(&self) -> Chars;
#[stable(feature = "core", since = "1.6.0")]
fn bytes(&self) -> Bytes;
#[stable(feature = "core", since = "1.6.0")]
fn char_indices(&self) -> CharIndices;
#[stable(feature = "core", since = "1.6.0")]
fn split<'a, P: Pattern<'a>>(&'a self, pat: P) -> Split<'a, P>;
#[stable(feature = "core", since = "1.6.0")]
fn rsplit<'a, P: Pattern<'a>>(&'a self, pat: P) -> RSplit<'a, P>
where P::Searcher: ReverseSearcher<'a>;
#[stable(feature = "core", since = "1.6.0")]
fn splitn<'a, P: Pattern<'a>>(&'a self, count: usize, pat: P) -> SplitN<'a, P>;
#[stable(feature = "core", since = "1.6.0")]
fn rsplitn<'a, P: Pattern<'a>>(&'a self, count: usize, pat: P) -> RSplitN<'a, P>
where P::Searcher: ReverseSearcher<'a>;
#[stable(feature = "core", since = "1.6.0")]
fn split_terminator<'a, P: Pattern<'a>>(&'a self, pat: P) -> SplitTerminator<'a, P>;
#[stable(feature = "core", since = "1.6.0")]
fn rsplit_terminator<'a, P: Pattern<'a>>(&'a self, pat: P) -> RSplitTerminator<'a, P>
where P::Searcher: ReverseSearcher<'a>;
#[stable(feature = "core", since = "1.6.0")]
fn matches<'a, P: Pattern<'a>>(&'a self, pat: P) -> Matches<'a, P>;
#[stable(feature = "core", since = "1.6.0")]
fn rmatches<'a, P: Pattern<'a>>(&'a self, pat: P) -> RMatches<'a, P>
where P::Searcher: ReverseSearcher<'a>;
#[stable(feature = "core", since = "1.6.0")]
fn match_indices<'a, P: Pattern<'a>>(&'a self, pat: P) -> MatchIndices<'a, P>;
#[stable(feature = "core", since = "1.6.0")]
fn rmatch_indices<'a, P: Pattern<'a>>(&'a self, pat: P) -> RMatchIndices<'a, P>
where P::Searcher: ReverseSearcher<'a>;
#[stable(feature = "core", since = "1.6.0")]
fn lines(&self) -> Lines;
#[stable(feature = "core", since = "1.6.0")]
#[rustc_deprecated(since = "1.6.0", reason = "use lines() instead now")]
#[allow(deprecated)]
fn lines_any(&self) -> LinesAny;
fn char_len(&self) -> usize;
fn slice_chars(&self, begin: usize, end: usize) -> &str;
#[stable(feature = "core", since = "1.6.0")]
unsafe fn slice_unchecked(&self, begin: usize, end: usize) -> &str;
#[stable(feature = "core", since = "1.6.0")]
unsafe fn slice_mut_unchecked(&mut self, begin: usize, end: usize) -> &mut str;
#[stable(feature = "core", since = "1.6.0")]
fn starts_with<'a, P: Pattern<'a>>(&'a self, pat: P) -> bool;
#[stable(feature = "core", since = "1.6.0")]
fn ends_with<'a, P: Pattern<'a>>(&'a self, pat: P) -> bool
where P::Searcher: ReverseSearcher<'a>;
#[stable(feature = "core", since = "1.6.0")]
fn trim_matches<'a, P: Pattern<'a>>(&'a self, pat: P) -> &'a str
where P::Searcher: DoubleEndedSearcher<'a>;
#[stable(feature = "core", since = "1.6.0")]
fn trim_left_matches<'a, P: Pattern<'a>>(&'a self, pat: P) -> &'a str;
#[stable(feature = "core", since = "1.6.0")]
fn trim_right_matches<'a, P: Pattern<'a>>(&'a self, pat: P) -> &'a str
where P::Searcher: ReverseSearcher<'a>;
#[unstable(feature = "str_char",
reason = "it is unclear whether this method pulls its weight \
with the existence of the char_indices iterator or \
this method may want to be replaced with checked \
slicing",
issue = "27754")]
fn is_char_boundary(&self, index: usize) -> bool;
#[unstable(feature = "str_char",
reason = "often replaced by char_indices, this method may \
be removed in favor of just char_at() or eventually \
removed altogether",
issue = "27754")]
fn char_range_at(&self, start: usize) -> CharRange;
#[unstable(feature = "str_char",
reason = "often replaced by char_indices, this method may \
be removed in favor of just char_at_reverse() or \
eventually removed altogether",
issue = "27754")]
fn char_range_at_reverse(&self, start: usize) -> CharRange;
#[unstable(feature = "str_char",
reason = "frequently replaced by the chars() iterator, this \
method may be removed or possibly renamed in the \
future; it is normally replaced by chars/char_indices \
iterators or by getting the first char from a \
subslice",
issue = "27754")]
fn char_at(&self, i: usize) -> char;
#[unstable(feature = "str_char",
reason = "see char_at for more details, but reverse semantics \
are also somewhat unclear, especially with which \
cases generate panics",
issue = "27754")]
fn char_at_reverse(&self, i: usize) -> char;
#[stable(feature = "core", since = "1.6.0")]
fn as_bytes(&self) -> &[u8];
#[stable(feature = "core", since = "1.6.0")]
fn find<'a, P: Pattern<'a>>(&'a self, pat: P) -> Option<usize>;
#[stable(feature = "core", since = "1.6.0")]
fn rfind<'a, P: Pattern<'a>>(&'a self, pat: P) -> Option<usize>
where P::Searcher: ReverseSearcher<'a>;
fn find_str<'a, P: Pattern<'a>>(&'a self, pat: P) -> Option<usize>;
#[stable(feature = "core", since = "1.6.0")]
fn split_at(&self, mid: usize) -> (&str, &str);
#[stable(feature = "core", since = "1.6.0")]
fn split_at_mut(&mut self, mid: usize) -> (&mut str, &mut str);
#[unstable(feature = "str_char",
reason = "awaiting conventions about shifting and slices and \
may not be warranted with the existence of the chars \
and/or char_indices iterators",
issue = "27754")]
fn slice_shift_char(&self) -> Option<(char, &str)>;
fn subslice_offset(&self, inner: &str) -> usize;
#[stable(feature = "core", since = "1.6.0")]
fn as_ptr(&self) -> *const u8;
#[stable(feature = "core", since = "1.6.0")]
fn len(&self) -> usize;
#[stable(feature = "core", since = "1.6.0")]
fn is_empty(&self) -> bool;
#[stable(feature = "core", since = "1.6.0")]
fn parse<T: FromStr>(&self) -> Result<T, T::Err>;
}
@ -1448,20 +1510,13 @@ fn slice_error_fail(s: &str, begin: usize, end: usize) -> ! {
begin, end, s);
}
#[unstable(feature = "core_str_ext",
reason = "stable interface provided by `impl str` in later crates",
issue = "27701")]
#[stable(feature = "core", since = "1.6.0")]
impl StrExt for str {
#[inline]
fn contains<'a, P: Pattern<'a>>(&'a self, pat: P) -> bool {
pat.is_contained_in(self)
}
#[inline]
fn contains_char<'a, P: Pattern<'a>>(&'a self, pat: P) -> bool {
pat.is_contained_in(self)
}
#[inline]
fn chars(&self) -> Chars {
Chars{iter: self.as_bytes().iter()}
@ -1559,32 +1614,6 @@ impl StrExt for str {
LinesAny(self.lines())
}
#[inline]
fn char_len(&self) -> usize { self.chars().count() }
fn slice_chars(&self, begin: usize, end: usize) -> &str {
assert!(begin <= end);
let mut count = 0;
let mut begin_byte = None;
let mut end_byte = None;
// This could be even more efficient by not decoding,
// only finding the char boundaries
for (idx, _) in self.char_indices() {
if count == begin { begin_byte = Some(idx); }
if count == end { end_byte = Some(idx); break; }
count += 1;
}
if begin_byte.is_none() && count == begin { begin_byte = Some(self.len()) }
if end_byte.is_none() && count == end { end_byte = Some(self.len()) }
match (begin_byte, end_byte) {
(None, _) => panic!("slice_chars: `begin` is beyond end of string"),
(_, None) => panic!("slice_chars: `end` is beyond end of string"),
(Some(a), Some(b)) => unsafe { self.slice_unchecked(a, b) }
}
}
#[inline]
unsafe fn slice_unchecked(&self, begin: usize, end: usize) -> &str {
mem::transmute(Slice {
@ -1774,17 +1803,6 @@ impl StrExt for str {
}
}
fn subslice_offset(&self, inner: &str) -> usize {
let a_start = self.as_ptr() as usize;
let a_end = a_start + self.len();
let b_start = inner.as_ptr() as usize;
let b_end = b_start + inner.len();
assert!(a_start <= b_start);
assert!(b_end <= a_end);
b_start - a_start
}
#[inline]
fn as_ptr(&self) -> *const u8 {
self.repr().data

View File

@ -31,6 +31,7 @@
#![feature(libc)]
#![feature(nonzero)]
#![feature(num_bits_bytes)]
#![feature(peekable_is_empty)]
#![feature(ptr_as_ref)]
#![feature(rand)]
#![feature(range_inclusive)]

View File

@ -174,7 +174,6 @@
#![feature(box_syntax)]
#![feature(const_fn)]
#![feature(iter_cmp)]
#![feature(staged_api)]
#![feature(static_mutex)]
@ -418,7 +417,7 @@ fn init() {
});
let max_level = {
let max = directives.iter().max_by(|d| d.level);
let max = directives.iter().max_by_key(|d| d.level);
max.map(|d| d.level).unwrap_or(DEFAULT_LOG_LEVEL)
};

View File

@ -32,13 +32,12 @@
issue = "27703")]
#![feature(core_float)]
#![feature(core_intrinsics)]
#![feature(core_slice_ext)]
#![feature(no_std)]
#![feature(num_bits_bytes)]
#![feature(staged_api)]
#![feature(step_by)]
#![feature(custom_attribute)]
#![allow(unused_attributes)]
#![cfg_attr(stage0, feature(no_std))]
#![cfg_attr(test, feature(test, rand, rustc_private, iter_order_deprecated))]

View File

@ -126,7 +126,7 @@
#![feature(rustc_private)]
#![feature(staged_api)]
#![feature(slice_bytes)]
#![feature(clone_from_slice)]
#![cfg_attr(test, feature(test))]
@ -241,7 +241,6 @@ pub mod reader {
use std::isize;
use std::mem::transmute;
use std::slice::bytes;
use serialize;
@ -482,7 +481,7 @@ pub mod reader {
// of the page and segfault.
let mut b = [0; 8];
bytes::copy_memory(&d.data[d.end-8..d.end], &mut b);
b.clone_from_slice(&d.data[d.end-8..d.end]);
let data = unsafe { (*(b.as_ptr() as *const u64)).to_be() };
let len = d.end - d.start;
if len < 8 {
@ -872,7 +871,6 @@ pub mod writer {
use std::mem;
use std::io::prelude::*;
use std::io::{self, SeekFrom, Cursor};
use std::slice::bytes;
use super::{ EsVec, EsMap, EsEnum, EsSub8, EsSub32, EsVecElt, EsMapKey,
EsU64, EsU32, EsU16, EsU8, EsI64, EsI32, EsI16, EsI8,
@ -962,7 +960,7 @@ pub mod writer {
{
let last_size_pos = last_size_pos as usize;
let data = &self.writer.get_ref()[last_size_pos+4..cur_pos as usize];
bytes::copy_memory(data, &mut buf);
buf.clone_from_slice(data);
}
// overwrite the size and data and continue

View File

@ -872,7 +872,6 @@ You can build a free-standing crate by adding `#![no_std]` to the crate
attributes:
```
#![feature(no_std)]
#![no_std]
```

View File

@ -28,15 +28,13 @@
#![feature(associated_consts)]
#![feature(box_patterns)]
#![feature(box_syntax)]
#![feature(cell_extras)]
#![feature(clone_from_slice)]
#![feature(collections)]
#![feature(const_fn)]
#![feature(core)]
#![feature(duration_span)]
#![feature(enumset)]
#![feature(hashmap_hasher)]
#![feature(into_cow)]
#![feature(iter_cmp)]
#![feature(iter_arith)]
#![feature(libc)]
#![feature(nonzero)]
@ -48,9 +46,8 @@
#![feature(slice_patterns)]
#![feature(staged_api)]
#![feature(str_char)]
#![feature(vec_push_all)]
#![feature(time2)]
#![feature(wrapping)]
#![feature(cell_extras)]
#![cfg_attr(test, feature(test))]
#![allow(trivial_casts)]

View File

@ -980,8 +980,8 @@ pub fn specialize<'a>(cx: &MatchCheckCtxt, r: &[&'a Pat],
}
};
head.map(|mut head| {
head.push_all(&r[..col]);
head.push_all(&r[col + 1..]);
head.extend_from_slice(&r[..col]);
head.extend_from_slice(&r[col + 1..]);
head
})
}

View File

@ -255,7 +255,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for MarkSymbolVisitor<'a, 'tcx> {
// necessary for the pattern to match. Those construction sites
// can't be reached unless the variant is constructed elsewhere.
let len = self.ignore_variant_stack.len();
self.ignore_variant_stack.push_all(&*variants);
self.ignore_variant_stack.extend_from_slice(&*variants);
intravisit::walk_arm(self, arm);
self.ignore_variant_stack.truncate(len);
} else {

View File

@ -1523,7 +1523,7 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> {
parameters: new_parameters
};
let mut new_segs = Vec::new();
new_segs.push_all(path.segments.split_last().unwrap().1);
new_segs.extend_from_slice(path.segments.split_last().unwrap().1);
new_segs.push(new_seg);
hir::Path {
span: path.span,
@ -1831,7 +1831,7 @@ fn lifetimes_in_scope(tcx: &ty::ctxt,
Some(node) => match node {
ast_map::NodeItem(item) => match item.node {
hir::ItemFn(_, _, _, _, ref gen, _) => {
taken.push_all(&gen.lifetimes);
taken.extend_from_slice(&gen.lifetimes);
None
},
_ => None
@ -1839,7 +1839,7 @@ fn lifetimes_in_scope(tcx: &ty::ctxt,
ast_map::NodeImplItem(ii) => {
match ii.node {
hir::ImplItemKind::Method(ref sig, _) => {
taken.push_all(&sig.generics.lifetimes);
taken.extend_from_slice(&sig.generics.lifetimes);
Some(ii.id)
}
_ => None,
@ -1856,7 +1856,7 @@ fn lifetimes_in_scope(tcx: &ty::ctxt,
Some(node) => match node {
ast_map::NodeItem(item) => match item.node {
hir::ItemImpl(_, _, ref gen, _, _, _) => {
taken.push_all(&gen.lifetimes);
taken.extend_from_slice(&gen.lifetimes);
}
_ => ()
},

View File

@ -178,7 +178,7 @@ pub fn pat_contains_ref_binding(dm: &RefCell<DefMap>, pat: &hir::Pat) -> Option<
pub fn arm_contains_ref_binding(dm: &RefCell<DefMap>, arm: &hir::Arm) -> Option<hir::Mutability> {
arm.pats.iter()
.filter_map(|pat| pat_contains_ref_binding(dm, pat))
.max_by(|m| match *m {
.max_by_key(|m| match *m {
hir::MutMutable => 1,
hir::MutImmutable => 0,
})

View File

@ -630,7 +630,7 @@ impl RegionMaps {
}
*vec = Vec::with_capacity(64);
vec.push_all(buf);
vec.extend_from_slice(buf);
loop {
vec.push(scope);
match scope_map[scope.0 as usize].into_option() {

View File

@ -1185,7 +1185,8 @@ impl<'tcx> TyS<'tcx> {
}
TyTrait(ref obj) => {
let mut v = vec![obj.bounds.region_bound];
v.push_all(obj.principal.skip_binder().substs.regions().as_slice());
v.extend_from_slice(obj.principal.skip_binder()
.substs.regions().as_slice());
v
}
TyEnum(_, substs) |

View File

@ -659,7 +659,7 @@ pub fn build_configuration(sess: &Session) -> ast::CrateConfig {
append_configuration(&mut user_cfg, InternedString::new("test"))
}
let mut v = user_cfg.into_iter().collect::<Vec<_>>();
v.push_all(&default_cfg[..]);
v.extend_from_slice(&default_cfg[..]);
v
}
@ -818,7 +818,7 @@ pub fn rustc_short_optgroups() -> Vec<RustcOptGroup> {
/// long-term interface for rustc.
pub fn rustc_optgroups() -> Vec<RustcOptGroup> {
let mut opts = rustc_short_optgroups();
opts.push_all(&[
opts.extend_from_slice(&[
opt::multi("", "extern", "Specify where an external rust library is \
located",
"NAME=PATH"),

View File

@ -18,7 +18,7 @@ use std::fmt::Debug;
use std::hash::Hash;
use std::iter::repeat;
use std::path::Path;
use std::time::Duration;
use std::time::Instant;
use rustc_front::hir;
use rustc_front::intravisit;
@ -44,15 +44,9 @@ pub fn time<T, F>(do_it: bool, what: &str, f: F) -> T where
r
});
let mut rv = None;
let dur = {
let ref mut rvp = rv;
Duration::span(move || {
*rvp = Some(f())
})
};
let rv = rv.unwrap();
let start = Instant::now();
let rv = f();
let dur = start.elapsed();
// Hack up our own formatting for the duration to make it easier for scripts
// to parse (always use the same number of decimal places and the same unit).

View File

@ -36,10 +36,9 @@
#![feature(libc)]
#![feature(rand)]
#![feature(rustc_private)]
#![feature(slice_bytes)]
#![feature(clone_from_slice)]
#![feature(staged_api)]
#![feature(step_by)]
#![feature(vec_push_all)]
#![cfg_attr(test, feature(test, rand))]
extern crate syntax;

View File

@ -35,7 +35,7 @@ pub fn get_rpath_flags(config: &mut RPathConfig) -> Vec<String> {
let libs = config.used_crates.clone();
let libs = libs.into_iter().filter_map(|(_, l)| l).collect::<Vec<_>>();
let rpaths = get_rpaths(config, &libs[..]);
flags.push_all(&rpaths_to_flags(&rpaths[..]));
flags.extend_from_slice(&rpaths_to_flags(&rpaths[..]));
flags
}
@ -73,7 +73,7 @@ fn get_rpaths(config: &mut RPathConfig, libs: &[PathBuf]) -> Vec<String> {
log_rpaths("fallback", &fallback_rpaths[..]);
let mut rpaths = rel_rpaths;
rpaths.push_all(&fallback_rpaths[..]);
rpaths.extend_from_slice(&fallback_rpaths[..]);
// Remove duplicates
let rpaths = minimize_rpaths(&rpaths[..]);

View File

@ -12,7 +12,6 @@
//! use. This implementation is not intended for external use or for any use where security is
//! important.
use std::slice::bytes::{MutableByteVector, copy_memory};
use serialize::hex::ToHex;
/// Write a u32 into a vector, which must be 4 bytes long. The value is written in big-endian
@ -134,16 +133,14 @@ impl FixedBuffer for FixedBuffer64 {
if self.buffer_idx != 0 {
let buffer_remaining = size - self.buffer_idx;
if input.len() >= buffer_remaining {
copy_memory(
&input[..buffer_remaining],
&mut self.buffer[self.buffer_idx..size]);
self.buffer[self.buffer_idx..size]
.clone_from_slice(&input[..buffer_remaining]);
self.buffer_idx = 0;
func(&self.buffer);
i += buffer_remaining;
} else {
copy_memory(
input,
&mut self.buffer[self.buffer_idx..self.buffer_idx + input.len()]);
self.buffer[self.buffer_idx..self.buffer_idx + input.len()]
.clone_from_slice(input);
self.buffer_idx += input.len();
return;
}
@ -160,9 +157,7 @@ impl FixedBuffer for FixedBuffer64 {
// data left in the input vector will be less than the buffer size and the buffer will
// be empty.
let input_remaining = input.len() - i;
copy_memory(
&input[i..],
&mut self.buffer[..input_remaining]);
self.buffer[..input_remaining].clone_from_slice(&input[i..]);
self.buffer_idx += input_remaining;
}
@ -172,7 +167,9 @@ impl FixedBuffer for FixedBuffer64 {
fn zero_until(&mut self, idx: usize) {
assert!(idx >= self.buffer_idx);
self.buffer[self.buffer_idx..idx].set_memory(0);
for slot in self.buffer[self.buffer_idx..idx].iter_mut() {
*slot = 0;
}
self.buffer_idx = idx;
}

View File

@ -16,7 +16,7 @@
#![feature(staged_api)]
#![cfg_attr(stage0, staged_api)]
#![crate_type = "rlib"]
#![feature(no_std)]
#![cfg_attr(stage0, feature(no_std))]
#![no_std]
#![unstable(feature = "rustc_private", issue = "27812")]

View File

@ -32,7 +32,6 @@
#![feature(rustc_private)]
#![feature(set_stdio)]
#![feature(staged_api)]
#![feature(vec_push_all)]
#![feature(raw)] // remove after snapshot
extern crate arena;
@ -932,12 +931,12 @@ pub fn diagnostics_registry() -> diagnostics::registry::Registry {
use syntax::diagnostics::registry::Registry;
let mut all_errors = Vec::new();
all_errors.push_all(&rustc::DIAGNOSTICS);
all_errors.push_all(&rustc_typeck::DIAGNOSTICS);
all_errors.push_all(&rustc_borrowck::DIAGNOSTICS);
all_errors.push_all(&rustc_resolve::DIAGNOSTICS);
all_errors.push_all(&rustc_privacy::DIAGNOSTICS);
all_errors.push_all(&rustc_trans::DIAGNOSTICS);
all_errors.extend_from_slice(&rustc::DIAGNOSTICS);
all_errors.extend_from_slice(&rustc_typeck::DIAGNOSTICS);
all_errors.extend_from_slice(&rustc_borrowck::DIAGNOSTICS);
all_errors.extend_from_slice(&rustc_resolve::DIAGNOSTICS);
all_errors.extend_from_slice(&rustc_privacy::DIAGNOSTICS);
all_errors.extend_from_slice(&rustc_trans::DIAGNOSTICS);
Registry::new(&*all_errors)
}

View File

@ -32,7 +32,6 @@
#![feature(libc)]
#![feature(link_args)]
#![feature(staged_api)]
#![feature(vec_push_all)]
#![feature(linked_from)]
extern crate libc;
@ -2309,7 +2308,7 @@ pub unsafe extern "C" fn rust_llvm_string_write_impl(sr: RustStringRef,
let slice = slice::from_raw_parts(ptr as *const u8, size as usize);
let sr = sr as RustStringRepr;
(*sr).borrow_mut().push_all(slice);
(*sr).borrow_mut().extend_from_slice(slice);
}
pub fn build_string<F>(f: F) -> Option<String> where F: FnOnce(RustStringRef){

View File

@ -122,8 +122,8 @@ impl<'tcx> CrateStore<'tcx> for cstore::CStore {
cdata.with_local_path(|cpath| {
let mut r = Vec::with_capacity(cpath.len() + path.len());
r.push_all(cpath);
r.push_all(&path);
r.extend_from_slice(cpath);
r.extend_from_slice(&path);
r
})
}
@ -135,7 +135,7 @@ impl<'tcx> CrateStore<'tcx> for cstore::CStore {
let mut r = Vec::with_capacity(path.len() + 1);
let crate_name = hir_map::PathMod(token::intern(&cdata.name));
r.push(crate_name);
r.push_all(&path);
r.extend_from_slice(&path);
r
}

View File

@ -19,13 +19,12 @@
html_root_url = "https://doc.rust-lang.org/nightly/")]
#![feature(box_patterns)]
#![feature(duration_span)]
#![feature(enumset)]
#![feature(quote)]
#![feature(staged_api)]
#![feature(vec_push_all)]
#![feature(rustc_diagnostic_macros)]
#![feature(rustc_private)]
#![feature(staged_api)]
#![feature(time2)]
#[macro_use] extern crate log;
#[macro_use] extern crate syntax;

View File

@ -237,7 +237,7 @@ use std::io;
use std::path::{Path, PathBuf};
use std::ptr;
use std::slice;
use std::time::Duration;
use std::time::Instant;
use flate;
@ -728,12 +728,11 @@ impl ArchiveMetadata {
// Just a small wrapper to time how long reading metadata takes.
fn get_metadata_section(target: &Target, filename: &Path)
-> Result<MetadataBlob, String> {
let mut ret = None;
let dur = Duration::span(|| {
ret = Some(get_metadata_section_imp(target, filename));
});
info!("reading {:?} => {:?}", filename.file_name().unwrap(), dur);
ret.unwrap()
let start = Instant::now();
let ret = get_metadata_section_imp(target, filename);
info!("reading {:?} => {:?}", filename.file_name().unwrap(),
start.elapsed());
return ret
}
fn get_metadata_section_imp(target: &Target, filename: &Path)

View File

@ -280,7 +280,7 @@ impl<'a,'tcx> TyDecoder<'a,'tcx> {
let mut result = String::new();
while self.peek() != term {
unsafe {
result.as_mut_vec().push_all(&[self.next_byte()])
result.as_mut_vec().extend_from_slice(&[self.next_byte()])
}
}
self.next();

View File

@ -907,7 +907,7 @@ fn link_natively(sess: &Session, dylib: bool,
prog.status));
sess.note(&format!("{:?}", &cmd));
let mut output = prog.stderr.clone();
output.push_all(&prog.stdout);
output.extend_from_slice(&prog.stdout);
sess.note(&*escape_string(&output[..]));
sess.abort_if_errors();
}

View File

@ -925,7 +925,7 @@ pub fn run_assembler(sess: &Session, outputs: &OutputFilenames) {
prog.status));
sess.note(&format!("{:?}", &cmd));
let mut note = prog.stderr.clone();
note.push_all(&prog.stdout);
note.extend_from_slice(&prog.stdout);
sess.note(str::from_utf8(&note[..]).unwrap());
sess.abort_if_errors();
}

View File

@ -30,7 +30,6 @@
#![feature(const_fn)]
#![feature(custom_attribute)]
#![allow(unused_attributes)]
#![feature(iter_cmp)]
#![feature(iter_arith)]
#![feature(libc)]
#![feature(path_relative_from)]
@ -40,7 +39,6 @@
#![feature(slice_patterns)]
#![feature(staged_api)]
#![feature(unicode)]
#![feature(vec_push_all)]
#![allow(trivial_casts)]

View File

@ -559,7 +559,7 @@ fn enter_default<'a, 'p, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
enter_match(bcx, dm, m, col, val, |pats| {
if pat_is_binding_or_wild(&dm.borrow(), &*pats[col]) {
let mut r = pats[..col].to_vec();
r.push_all(&pats[col + 1..]);
r.extend_from_slice(&pats[col + 1..]);
Some(r)
} else {
None
@ -877,7 +877,7 @@ fn pick_column_to_specialize(def_map: &RefCell<DefMap>, m: &[Match]) -> Option<u
(0..m[0].pats.len())
.filter(column_contains_any_nonwild_patterns)
.map(|col| (col, column_score(m, col)))
.max_by(|&(_, score)| score)
.max_by_key(|&(_, score)| score)
.map(|(col, _)| col)
}
@ -1167,7 +1167,7 @@ fn compile_submatch_continue<'a, 'p, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
let dm = &tcx.def_map;
let mut vals_left = vals[0..col].to_vec();
vals_left.push_all(&vals[col + 1..]);
vals_left.extend_from_slice(&vals[col + 1..]);
let ccx = bcx.fcx.ccx;
// Find a real id (we're adding placeholder wildcard patterns, but
@ -1241,7 +1241,7 @@ fn compile_submatch_continue<'a, 'p, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
let mut vals: Vec<_> = field_vals.into_iter()
.map(|v|MatchInput::from_val(v))
.collect();
vals.push_all(&vals_left);
vals.extend_from_slice(&vals_left);
compile_submatch(bcx, &pats, &vals, chk, has_genuine_default);
return;
}
@ -1401,7 +1401,7 @@ fn compile_submatch_continue<'a, 'p, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
let mut opt_vals: Vec<_> = unpacked.into_iter()
.map(|v|MatchInput::from_val(v))
.collect();
opt_vals.push_all(&vals_left[..]);
opt_vals.extend_from_slice(&vals_left[..]);
compile_submatch(opt_cx,
&opt_ms[..],
&opt_vals[..],

View File

@ -346,7 +346,7 @@ fn represent_type_uncached<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
// Use the minimum integer type we figured out above
let fields : Vec<_> = cases.iter().map(|c| {
let mut ftys = vec!(ty_of_inttype(cx.tcx(), min_ity));
ftys.push_all(&c.tys);
ftys.extend_from_slice(&c.tys);
if dtor { ftys.push(cx.tcx().dtor_type()); }
mk_struct(cx, &ftys, false, t)
}).collect();
@ -399,7 +399,7 @@ fn represent_type_uncached<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
let fields : Vec<_> = cases.iter().map(|c| {
let mut ftys = vec!(ty_of_inttype(cx.tcx(), ity));
ftys.push_all(&c.tys);
ftys.extend_from_slice(&c.tys);
if dtor { ftys.push(cx.tcx().dtor_type()); }
mk_struct(cx, &ftys[..], false, t)
}).collect();
@ -444,7 +444,7 @@ fn find_discr_field_candidate<'tcx>(tcx: &ty::ctxt<'tcx>,
let field_ty = monomorphize::field_ty(tcx, substs, &nonzero_fields[0]);
match field_ty.sty {
ty::TyRawPtr(ty::TypeAndMut { ty, .. }) if !type_is_sized(tcx, ty) => {
path.push_all(&[0, FAT_PTR_ADDR]);
path.extend_from_slice(&[0, FAT_PTR_ADDR]);
Some(path)
},
ty::TyRawPtr(..) | ty::TyInt(..) | ty::TyUint(..) => {
@ -1212,9 +1212,9 @@ pub fn trans_const<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, r: &Repr<'tcx>, discr
let (max_sz, _) = union_size_and_align(&cases[..]);
let lldiscr = C_integral(ll_inttype(ccx, ity), discr as u64, true);
let mut f = vec![lldiscr];
f.push_all(vals);
f.extend_from_slice(vals);
let mut contents = build_const_struct(ccx, case, &f[..]);
contents.push_all(&[padding(ccx, max_sz - case.size)]);
contents.extend_from_slice(&[padding(ccx, max_sz - case.size)]);
C_struct(ccx, &contents[..], false)
}
Univariant(ref st, _dro) => {

View File

@ -71,7 +71,7 @@ pub fn trans_inline_asm<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, ia: &ast::InlineAsm)
callee::DontAutorefArg,
&mut inputs);
}
inputs.push_all(&ext_inputs[..]);
inputs.extend_from_slice(&ext_inputs[..]);
// no failure occurred preparing operands, no need to cleanup
fcx.pop_custom_cleanup_scope(temp_scope);

View File

@ -156,7 +156,7 @@ pub fn from_fn_type<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, fn_type: ty::Ty<'tcx
match fn_sig.inputs[0].sty {
ty::TyTuple(ref inputs) => {
let mut full_inputs = vec![env_ty.expect("Missing closure environment")];
full_inputs.push_all(inputs);
full_inputs.extend_from_slice(inputs);
full_inputs
}
_ => ccx.sess().bug("expected tuple'd inputs")
@ -167,7 +167,7 @@ pub fn from_fn_type<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, fn_type: ty::Ty<'tcx
match fn_sig.inputs[1].sty {
ty::TyTuple(ref t_in) => {
inputs.push_all(&t_in[..]);
inputs.extend_from_slice(&t_in[..]);
inputs
}
_ => ccx.sess().bug("expected tuple'd inputs")

View File

@ -2772,7 +2772,7 @@ pub fn write_metadata(cx: &SharedCrateContext, krate: &hir::Crate, reachable: &N
cx.tcx(), cx.export_map(), cx.item_symbols(), cx.link_meta(), reachable,
krate);
let mut compressed = cstore.metadata_encoding_version().to_vec();
compressed.push_all(&flate::deflate_bytes(&metadata));
compressed.extend_from_slice(&flate::deflate_bytes(&metadata));
let llmeta = C_bytes_in_context(cx.metadata_llcx(), &compressed[..]);
let llconst = C_struct_in_context(cx.metadata_llcx(), &[llmeta], false);

View File

@ -1009,7 +1009,7 @@ pub fn trans_args<'a, 'blk, 'tcx>(cx: Block<'blk, 'tcx>,
}
}
ArgVals(vs) => {
llargs.push_all(vs);
llargs.extend_from_slice(vs);
}
}

View File

@ -376,7 +376,7 @@ impl<'b, 'tcx> SharedCrateContext<'b, 'tcx> {
self.local_ccxs
.iter()
.zip(0..self.local_ccxs.len())
.min_by(|&(local_ccx, _idx)| local_ccx.n_llvm_insns.get())
.min_by_key(|&(local_ccx, _idx)| local_ccx.n_llvm_insns.get())
.unwrap();
CrateContext {
shared: self,

View File

@ -1036,7 +1036,7 @@ fn ast_ty_to_trait_ref<'tcx>(this: &AstConv<'tcx>,
let hi = bounds.iter().map(|x| match *x {
hir::TraitTyParamBound(ref tr, _) => tr.span.hi,
hir::RegionTyParamBound(ref r) => r.span.hi,
}).max_by(|x| x.to_usize());
}).max_by_key(|x| x.to_usize());
let full_span = hi.map(|hi| Span {
lo: ty.span.lo,
hi: hi,

View File

@ -451,7 +451,7 @@ pub fn check_match<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
// supertype, as the "discriminant type" (issue #23116).
let contains_ref_bindings = arms.iter()
.filter_map(|a| tcx.arm_contains_ref_binding(a))
.max_by(|m| match *m {
.max_by_key(|m| match *m {
hir::MutMutable => 1,
hir::MutImmutable => 0,
});

View File

@ -1733,7 +1733,7 @@ fn projection_declared_bounds<'a, 'tcx>(rcx: &Rcx<'a,'tcx>,
let mut declared_bounds =
declared_generic_bounds_from_env(rcx, GenericKind::Projection(projection_ty));
declared_bounds.push_all(
declared_bounds.extend_from_slice(
&declared_projection_bounds_from_trait(rcx, span, projection_ty));
declared_bounds

View File

@ -77,14 +77,11 @@ This API is completely unstable and subject to change.
#![feature(box_patterns)]
#![feature(box_syntax)]
#![feature(drain)]
#![feature(iter_cmp)]
#![feature(iter_arith)]
#![feature(quote)]
#![feature(rustc_diagnostic_macros)]
#![feature(rustc_private)]
#![feature(staged_api)]
#![feature(vec_push_all)]
#![feature(cell_extras)]
#[macro_use] extern crate log;

View File

@ -35,12 +35,10 @@
#![no_std]
#![cfg_attr(stage0, feature(rustc_attrs))]
#![cfg_attr(stage0, feature(no_std))]
#![cfg_attr(stage0, allow(unused_attributes))]
#![feature(core_char_ext)]
#![feature(core_slice_ext)]
#![feature(core_str_ext)]
#![feature(lang_items)]
#![feature(no_std)]
#![feature(staged_api)]
mod tables;

View File

@ -18,7 +18,6 @@ pub const UNICODE_VERSION: (u64, u64, u64) = (8, 0, 0);
fn bsearch_range_table(c: char, r: &'static [(char,char)]) -> bool {
use core::cmp::Ordering::{Equal, Less, Greater};
use core::slice::SliceExt;
r.binary_search_by(|&(lo,hi)| {
if lo <= c && c <= hi { Equal }
else if hi < c { Less }
@ -1190,7 +1189,6 @@ pub mod property {
pub mod conversions {
use core::cmp::Ordering::{Equal, Less, Greater};
use core::slice::SliceExt;
use core::option::Option;
use core::option::Option::{Some, None};
use core::result::Result::{Ok, Err};

View File

@ -31,7 +31,6 @@
#![feature(staged_api)]
#![feature(test)]
#![feature(unicode)]
#![feature(vec_push_all)]
extern crate arena;
extern crate getopts;

View File

@ -346,7 +346,7 @@ pub fn unindent(s: &str) -> String {
if !lines.is_empty() {
let mut unindented = vec![ lines[0].trim().to_string() ];
unindented.push_all(&lines[1..].iter().map(|&line| {
unindented.extend_from_slice(&lines[1..].iter().map(|&line| {
if line.chars().all(|c| c.is_whitespace()) {
line.to_string()
} else {

View File

@ -986,8 +986,6 @@ impl<K, V, S> HashMap<K, V, S>
/// # Examples
///
/// ```
/// #![feature(drain)]
///
/// use std::collections::HashMap;
///
/// let mut a = HashMap::new();
@ -1002,9 +1000,7 @@ impl<K, V, S> HashMap<K, V, S>
/// assert!(a.is_empty());
/// ```
#[inline]
#[unstable(feature = "drain",
reason = "matches collection reform specification, waiting for dust to settle",
issue = "27711")]
#[stable(feature = "drain", since = "1.6.0")]
pub fn drain(&mut self) -> Drain<K, V> {
fn last_two<A, B, C>((_, b, c): (A, B, C)) -> (B, C) { (b, c) }
let last_two: fn((SafeHash, K, V)) -> (K, V) = last_two; // coerce to fn pointer
@ -1327,9 +1323,7 @@ impl<'a, K, V> Clone for Values<'a, K, V> {
}
/// HashMap drain iterator.
#[unstable(feature = "drain",
reason = "matches collection reform specification, waiting for dust to settle",
issue = "27711")]
#[stable(feature = "drain", since = "1.6.0")]
pub struct Drain<'a, K: 'a, V: 'a> {
inner: iter::Map<table::Drain<'a, K, V>, fn((SafeHash, K, V)) -> (K, V)>
}

View File

@ -413,9 +413,7 @@ impl<T, S> HashSet<T, S>
/// Clears the set, returning all elements in an iterator.
#[inline]
#[unstable(feature = "drain",
reason = "matches collection reform specification, waiting for dust to settle",
issue = "27711")]
#[stable(feature = "drain", since = "1.6.0")]
pub fn drain(&mut self) -> Drain<T> {
fn first<A, B>((a, _): (A, B)) -> A { a }
let first: fn((T, ())) -> T = first; // coerce to fn pointer

View File

@ -72,6 +72,8 @@ impl OsString {
/// On Windows system, only UTF-8 byte sequences will successfully
/// convert; non UTF-8 data will produce `None`.
#[unstable(feature = "convert", reason = "recently added", issue = "27704")]
#[rustc_deprecated(reason = "RFC was closed, hides subtle Windows semantics",
since = "1.6.0")]
pub fn from_bytes<B>(bytes: B) -> Option<OsString> where B: Into<Vec<u8>> {
Self::_from_bytes(bytes.into())
}
@ -256,6 +258,8 @@ impl OsStr {
/// valid unicode, in which case it produces UTF-8-encoded
/// data. This may entail checking validity.
#[unstable(feature = "convert", reason = "recently added", issue = "27704")]
#[rustc_deprecated(reason = "RFC was closed, hides subtle Windows semantics",
since = "1.6.0")]
pub fn to_bytes(&self) -> Option<&[u8]> {
if cfg!(windows) {
self.to_str().map(|s| s.as_bytes())
@ -272,6 +276,9 @@ impl OsStr {
/// `self.to_bytes()`, and inherits the platform behavior of the
/// `to_bytes` method.
#[unstable(feature = "convert", reason = "recently added", issue = "27704")]
#[rustc_deprecated(reason = "RFC was closed, hides subtle Windows semantics",
since = "1.6.0")]
#[allow(deprecated)]
pub fn to_cstring(&self) -> Option<CString> {
self.to_bytes().and_then(|b| CString::new(b).ok())
}

View File

@ -91,6 +91,8 @@ pub struct DirEntry(fs_imp::DirEntry);
may change and this may end up accounting for files such \
as symlinks differently",
issue = "27707")]
#[rustc_deprecated(reason = "superceded by the walkdir crate",
since = "1.6.0")]
pub struct WalkDir {
cur: Option<ReadDir>,
stack: Vec<io::Result<ReadDir>>,
@ -156,8 +158,7 @@ pub struct FileType(fs_imp::FileType);
/// A builder used to create directories in various manners.
///
/// This builder also supports platform-specific options.
#[unstable(feature = "dir_builder", reason = "recently added API",
issue = "27710")]
#[stable(feature = "dir_builder", since = "1.6.0")]
pub struct DirBuilder {
inner: fs_imp::DirBuilder,
recursive: bool,
@ -1132,16 +1133,23 @@ pub fn read_dir<P: AsRef<Path>>(path: P) -> io::Result<ReadDir> {
may change and this may end up accounting for files such \
as symlinks differently",
issue = "27707")]
#[rustc_deprecated(reason = "superceded by the walkdir crate",
since = "1.6.0")]
#[allow(deprecated)]
pub fn walk_dir<P: AsRef<Path>>(path: P) -> io::Result<WalkDir> {
_walk_dir(path.as_ref())
}
#[allow(deprecated)]
fn _walk_dir(path: &Path) -> io::Result<WalkDir> {
let start = try!(read_dir(path));
Ok(WalkDir { cur: Some(start), stack: Vec::new() })
}
#[unstable(feature = "fs_walk", issue = "27707")]
#[rustc_deprecated(reason = "superceded by the walkdir crate",
since = "1.6.0")]
#[allow(deprecated)]
impl Iterator for WalkDir {
type Item = io::Result<DirEntry>;
@ -1275,11 +1283,10 @@ pub fn set_permissions<P: AsRef<Path>>(path: P, perm: Permissions)
fs_imp::set_perm(path.as_ref(), perm.0)
}
#[unstable(feature = "dir_builder", reason = "recently added API",
issue = "27710")]
impl DirBuilder {
/// Creates a new set of options with default mode/security settings for all
/// platforms and also non-recursive.
#[stable(feature = "dir_builder", since = "1.6.0")]
pub fn new() -> DirBuilder {
DirBuilder {
inner: fs_imp::DirBuilder::new(),
@ -1292,6 +1299,7 @@ impl DirBuilder {
/// permissions settings.
///
/// This option defaults to `false`
#[stable(feature = "dir_builder", since = "1.6.0")]
pub fn recursive(&mut self, recursive: bool) -> &mut Self {
self.recursive = recursive;
self
@ -1303,7 +1311,6 @@ impl DirBuilder {
/// # Examples
///
/// ```no_run
/// #![feature(dir_builder)]
/// use std::fs::{self, DirBuilder};
///
/// let path = "/tmp/foo/bar/baz";
@ -1313,6 +1320,7 @@ impl DirBuilder {
///
/// assert!(fs::metadata(path).unwrap().is_dir());
/// ```
#[stable(feature = "dir_builder", since = "1.6.0")]
pub fn create<P: AsRef<Path>>(&self, path: P) -> io::Result<()> {
self._create(path.as_ref())
}

View File

@ -13,7 +13,6 @@ use io::prelude::*;
use cmp;
use io::{self, SeekFrom, Error, ErrorKind};
use slice;
/// A `Cursor` wraps another type and provides it with a
/// [`Seek`](trait.Seek.html) implementation.
@ -255,8 +254,8 @@ impl Write for Cursor<Vec<u8>> {
// there (left), and what will be appended on the end (right)
let space = self.inner.len() - pos as usize;
let (left, right) = buf.split_at(cmp::min(space, buf.len()));
slice::bytes::copy_memory(left, &mut self.inner[(pos as usize)..]);
self.inner.push_all(right);
self.inner[(pos as usize)..].clone_from_slice(left);
self.inner.extend_from_slice(right);
// Bump us forward
self.set_position(pos + buf.len() as u64);

View File

@ -79,6 +79,7 @@ struct Custom {
/// exhaustively match against it.
#[derive(Copy, PartialEq, Eq, Clone, Debug)]
#[stable(feature = "rust1", since = "1.0.0")]
#[allow(deprecated)]
pub enum ErrorKind {
/// An entity was not found, often a file.
#[stable(feature = "rust1", since = "1.0.0")]
@ -155,9 +156,20 @@ pub enum ErrorKind {
/// This typically means that an operation could only succeed if it read a
/// particular number of bytes but only a smaller number of bytes could be
/// read.
#[unstable(feature = "read_exact", reason = "recently added", issue = "27585")]
#[unstable(feature = "read_exact_old", reason = "recently added",
issue = "0")]
#[rustc_deprecated(since = "1.6.0", reason = "renamed to UnexpectedEof")]
UnexpectedEOF,
/// An error returned when an operation could not be completed because an
/// "end of file" was reached prematurely.
///
/// This typically means that an operation could only succeed if it read a
/// particular number of bytes but only a smaller number of bytes could be
/// read.
#[stable(feature = "read_exact", since = "1.6.0")]
UnexpectedEof,
/// Any I/O error not part of this list.
#[unstable(feature = "io_error_internals",
reason = "better expressed through extensible enums that this \

View File

@ -13,7 +13,6 @@ use cmp;
use io::{self, SeekFrom, Read, Write, Seek, BufRead, Error, ErrorKind};
use fmt;
use mem;
use slice;
use string::String;
use vec::Vec;
@ -157,7 +156,7 @@ impl<'a> Read for &'a [u8] {
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
let amt = cmp::min(buf.len(), self.len());
let (a, b) = self.split_at(amt);
slice::bytes::copy_memory(a, buf);
buf.clone_from_slice(a);
*self = b;
Ok(amt)
}
@ -165,10 +164,11 @@ impl<'a> Read for &'a [u8] {
#[inline]
fn read_exact(&mut self, buf: &mut [u8]) -> io::Result<()> {
if buf.len() > self.len() {
return Err(Error::new(ErrorKind::UnexpectedEOF, "failed to fill whole buffer"));
return Err(Error::new(ErrorKind::UnexpectedEof,
"failed to fill whole buffer"));
}
let (a, b) = self.split_at(buf.len());
slice::bytes::copy_memory(a, buf);
buf.clone_from_slice(a);
*self = b;
Ok(())
}
@ -189,7 +189,7 @@ impl<'a> Write for &'a mut [u8] {
fn write(&mut self, data: &[u8]) -> io::Result<usize> {
let amt = cmp::min(data.len(), self.len());
let (a, b) = mem::replace(self, &mut []).split_at_mut(amt);
slice::bytes::copy_memory(&data[..amt], a);
a.clone_from_slice(&data[..amt]);
*self = b;
Ok(amt)
}
@ -211,13 +211,13 @@ impl<'a> Write for &'a mut [u8] {
impl Write for Vec<u8> {
#[inline]
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
self.push_all(buf);
self.extend_from_slice(buf);
Ok(buf.len())
}
#[inline]
fn write_all(&mut self, buf: &[u8]) -> io::Result<()> {
self.push_all(buf);
self.extend_from_slice(buf);
Ok(())
}

View File

@ -593,7 +593,6 @@ pub trait Read {
/// [file]: ../std/fs/struct.File.html
///
/// ```
/// #![feature(read_exact)]
/// use std::io;
/// use std::io::prelude::*;
/// use std::fs::File;
@ -607,7 +606,7 @@ pub trait Read {
/// # Ok(())
/// # }
/// ```
#[unstable(feature = "read_exact", reason = "recently added", issue = "27585")]
#[stable(feature = "read_exact", since = "1.6.0")]
fn read_exact(&mut self, mut buf: &mut [u8]) -> Result<()> {
while !buf.is_empty() {
match self.read(buf) {
@ -618,7 +617,7 @@ pub trait Read {
}
}
if !buf.is_empty() {
Err(Error::new(ErrorKind::UnexpectedEOF,
Err(Error::new(ErrorKind::UnexpectedEof,
"failed to fill whole buffer"))
} else {
Ok(())
@ -838,6 +837,10 @@ pub trait Read {
of where errors happen is currently \
unclear and may change",
issue = "27802")]
#[rustc_deprecated(reason = "error handling semantics unclear and \
don't seem to have an ergonomic resolution",
since = "1.6.0")]
#[allow(deprecated)]
fn tee<W: Write>(self, out: W) -> Tee<Self, W> where Self: Sized {
Tee { reader: self, writer: out }
}
@ -1101,6 +1104,10 @@ pub trait Write {
of where errors happen is currently \
unclear and may change",
issue = "27802")]
#[rustc_deprecated(reason = "error handling semantics unclear and \
don't seem to have an ergonomic resolution",
since = "1.6.0")]
#[allow(deprecated)]
fn broadcast<W: Write>(self, other: W) -> Broadcast<Self, W>
where Self: Sized
{
@ -1189,11 +1196,11 @@ fn read_until<R: BufRead + ?Sized>(r: &mut R, delim: u8, buf: &mut Vec<u8>)
};
match available.iter().position(|x| *x == delim) {
Some(i) => {
buf.push_all(&available[..i + 1]);
buf.extend_from_slice(&available[..i + 1]);
(true, i + 1)
}
None => {
buf.push_all(available);
buf.extend_from_slice(available);
(false, available.len())
}
}
@ -1484,6 +1491,9 @@ pub trait BufRead: Read {
/// [broadcast]: trait.Write.html#method.broadcast
#[unstable(feature = "io", reason = "awaiting stability of Write::broadcast",
issue = "27802")]
#[rustc_deprecated(reason = "error handling semantics unclear and \
don't seem to have an ergonomic resolution",
since = "1.6.0")]
pub struct Broadcast<T, U> {
first: T,
second: U,
@ -1491,6 +1501,10 @@ pub struct Broadcast<T, U> {
#[unstable(feature = "io", reason = "awaiting stability of Write::broadcast",
issue = "27802")]
#[rustc_deprecated(reason = "error handling semantics unclear and \
don't seem to have an ergonomic resolution",
since = "1.6.0")]
#[allow(deprecated)]
impl<T: Write, U: Write> Write for Broadcast<T, U> {
fn write(&mut self, data: &[u8]) -> Result<usize> {
let n = try!(self.first.write(data));
@ -1593,6 +1607,9 @@ impl<T: BufRead> BufRead for Take<T> {
/// [tee]: trait.Read.html#method.tee
#[unstable(feature = "io", reason = "awaiting stability of Read::tee",
issue = "27802")]
#[rustc_deprecated(reason = "error handling semantics unclear and \
don't seem to have an ergonomic resolution",
since = "1.6.0")]
pub struct Tee<R, W> {
reader: R,
writer: W,
@ -1600,6 +1617,10 @@ pub struct Tee<R, W> {
#[unstable(feature = "io", reason = "awaiting stability of Read::tee",
issue = "27802")]
#[rustc_deprecated(reason = "error handling semantics unclear and \
don't seem to have an ergonomic resolution",
since = "1.6.0")]
#[allow(deprecated)]
impl<R: Read, W: Write> Read for Tee<R, W> {
fn read(&mut self, buf: &mut [u8]) -> Result<usize> {
let n = try!(self.reader.read(buf));
@ -1907,7 +1928,7 @@ mod tests {
let mut c = Cursor::new(&b""[..]);
assert_eq!(c.read_exact(&mut buf).unwrap_err().kind(),
io::ErrorKind::UnexpectedEOF);
io::ErrorKind::UnexpectedEof);
let mut c = Cursor::new(&b"123"[..]).chain(Cursor::new(&b"456789"[..]));
c.read_exact(&mut buf).unwrap();
@ -1915,7 +1936,7 @@ mod tests {
c.read_exact(&mut buf).unwrap();
assert_eq!(&buf, b"5678");
assert_eq!(c.read_exact(&mut buf).unwrap_err().kind(),
io::ErrorKind::UnexpectedEOF);
io::ErrorKind::UnexpectedEof);
}
#[test]
@ -1924,11 +1945,11 @@ mod tests {
let mut c = &b""[..];
assert_eq!(c.read_exact(&mut buf).unwrap_err().kind(),
io::ErrorKind::UnexpectedEOF);
io::ErrorKind::UnexpectedEof);
let mut c = &b"123"[..];
assert_eq!(c.read_exact(&mut buf).unwrap_err().kind(),
io::ErrorKind::UnexpectedEOF);
io::ErrorKind::UnexpectedEof);
// make sure the optimized (early returning) method is being used
assert_eq!(&buf, &[0; 4]);

View File

@ -217,6 +217,7 @@
#![cfg_attr(stage0, allow(improper_ctypes))]
#![cfg_attr(stage0, feature(rustc_attrs))]
#![cfg_attr(stage0, feature(no_std))]
#![cfg_attr(stage0, allow(unused_attributes))]
#![feature(alloc)]
#![feature(allow_internal_unstable)]
@ -230,12 +231,10 @@
#![feature(collections)]
#![feature(collections_bound)]
#![feature(const_fn)]
#![feature(core)]
#![feature(core_float)]
#![feature(core_intrinsics)]
#![feature(core_simd)]
#![feature(decode_utf16)]
#![feature(drain)]
#![feature(drop_in_place)]
#![feature(dropck_parametricity)]
#![feature(float_extras)]
@ -249,7 +248,6 @@
#![feature(link_args)]
#![feature(linkage)]
#![feature(macro_reexport)]
#![feature(no_std)]
#![feature(oom)]
#![feature(optin_builtin_traits)]
#![feature(placement_in_syntax)]
@ -288,7 +286,7 @@
// imported by the compiler (via our #[no_std] attribute) In this case we just
// add a new crate name so we can attach the reexports to it.
#[macro_reexport(assert, assert_eq, debug_assert, debug_assert_eq,
unreachable, unimplemented, write, writeln)]
unreachable, unimplemented, write, writeln, try)]
extern crate core as __core;
#[macro_use]

View File

@ -120,46 +120,6 @@ macro_rules! println {
($fmt:expr, $($arg:tt)*) => (print!(concat!($fmt, "\n"), $($arg)*));
}
/// Helper macro for unwrapping `Result` values while returning early with an
/// error if the value of the expression is `Err`. Can only be used in
/// functions that return `Result` because of the early return of `Err` that
/// it provides.
///
/// # Examples
///
/// ```
/// use std::io;
/// use std::fs::File;
/// use std::io::prelude::*;
///
/// fn write_to_file_using_try() -> Result<(), io::Error> {
/// let mut file = try!(File::create("my_best_friends.txt"));
/// try!(file.write_all(b"This is a list of my best friends."));
/// println!("I wrote to the file");
/// Ok(())
/// }
/// // This is equivalent to:
/// fn write_to_file_using_match() -> Result<(), io::Error> {
/// let mut file = try!(File::create("my_best_friends.txt"));
/// match file.write_all(b"This is a list of my best friends.") {
/// Ok(_) => (),
/// Err(e) => return Err(e),
/// }
/// println!("I wrote to the file");
/// Ok(())
/// }
/// ```
#[macro_export]
#[stable(feature = "rust1", since = "1.0.0")]
macro_rules! try {
($expr:expr) => (match $expr {
$crate::result::Result::Ok(val) => val,
$crate::result::Result::Err(err) => {
return $crate::result::Result::Err($crate::convert::From::from(err))
}
})
}
/// A macro to select an event from a number of receivers.
///
/// This macro is used to wait for the first event to occur on a number of

View File

@ -14,7 +14,9 @@ use fmt;
use hash;
use io;
use mem;
use net::{lookup_host, ntoh, hton, IpAddr, Ipv4Addr, Ipv6Addr};
use net::{lookup_host, ntoh, hton, Ipv4Addr, Ipv6Addr};
#[allow(deprecated)]
use net::IpAddr;
use option;
use sys::net::netc as c;
use sys_common::{FromInner, AsInner, IntoInner};
@ -49,6 +51,9 @@ pub struct SocketAddrV6 { inner: c::sockaddr_in6 }
impl SocketAddr {
/// Creates a new socket address from the (ip, port) pair.
#[unstable(feature = "ip_addr", reason = "recent addition", issue = "27801")]
#[rustc_deprecated(reason = "ip type too small a type to pull its weight",
since = "1.6.0")]
#[allow(deprecated)]
pub fn new(ip: IpAddr, port: u16) -> SocketAddr {
match ip {
IpAddr::V4(a) => SocketAddr::V4(SocketAddrV4::new(a, port)),
@ -58,6 +63,9 @@ impl SocketAddr {
/// Returns the IP address associated with this socket address.
#[unstable(feature = "ip_addr", reason = "recent addition", issue = "27801")]
#[rustc_deprecated(reason = "too small a type to pull its weight",
since = "1.6.0")]
#[allow(deprecated)]
pub fn ip(&self) -> IpAddr {
match *self {
SocketAddr::V4(ref a) => IpAddr::V4(*a.ip()),
@ -351,6 +359,7 @@ impl ToSocketAddrs for SocketAddrV6 {
}
#[stable(feature = "rust1", since = "1.0.0")]
#[allow(deprecated)]
impl ToSocketAddrs for (IpAddr, u16) {
type Iter = option::IntoIter<SocketAddr>;
fn to_socket_addrs(&self) -> io::Result<option::IntoIter<SocketAddr>> {

View File

@ -25,7 +25,10 @@ use sys_common::{AsInner, FromInner};
/// An IP address, either an IPv4 or IPv6 address.
#[unstable(feature = "ip_addr", reason = "recent addition", issue = "27801")]
#[rustc_deprecated(reason = "too small a type to pull its weight",
since = "1.6.0")]
#[derive(Copy, Clone, Eq, PartialEq, Debug, Hash, PartialOrd, Ord)]
#[allow(deprecated)]
pub enum IpAddr {
/// Representation of an IPv4 address.
V4(Ipv4Addr),
@ -180,6 +183,7 @@ impl Ipv4Addr {
}
#[stable(feature = "rust1", since = "1.0.0")]
#[allow(deprecated)]
impl fmt::Display for IpAddr {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
match *self {

View File

@ -18,6 +18,7 @@ use io::{self, Error, ErrorKind};
use sys_common::net as net_imp;
#[stable(feature = "rust1", since = "1.0.0")]
#[allow(deprecated)]
pub use self::ip::{IpAddr, Ipv4Addr, Ipv6Addr, Ipv6MulticastScope};
#[stable(feature = "rust1", since = "1.0.0")]
pub use self::addr::{SocketAddr, SocketAddrV4, SocketAddrV6, ToSocketAddrs};
@ -136,6 +137,9 @@ pub fn lookup_host(host: &str) -> io::Result<LookupHost> {
/// cannot be resolved, it is returned in string format.
#[unstable(feature = "lookup_addr", reason = "recent addition",
issue = "27705")]
#[rustc_deprecated(reason = "ipaddr type is being deprecated",
since = "1.6.0")]
#[allow(deprecated)]
pub fn lookup_addr(addr: &IpAddr) -> io::Result<String> {
net_imp::lookup_addr(addr)
}

View File

@ -17,6 +17,7 @@ use prelude::v1::*;
use error::Error;
use fmt;
#[allow(deprecated)]
use net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6};
use str::FromStr;
@ -261,6 +262,7 @@ impl<'a> Parser<'a> {
self.read_atomically(|p| p.read_ipv6_addr_impl())
}
#[allow(deprecated)]
fn read_ip_addr(&mut self) -> Option<IpAddr> {
let ipv4_addr = |p: &mut Parser| p.read_ipv4_addr().map(IpAddr::V4);
let ipv6_addr = |p: &mut Parser| p.read_ipv6_addr().map(IpAddr::V6);
@ -306,6 +308,7 @@ impl<'a> Parser<'a> {
}
#[stable(feature = "rust1", since = "1.0.0")]
#[allow(deprecated)]
impl FromStr for IpAddr {
type Err = AddrParseError;
fn from_str(s: &str) -> Result<IpAddr, AddrParseError> {

View File

@ -131,6 +131,7 @@ impl f32 {
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)
}
@ -424,7 +425,7 @@ impl f32 {
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn is_sign_positive(self) -> bool { num::Float::is_positive(self) }
pub fn is_sign_positive(self) -> bool { num::Float::is_sign_positive(self) }
/// Returns `true` if `self`'s sign is negative, including `-0.0`
/// and `NEG_INFINITY`.
@ -443,7 +444,7 @@ impl f32 {
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn is_sign_negative(self) -> bool { num::Float::is_negative(self) }
pub fn is_sign_negative(self) -> bool { num::Float::is_sign_negative(self) }
/// Fused multiply-add. Computes `(self * a) + b` with only one rounding
/// error. This produces a more accurate result with better performance than

View File

@ -88,6 +88,7 @@ impl f64 {
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)
}
@ -352,12 +353,12 @@ impl f64 {
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn is_sign_positive(self) -> bool { num::Float::is_positive(self) }
pub fn is_sign_positive(self) -> bool { num::Float::is_sign_positive(self) }
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_deprecated(since = "1.0.0", reason = "renamed to is_sign_positive")]
#[inline]
pub fn is_positive(self) -> bool { num::Float::is_positive(self) }
pub fn is_positive(self) -> bool { num::Float::is_sign_positive(self) }
/// Returns `true` if `self`'s sign is negative, including `-0.0`
/// and `NEG_INFINITY`.
@ -377,12 +378,12 @@ impl f64 {
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn is_sign_negative(self) -> bool { num::Float::is_negative(self) }
pub fn is_sign_negative(self) -> bool { num::Float::is_sign_negative(self) }
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_deprecated(since = "1.0.0", reason = "renamed to is_sign_negative")]
#[inline]
pub fn is_negative(self) -> bool { num::Float::is_negative(self) }
pub fn is_negative(self) -> bool { num::Float::is_sign_negative(self) }
/// Fused multiply-add. Computes `(self * a) + b` with only one rounding
/// error. This produces a more accurate result with better performance than

View File

@ -777,6 +777,8 @@ impl<'a> Components<'a> {
/// Examine the next component without consuming it.
#[unstable(feature = "path_components_peek", issue = "27727")]
#[rustc_deprecated(reason = "use peekable() instead",
since = "1.6.0")]
pub fn peek(&self) -> Option<Component<'a>> {
self.clone().next()
}

View File

@ -254,7 +254,7 @@ impl<T: ?Sized> Mutex<T> {
///
/// If another user of this mutex panicked while holding the mutex, then
/// this call will return an error instead.
#[unstable(feature = "mutex_into_inner", reason = "recently added", issue = "28968")]
#[stable(feature = "mutex_into_inner", since = "1.6.0")]
pub fn into_inner(self) -> LockResult<T> where T: Sized {
// We know statically that there are no outstanding references to
// `self` so there's no need to lock the inner StaticMutex.
@ -284,7 +284,7 @@ impl<T: ?Sized> Mutex<T> {
///
/// If another user of this mutex panicked while holding the mutex, then
/// this call will return an error instead.
#[unstable(feature = "mutex_get_mut", reason = "recently added", issue = "28968")]
#[stable(feature = "mutex_get_mut", since = "1.6.0")]
pub fn get_mut(&mut self) -> LockResult<&mut T> {
// We know statically that there are no other references to `self`, so
// there's no need to lock the inner StaticMutex.

View File

@ -275,7 +275,7 @@ impl<T: ?Sized> RwLock<T> {
/// is poisoned whenever a writer panics while holding an exclusive lock. An
/// error will only be returned if the lock would have otherwise been
/// acquired.
#[unstable(feature = "rwlock_into_inner", reason = "recently added", issue = "28968")]
#[stable(feature = "rwlock_into_inner", since = "1.6.0")]
pub fn into_inner(self) -> LockResult<T> where T: Sized {
// We know statically that there are no outstanding references to
// `self` so there's no need to lock the inner StaticRwLock.
@ -307,7 +307,7 @@ impl<T: ?Sized> RwLock<T> {
/// is poisoned whenever a writer panics while holding an exclusive lock. An
/// error will only be returned if the lock would have otherwise been
/// acquired.
#[unstable(feature = "rwlock_get_mut", reason = "recently added", issue = "28968")]
#[stable(feature = "rwlock_get_mut", since = "1.6.0")]
pub fn get_mut(&mut self) -> LockResult<&mut T> {
// We know statically that there are no other references to `self`, so
// there's no need to lock the inner StaticRwLock.

View File

@ -134,9 +134,9 @@ pub fn print(w: &mut Write, idx: isize, addr: *mut libc::c_void,
} else {
None
};
let filename = match selfname.as_ref().and_then(|s| s.as_os_str().to_bytes()) {
let filename = match selfname.as_ref().and_then(|s| s.to_str()) {
Some(path) => {
let bytes = path;
let bytes = path.as_bytes();
if bytes.len() < LAST_FILENAME.len() {
let i = bytes.iter();
for (slot, val) in LAST_FILENAME.iter_mut().zip(i) {

View File

@ -15,6 +15,7 @@ use fmt;
use io::{self, Error, ErrorKind};
use libc::{c_int, c_char, c_void};
use mem;
#[allow(deprecated)]
use net::{SocketAddr, Shutdown, IpAddr};
use ptr;
use str::from_utf8;
@ -129,6 +130,7 @@ pub fn lookup_host(host: &str) -> io::Result<LookupHost> {
// lookup_addr
////////////////////////////////////////////////////////////////////////////////
#[allow(deprecated)]
pub fn lookup_addr(addr: &IpAddr) -> io::Result<String> {
init();

View File

@ -243,7 +243,7 @@ impl Wtf8Buf {
/// Append a UTF-8 slice at the end of the string.
#[inline]
pub fn push_str(&mut self, other: &str) {
self.bytes.push_all(other.as_bytes())
self.bytes.extend_from_slice(other.as_bytes())
}
/// Append a WTF-8 slice at the end of the string.
@ -262,9 +262,9 @@ impl Wtf8Buf {
// 4 bytes for the supplementary code point
self.bytes.reserve(4 + other_without_trail_surrogate.len());
self.push_char(decode_surrogate_pair(lead, trail));
self.bytes.push_all(other_without_trail_surrogate);
self.bytes.extend_from_slice(other_without_trail_surrogate);
}
_ => self.bytes.push_all(&other.bytes)
_ => self.bytes.extend_from_slice(&other.bytes)
}
}
@ -331,10 +331,8 @@ impl Wtf8Buf {
match self.next_surrogate(pos) {
Some((surrogate_pos, _)) => {
pos = surrogate_pos + 3;
slice::bytes::copy_memory(
UTF8_REPLACEMENT_CHARACTER,
&mut self.bytes[surrogate_pos .. pos],
);
self.bytes[surrogate_pos..pos]
.clone_from_slice(UTF8_REPLACEMENT_CHARACTER);
},
None => return unsafe { String::from_utf8_unchecked(self.bytes) }
}
@ -493,18 +491,18 @@ impl Wtf8 {
};
let wtf8_bytes = &self.bytes;
let mut utf8_bytes = Vec::with_capacity(self.len());
utf8_bytes.push_all(&wtf8_bytes[..surrogate_pos]);
utf8_bytes.push_all(UTF8_REPLACEMENT_CHARACTER);
utf8_bytes.extend_from_slice(&wtf8_bytes[..surrogate_pos]);
utf8_bytes.extend_from_slice(UTF8_REPLACEMENT_CHARACTER);
let mut pos = surrogate_pos + 3;
loop {
match self.next_surrogate(pos) {
Some((surrogate_pos, _)) => {
utf8_bytes.push_all(&wtf8_bytes[pos .. surrogate_pos]);
utf8_bytes.push_all(UTF8_REPLACEMENT_CHARACTER);
utf8_bytes.extend_from_slice(&wtf8_bytes[pos .. surrogate_pos]);
utf8_bytes.extend_from_slice(UTF8_REPLACEMENT_CHARACTER);
pos = surrogate_pos + 3;
},
None => {
utf8_bytes.push_all(&wtf8_bytes[pos..]);
utf8_bytes.extend_from_slice(&wtf8_bytes[pos..]);
return Cow::Owned(unsafe { String::from_utf8_unchecked(utf8_bytes) })
}
}

View File

@ -246,17 +246,16 @@ pub fn symlink<P: AsRef<Path>, Q: AsRef<Path>>(src: P, dst: Q) -> io::Result<()>
sys::fs::symlink(src.as_ref(), dst.as_ref())
}
#[unstable(feature = "dir_builder", reason = "recently added API",
issue = "27710")]
#[stable(feature = "dir_builder", since = "1.6.0")]
/// An extension trait for `fs::DirBuilder` for unix-specific options.
pub trait DirBuilderExt {
/// Sets the mode to create new directories with. This option defaults to
/// 0o777.
#[stable(feature = "dir_builder", since = "1.6.0")]
fn mode(&mut self, mode: raw::mode_t) -> &mut Self;
}
#[unstable(feature = "dir_builder", reason = "recently added API",
issue = "27710")]
#[stable(feature = "dir_builder", since = "1.6.0")]
impl DirBuilderExt for fs::DirBuilder {
fn mode(&mut self, mode: raw::mode_t) -> &mut fs::DirBuilder {
self.as_inner_mut().set_mode(mode);

View File

@ -355,8 +355,7 @@ impl DirBuilder {
}
fn cstr(path: &Path) -> io::Result<CString> {
path.as_os_str().to_cstring().ok_or(
io::Error::new(io::ErrorKind::InvalidInput, "path contained a null"))
Ok(try!(CString::new(path.as_os_str().as_bytes())))
}
impl FromInner<c_int> for File {

View File

@ -149,7 +149,7 @@ pub fn join_paths<I, T>(paths: I) -> Result<OsString, JoinPathsError>
if path.contains(&sep) {
return Err(JoinPathsError)
}
joined.push_all(path);
joined.extend_from_slice(path);
}
Ok(OsStringExt::from_vec(joined))
}

View File

@ -53,7 +53,7 @@ impl Buf {
}
pub fn push_slice(&mut self, s: &Slice) {
self.inner.push_all(&s.inner)
self.inner.extend_from_slice(&s.inner)
}
}

Some files were not shown because too many files have changed in this diff Show More