Skip to content

Commit 6c494ee

Browse files
committed
---
yaml --- r: 192333 b: refs/heads/master c: eefb8e2 h: refs/heads/master i: 192331: e0d8192 v: v3
1 parent 6f40230 commit 6c494ee

File tree

11 files changed

+79
-104
lines changed

11 files changed

+79
-104
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 4283b2ab5053eec3c7f95682e82aee9006c58eef
2+
refs/heads/master: eefb8e206504e01054fdd4843c31270a3945e49c
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: a923278c6278c63468d74772c58dbf788e88f58c
55
refs/heads/try: ce76bff75603a754d092456285ff455eb871633d

trunk/src/libcollections/binary_heap.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -563,8 +563,6 @@ impl<T: Ord> BinaryHeap<T> {
563563
pub fn is_empty(&self) -> bool { self.len() == 0 }
564564

565565
/// Clears the binary heap, returning an iterator over the removed elements.
566-
///
567-
/// The elements are removed in arbitrary order.
568566
#[inline]
569567
#[unstable(feature = "collections",
570568
reason = "matches collection reform specification, waiting for dust to settle")]

trunk/src/libcollections/slice.rs

Lines changed: 41 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,25 @@
1313
//! The `slice` module contains useful code to help work with slice values.
1414
//! Slices are a view into a block of memory represented as a pointer and a length.
1515
//!
16-
//! ```
16+
//! ```rust
17+
//! # #![feature(core)]
1718
//! // slicing a Vec
18-
//! let vec = vec![1, 2, 3];
19-
//! let int_slice = &vec[..];
19+
//! let vec = vec!(1, 2, 3);
20+
//! let int_slice = vec.as_slice();
2021
//! // coercing an array to a slice
2122
//! let str_slice: &[&str] = &["one", "two", "three"];
2223
//! ```
2324
//!
2425
//! Slices are either mutable or shared. The shared slice type is `&[T]`,
25-
//! while the mutable slice type is `&mut [T]`, where `T` represents the element
26-
//! type. For example, you can mutate the block of memory that a mutable slice
27-
//! points to:
26+
//! while the mutable slice type is `&mut[T]`. For example, you can mutate the
27+
//! block of memory that a mutable slice points to:
2828
//!
29-
//! ```
30-
//! let x = &mut [1, 2, 3];
29+
//! ```rust
30+
//! let x: &mut[i32] = &mut [1, 2, 3];
3131
//! x[1] = 7;
32-
//! assert_eq!(x, &[1, 7, 3]);
32+
//! assert_eq!(x[0], 1);
33+
//! assert_eq!(x[1], 7);
34+
//! assert_eq!(x[2], 3);
3335
//! ```
3436
//!
3537
//! Here are some of the things this module contains:
@@ -39,43 +41,49 @@
3941
//! There are several structs that are useful for slices, such as `Iter`, which
4042
//! represents iteration over a slice.
4143
//!
42-
//! ## Trait Implementations
44+
//! ## Traits
45+
//!
46+
//! A number of traits add methods that allow you to accomplish tasks
47+
//! with slices, the most important being `SliceExt`. Other traits
48+
//! apply only to slices of elements satisfying certain bounds (like
49+
//! `Ord`).
50+
//!
51+
//! An example is the `slice` method which enables slicing syntax `[a..b]` that
52+
//! returns an immutable "view" into a `Vec` or another slice from the index
53+
//! interval `[a, b)`:
54+
//!
55+
//! ```rust
56+
//! fn main() {
57+
//! let numbers = [0, 1, 2];
58+
//! let last_numbers = &numbers[1..3];
59+
//! // last_numbers is now &[1, 2]
60+
//! }
61+
//! ```
62+
//!
63+
//! ## Implementations of other traits
4364
//!
4465
//! There are several implementations of common traits for slices. Some examples
4566
//! include:
4667
//!
4768
//! * `Clone`
48-
//! * `Eq`, `Ord` - for slices whose element type are `Eq` or `Ord`.
69+
//! * `Eq`, `Ord` - for immutable slices whose element type are `Eq` or `Ord`.
4970
//! * `Hash` - for slices whose element type is `Hash`
5071
//!
5172
//! ## Iteration
5273
//!
53-
//! The slices implement `IntoIterator`. The iterators of yield references
54-
//! to the slice elements.
74+
//! The method `iter()` returns an iteration value for a slice. The iterator
75+
//! yields references to the slice's elements, so if the element
76+
//! type of the slice is `isize`, the element type of the iterator is `&isize`.
5577
//!
56-
//! ```
57-
//! let numbers = &[0, 1, 2];
58-
//! for n in numbers {
59-
//! println!("{} is a number!", n);
78+
//! ```rust
79+
//! let numbers = [0, 1, 2];
80+
//! for &x in numbers.iter() {
81+
//! println!("{} is a number!", x);
6082
//! }
6183
//! ```
6284
//!
63-
//! The mutable slice yields mutable references to the elements:
64-
//!
65-
//! ```
66-
//! let mut scores = [7, 8, 9];
67-
//! for score in &mut scores[..] {
68-
//! *score += 1;
69-
//! }
70-
//! ```
71-
//!
72-
//! This iterator yields mutable references to the slice's elements, so while the element
73-
//! type of the slice is `i32`, the element type of the iterator is `&mut i32`.
74-
//!
75-
//! * `.iter()` and `.iter_mut()` are the explicit methods to return the default
76-
//! iterators.
77-
//! * Further methods that return iterators are `.split()`, `.splitn()`,
78-
//! `.chunks()`, `.windows()` and more.
85+
//! * `.iter_mut()` returns an iterator that allows modifying each value.
86+
//! * Further iterators exist that split, chunk or permute the slice.
7987
8088
#![doc(primitive = "slice")]
8189
#![stable(feature = "rust1", since = "1.0.0")]

trunk/src/libcollections/str.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
//! are owned elsewhere.
2020
//!
2121
//! Basic operations are implemented directly by the compiler, but more advanced
22-
//! operations are defined as methods on the `str` type.
22+
//! operations are defined on the [`StrExt`](trait.StrExt.html) trait.
2323
//!
2424
//! # Examples
2525
//!

trunk/src/libcollections/vec.rs

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -646,30 +646,23 @@ impl<T> Vec<T> {
646646
#[inline]
647647
#[stable(feature = "rust1", since = "1.0.0")]
648648
pub fn push(&mut self, value: T) {
649-
#[cold]
650-
#[inline(never)]
651-
fn resize<T>(vec: &mut Vec<T>) {
652-
let old_size = vec.cap * mem::size_of::<T>();
653-
let size = max(old_size, 2 * mem::size_of::<T>()) * 2;
654-
if old_size > size { panic!("capacity overflow") }
655-
unsafe {
656-
let ptr = alloc_or_realloc(*vec.ptr, old_size, size);
657-
if ptr.is_null() { ::alloc::oom() }
658-
vec.ptr = Unique::new(ptr);
659-
}
660-
vec.cap = max(vec.cap, 2) * 2;
661-
}
662-
663649
if mem::size_of::<T>() == 0 {
664650
// zero-size types consume no memory, so we can't rely on the
665651
// address space running out
666652
self.len = self.len.checked_add(1).expect("length overflow");
667653
unsafe { mem::forget(value); }
668654
return
669655
}
670-
671656
if self.len == self.cap {
672-
resize(self);
657+
let old_size = self.cap * mem::size_of::<T>();
658+
let size = max(old_size, 2 * mem::size_of::<T>()) * 2;
659+
if old_size > size { panic!("capacity overflow") }
660+
unsafe {
661+
let ptr = alloc_or_realloc(*self.ptr, old_size, size);
662+
if ptr.is_null() { ::alloc::oom() }
663+
self.ptr = Unique::new(ptr);
664+
}
665+
self.cap = max(self.cap, 2) * 2;
673666
}
674667

675668
unsafe {

trunk/src/libcore/str/mod.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,8 @@ impl FromStr for bool {
165165
/// assert!(<bool as FromStr>::from_str("not even a boolean").is_err());
166166
/// ```
167167
///
168-
/// Note, in many cases, the `.parse()` method on `str` is more proper.
168+
/// Note, in many cases, the StrExt::parse() which is based on
169+
/// this FromStr::from_str() is more proper.
169170
///
170171
/// ```
171172
/// assert_eq!("true".parse(), Ok(true));
@@ -530,7 +531,7 @@ impl<'a> DoubleEndedIterator for CharIndices<'a> {
530531
/// External iterator for a string's bytes.
531532
/// Use with the `std::iter` module.
532533
///
533-
/// Created with `str::bytes`
534+
/// Created with `StrExt::bytes`
534535
#[stable(feature = "rust1", since = "1.0.0")]
535536
#[derive(Clone)]
536537
pub struct Bytes<'a>(Map<slice::Iter<'a, u8>, BytesDeref>);
@@ -1488,27 +1489,27 @@ impl<'a, S: ?Sized> Str for &'a S where S: Str {
14881489
fn as_slice(&self) -> &str { Str::as_slice(*self) }
14891490
}
14901491

1491-
/// Return type of `str::split`
1492+
/// Return type of `StrExt::split`
14921493
#[stable(feature = "rust1", since = "1.0.0")]
14931494
pub struct Split<'a, P: Pattern<'a>>(CharSplits<'a, P>);
14941495
delegate_iter!{pattern &'a str : Split<'a, P>}
14951496

1496-
/// Return type of `str::split_terminator`
1497+
/// Return type of `StrExt::split_terminator`
14971498
#[stable(feature = "rust1", since = "1.0.0")]
14981499
pub struct SplitTerminator<'a, P: Pattern<'a>>(CharSplits<'a, P>);
14991500
delegate_iter!{pattern &'a str : SplitTerminator<'a, P>}
15001501

1501-
/// Return type of `str::splitn`
1502+
/// Return type of `StrExt::splitn`
15021503
#[stable(feature = "rust1", since = "1.0.0")]
15031504
pub struct SplitN<'a, P: Pattern<'a>>(CharSplitsN<'a, P>);
15041505
delegate_iter!{pattern forward &'a str : SplitN<'a, P>}
15051506

1506-
/// Return type of `str::rsplit`
1507+
/// Return type of `StrExt::rsplit`
15071508
#[stable(feature = "rust1", since = "1.0.0")]
15081509
pub struct RSplit<'a, P: Pattern<'a>>(RCharSplits<'a, P>);
15091510
delegate_iter!{pattern reverse &'a str : RSplit<'a, P>}
15101511

1511-
/// Return type of `str::rsplitn`
1512+
/// Return type of `StrExt::rsplitn`
15121513
#[stable(feature = "rust1", since = "1.0.0")]
15131514
pub struct RSplitN<'a, P: Pattern<'a>>(RCharSplitsN<'a, P>);
15141515
delegate_iter!{pattern reverse &'a str : RSplitN<'a, P>}

trunk/src/librustc_trans/trans/expr.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1766,8 +1766,6 @@ fn trans_eager_binop<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
17661766
ast::BiAdd => {
17671767
if is_float {
17681768
FAdd(bcx, lhs, rhs, binop_debug_loc)
1769-
} else if is_simd {
1770-
Add(bcx, lhs, rhs, binop_debug_loc)
17711769
} else {
17721770
let (newbcx, res) = with_overflow_check(
17731771
bcx, OverflowOp::Add, info, lhs_t, lhs, rhs, binop_debug_loc);
@@ -1778,8 +1776,6 @@ fn trans_eager_binop<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
17781776
ast::BiSub => {
17791777
if is_float {
17801778
FSub(bcx, lhs, rhs, binop_debug_loc)
1781-
} else if is_simd {
1782-
Sub(bcx, lhs, rhs, binop_debug_loc)
17831779
} else {
17841780
let (newbcx, res) = with_overflow_check(
17851781
bcx, OverflowOp::Sub, info, lhs_t, lhs, rhs, binop_debug_loc);
@@ -1790,8 +1786,6 @@ fn trans_eager_binop<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
17901786
ast::BiMul => {
17911787
if is_float {
17921788
FMul(bcx, lhs, rhs, binop_debug_loc)
1793-
} else if is_simd {
1794-
Mul(bcx, lhs, rhs, binop_debug_loc)
17951789
} else {
17961790
let (newbcx, res) = with_overflow_check(
17971791
bcx, OverflowOp::Mul, info, lhs_t, lhs, rhs, binop_debug_loc);

trunk/src/libstd/io/mod.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -631,14 +631,14 @@ pub trait BufRead: Read {
631631

632632
/// A `Write` adaptor which will write data to multiple locations.
633633
///
634-
/// For more information, see `Write::broadcast`.
635-
#[unstable(feature = "io", reason = "awaiting stability of Write::broadcast")]
634+
/// For more information, see `WriteExt::broadcast`.
635+
#[unstable(feature = "io", reason = "awaiting stability of WriteExt::broadcast")]
636636
pub struct Broadcast<T, U> {
637637
first: T,
638638
second: U,
639639
}
640640

641-
#[unstable(feature = "io", reason = "awaiting stability of Write::broadcast")]
641+
#[unstable(feature = "io", reason = "awaiting stability of WriteExt::broadcast")]
642642
impl<T: Write, U: Write> Write for Broadcast<T, U> {
643643
fn write(&mut self, data: &[u8]) -> Result<usize> {
644644
let n = try!(self.first.write(data));
@@ -654,7 +654,7 @@ impl<T: Write, U: Write> Write for Broadcast<T, U> {
654654

655655
/// Adaptor to chain together two instances of `Read`.
656656
///
657-
/// For more information, see `Read::chain`.
657+
/// For more information, see `ReadExt::chain`.
658658
#[stable(feature = "rust1", since = "1.0.0")]
659659
pub struct Chain<T, U> {
660660
first: T,
@@ -677,7 +677,7 @@ impl<T: Read, U: Read> Read for Chain<T, U> {
677677

678678
/// Reader adaptor which limits the bytes read from an underlying reader.
679679
///
680-
/// For more information, see `Read::take`.
680+
/// For more information, see `ReadExt::take`.
681681
#[stable(feature = "rust1", since = "1.0.0")]
682682
pub struct Take<T> {
683683
inner: T,
@@ -730,14 +730,14 @@ impl<T: BufRead> BufRead for Take<T> {
730730

731731
/// An adaptor which will emit all read data to a specified writer as well.
732732
///
733-
/// For more information see `Read::tee`
734-
#[unstable(feature = "io", reason = "awaiting stability of Read::tee")]
733+
/// For more information see `ReadExt::tee`
734+
#[unstable(feature = "io", reason = "awaiting stability of ReadExt::tee")]
735735
pub struct Tee<R, W> {
736736
reader: R,
737737
writer: W,
738738
}
739739

740-
#[unstable(feature = "io", reason = "awaiting stability of Read::tee")]
740+
#[unstable(feature = "io", reason = "awaiting stability of ReadExt::tee")]
741741
impl<R: Read, W: Write> Read for Tee<R, W> {
742742
fn read(&mut self, buf: &mut [u8]) -> Result<usize> {
743743
let n = try!(self.reader.read(buf));
@@ -749,7 +749,7 @@ impl<R: Read, W: Write> Read for Tee<R, W> {
749749

750750
/// A bridge from implementations of `Read` to an `Iterator` of `u8`.
751751
///
752-
/// See `Read::bytes` for more information.
752+
/// See `ReadExt::bytes` for more information.
753753
#[stable(feature = "rust1", since = "1.0.0")]
754754
pub struct Bytes<R> {
755755
inner: R,
@@ -771,16 +771,16 @@ impl<R: Read> Iterator for Bytes<R> {
771771

772772
/// A bridge from implementations of `Read` to an `Iterator` of `char`.
773773
///
774-
/// See `Read::chars` for more information.
775-
#[unstable(feature = "io", reason = "awaiting stability of Read::chars")]
774+
/// See `ReadExt::chars` for more information.
775+
#[unstable(feature = "io", reason = "awaiting stability of ReadExt::chars")]
776776
pub struct Chars<R> {
777777
inner: R,
778778
}
779779

780780
/// An enumeration of possible errors that can be generated from the `Chars`
781781
/// adapter.
782782
#[derive(PartialEq, Clone, Debug)]
783-
#[unstable(feature = "io", reason = "awaiting stability of Read::chars")]
783+
#[unstable(feature = "io", reason = "awaiting stability of ReadExt::chars")]
784784
pub enum CharsError {
785785
/// Variant representing that the underlying stream was read successfully
786786
/// but it did not contain valid utf8 data.
@@ -790,7 +790,7 @@ pub enum CharsError {
790790
Other(Error),
791791
}
792792

793-
#[unstable(feature = "io", reason = "awaiting stability of Read::chars")]
793+
#[unstable(feature = "io", reason = "awaiting stability of ReadExt::chars")]
794794
impl<R: Read> Iterator for Chars<R> {
795795
type Item = result::Result<char, CharsError>;
796796

@@ -822,7 +822,7 @@ impl<R: Read> Iterator for Chars<R> {
822822
}
823823
}
824824

825-
#[unstable(feature = "io", reason = "awaiting stability of Read::chars")]
825+
#[unstable(feature = "io", reason = "awaiting stability of ReadExt::chars")]
826826
impl std_error::Error for CharsError {
827827
fn description(&self) -> &str {
828828
match *self {
@@ -838,7 +838,7 @@ impl std_error::Error for CharsError {
838838
}
839839
}
840840

841-
#[unstable(feature = "io", reason = "awaiting stability of Read::chars")]
841+
#[unstable(feature = "io", reason = "awaiting stability of ReadExt::chars")]
842842
impl fmt::Display for CharsError {
843843
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
844844
match *self {

trunk/src/libstd/io/prelude.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
//! ```
1919
//!
2020
//! This module contains reexports of many core I/O traits such as `Read`,
21-
//! `Write` and `BufRead`. Structures and functions are not
21+
//! `Write`, `ReadExt`, and `WriteExt`. Structures and functions are not
2222
//! contained in this module.
2323
2424
#![stable(feature = "rust1", since = "1.0.0")]

trunk/src/libstd/sys/unix/os.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ pub fn current_exe() -> io::Result<PathBuf> {
206206
if err != 0 { return Err(io::Error::last_os_error()); }
207207
if sz == 0 { return Err(io::Error::last_os_error()); }
208208
v.set_len(sz as uint - 1); // chop off trailing NUL
209-
Ok(PathBuf::new::<OsString>(OsStringExt::from_vec(v)))
209+
Ok(PathBuf::from(OsString::from_vec(v)))
210210
}
211211
}
212212

@@ -232,7 +232,7 @@ pub fn current_exe() -> io::Result<PathBuf> {
232232
Err(io::Error::last_os_error())
233233
} else {
234234
let vec = CStr::from_ptr(v).to_bytes().to_vec();
235-
Ok(PathBuf::new::<OsString>(OsStringExt::from_vec(vec)))
235+
Ok(PathBuf::from(OsString::from_vec(vec)))
236236
}
237237
}
238238
}
@@ -345,7 +345,7 @@ pub fn args() -> Args {
345345
let utf_c_str: *const libc::c_char =
346346
mem::transmute(objc_msgSend(tmp, utf8_sel));
347347
let bytes = CStr::from_ptr(utf_c_str).to_bytes();
348-
res.push(OsString::from(str::from_utf8(bytes).unwrap()))
348+
res.push(OsString::from_str(str::from_utf8(bytes).unwrap()))
349349
}
350350
}
351351

0 commit comments

Comments
 (0)