Skip to content

Commit 91813cf

Browse files
committed
---
yaml --- r: 210211 b: refs/heads/try c: f2a19b3 h: refs/heads/master i: 210209: efe96a4 210207: 6e9d4cd v: v3
1 parent b2ec739 commit 91813cf

File tree

23 files changed

+263
-233
lines changed

23 files changed

+263
-233
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 3e561f05c00cd180ec02db4ccab2840a4aba93d2
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: ba0e1cd8147d452c356aacb29fb87568ca26f111
5-
refs/heads/try: f0af2ec99c42a2e49af455c404c3ba92d75b271d
5+
refs/heads/try: f2a19b39fbb2c7fb7c6f0f52e7f65e6ed8bddec4
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
88
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596

branches/try/src/doc/trpl/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,5 +190,5 @@ fn main() {
190190
We created an inner scope with an additional set of curly braces. `y` will go out of
191191
scope before we call `push()`, and so we’re all good.
192192

193-
This concept of ownership isn’t just good for preventing danging pointers, but an
193+
This concept of ownership isn’t just good for preventing dangling pointers, but an
194194
entire set of related problems, like iterator invalidation, concurrency, and more.

branches/try/src/libcollections/string.rs

Lines changed: 10 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ use rustc_unicode::str as unicode_str;
2626
use rustc_unicode::str::Utf16Item;
2727

2828
use borrow::{Cow, IntoCow};
29-
use range::RangeArgument;
30-
use str::{self, FromStr, Utf8Error, Chars};
29+
use str::{self, FromStr, Utf8Error};
3130
use vec::{DerefVec, Vec, as_vec};
3231

3332
/// A growable string stored as a UTF-8 encoded buffer.
@@ -696,59 +695,6 @@ impl String {
696695
pub fn clear(&mut self) {
697696
self.vec.clear()
698697
}
699-
700-
/// Create a draining iterator that removes the specified range in the string
701-
/// and yields the removed chars from start to end. The element range is
702-
/// removed even if the iterator is not consumed until the end.
703-
///
704-
/// # Panics
705-
///
706-
/// Panics if the starting point or end point are not on character boundaries,
707-
/// or if they are out of bounds.
708-
///
709-
/// # Examples
710-
///
711-
/// ```
712-
/// # #![feature(collections_drain)]
713-
///
714-
/// let mut s = String::from("α is alpha, β is beta");
715-
/// let beta_offset = s.find('β').unwrap_or(s.len());
716-
///
717-
/// // Remove the range up until the β from the string
718-
/// let t: String = s.drain(..beta_offset).collect();
719-
/// assert_eq!(t, "α is alpha, ");
720-
/// assert_eq!(s, "β is beta");
721-
///
722-
/// // A full range clears the string
723-
/// s.drain(..);
724-
/// assert_eq!(s, "");
725-
/// ```
726-
#[unstable(feature = "collections_drain",
727-
reason = "recently added, matches RFC")]
728-
pub fn drain<R>(&mut self, range: R) -> Drain where R: RangeArgument<usize> {
729-
// Memory safety
730-
//
731-
// The String version of Drain does not have the memory safety issues
732-
// of the vector version. The data is just plain bytes.
733-
// Because the range removal happens in Drop, if the Drain iterator is leaked,
734-
// the removal will not happen.
735-
let len = self.len();
736-
let start = *range.start().unwrap_or(&0);
737-
let end = *range.end().unwrap_or(&len);
738-
739-
// Take out two simultaneous borrows. The &mut String won't be accessed
740-
// until iteration is over, in Drop.
741-
let self_ptr = self as *mut _;
742-
// slicing does the appropriate bounds checks
743-
let chars_iter = self[start..end].chars();
744-
745-
Drain {
746-
start: start,
747-
end: end,
748-
iter: chars_iter,
749-
string: self_ptr,
750-
}
751-
}
752698
}
753699

754700
impl FromUtf8Error {
@@ -794,7 +740,8 @@ impl<'a> FromIterator<&'a str> for String {
794740
}
795741
}
796742

797-
#[stable(feature = "rust1", since = "1.0.0")]
743+
#[unstable(feature = "collections",
744+
reason = "waiting on Extend stabilization")]
798745
impl Extend<char> for String {
799746
fn extend<I: IntoIterator<Item=char>>(&mut self, iterable: I) {
800747
let iterator = iterable.into_iter();
@@ -806,7 +753,8 @@ impl Extend<char> for String {
806753
}
807754
}
808755

809-
#[stable(feature = "rust1", since = "1.0.0")]
756+
#[unstable(feature = "collections",
757+
reason = "waiting on Extend stabilization")]
810758
impl<'a> Extend<&'a str> for String {
811759
fn extend<I: IntoIterator<Item=&'a str>>(&mut self, iterable: I) {
812760
let iterator = iterable.into_iter();
@@ -921,7 +869,8 @@ impl hash::Hash for String {
921869
}
922870
}
923871

924-
#[stable(feature = "rust1", since = "1.0.0")]
872+
#[unstable(feature = "collections",
873+
reason = "recent addition, needs more experience")]
925874
impl<'a> Add<&'a str> for String {
926875
type Output = String;
927876

@@ -1015,17 +964,11 @@ pub fn as_string<'a>(x: &'a str) -> DerefString<'a> {
1015964
DerefString { x: as_vec(x.as_bytes()) }
1016965
}
1017966

1018-
/// Error returned from `String::from_str`
1019-
#[unstable(feature = "str_parse_error", reason = "may want to be replaced with \
1020-
Void if it ever exists")]
1021-
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
1022-
pub struct ParseError(());
1023-
1024-
#[stable(feature = "rust1", since = "1.0.0")]
967+
#[unstable(feature = "collections", reason = "associated error type may change")]
1025968
impl FromStr for String {
1026-
type Err = ParseError;
969+
type Err = ();
1027970
#[inline]
1028-
fn from_str(s: &str) -> Result<String, ParseError> {
971+
fn from_str(s: &str) -> Result<String, ()> {
1029972
Ok(String::from_str(s))
1030973
}
1031974
}
@@ -1129,55 +1072,3 @@ impl fmt::Write for String {
11291072
Ok(())
11301073
}
11311074
}
1132-
1133-
/// A draining iterator for `String`.
1134-
#[unstable(feature = "collections_drain", reason = "recently added")]
1135-
pub struct Drain<'a> {
1136-
/// Will be used as &'a mut String in the destructor
1137-
string: *mut String,
1138-
/// Start of part to remove
1139-
start: usize,
1140-
/// End of part to remove
1141-
end: usize,
1142-
/// Current remaining range to remove
1143-
iter: Chars<'a>,
1144-
}
1145-
1146-
unsafe impl<'a> Sync for Drain<'a> {}
1147-
unsafe impl<'a> Send for Drain<'a> {}
1148-
1149-
#[unstable(feature = "collections_drain", reason = "recently added")]
1150-
impl<'a> Drop for Drain<'a> {
1151-
fn drop(&mut self) {
1152-
unsafe {
1153-
// Use Vec::drain. "Reaffirm" the bounds checks to avoid
1154-
// panic code being inserted again.
1155-
let self_vec = (*self.string).as_mut_vec();
1156-
if self.start <= self.end && self.end <= self_vec.len() {
1157-
self_vec.drain(self.start..self.end);
1158-
}
1159-
}
1160-
}
1161-
}
1162-
1163-
#[unstable(feature = "collections_drain", reason = "recently added")]
1164-
impl<'a> Iterator for Drain<'a> {
1165-
type Item = char;
1166-
1167-
#[inline]
1168-
fn next(&mut self) -> Option<char> {
1169-
self.iter.next()
1170-
}
1171-
1172-
fn size_hint(&self) -> (usize, Option<usize>) {
1173-
self.iter.size_hint()
1174-
}
1175-
}
1176-
1177-
#[unstable(feature = "collections_drain", reason = "recently added")]
1178-
impl<'a> DoubleEndedIterator for Drain<'a> {
1179-
#[inline]
1180-
fn next_back(&mut self) -> Option<char> {
1181-
self.iter.next_back()
1182-
}
1183-
}

branches/try/src/libcollections/vec.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1299,7 +1299,7 @@ pub fn from_elem<T: Clone>(elem: T, n: usize) -> Vec<T> {
12991299
// Common trait implementations for Vec
13001300
////////////////////////////////////////////////////////////////////////////////
13011301

1302-
#[stable(feature = "rust1", since = "1.0.0")]
1302+
#[unstable(feature = "collections")]
13031303
impl<T:Clone> Clone for Vec<T> {
13041304
#[cfg(not(test))]
13051305
fn clone(&self) -> Vec<T> { <[T]>::to_vec(&**self) }
@@ -1554,7 +1554,7 @@ impl<'a, T> IntoIterator for &'a mut Vec<T> {
15541554
}
15551555
}
15561556

1557-
#[stable(feature = "rust1", since = "1.0.0")]
1557+
#[unstable(feature = "collections", reason = "waiting on Extend stability")]
15581558
impl<T> Extend<T> for Vec<T> {
15591559
#[inline]
15601560
fn extend<I: IntoIterator<Item=T>>(&mut self, iterable: I) {
@@ -1614,7 +1614,8 @@ impl<T: Ord> Ord for Vec<T> {
16141614
}
16151615
}
16161616

1617-
#[stable(feature = "rust1", since = "1.0.0")]
1617+
#[unstable(feature = "collections",
1618+
reason = "recent addition, needs more experience")]
16181619
impl<'a, T: Clone> Add<&'a [T]> for Vec<T> {
16191620
type Output = Vec<T>;
16201621

@@ -1693,7 +1694,7 @@ impl<'a> From<&'a str> for Vec<u8> {
16931694
// Clone-on-write
16941695
////////////////////////////////////////////////////////////////////////////////
16951696

1696-
#[stable(feature = "rust1", since = "1.0.0")]
1697+
#[unstable(feature = "collections")]
16971698
impl<'a, T> FromIterator<T> for Cow<'a, [T]> where T: Clone {
16981699
fn from_iter<I: IntoIterator<Item=T>>(it: I) -> Cow<'a, [T]> {
16991700
Cow::Owned(FromIterator::from_iter(it))

branches/try/src/libcollectionstest/string.rs

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -348,23 +348,6 @@ fn test_from_iterator() {
348348
assert_eq!(s, d);
349349
}
350350

351-
#[test]
352-
fn test_drain() {
353-
let mut s = String::from("αβγ");
354-
assert_eq!(s.drain(2..4).collect::<String>(), "β");
355-
assert_eq!(s, "αγ");
356-
357-
let mut t = String::from("abcd");
358-
t.drain(..0);
359-
assert_eq!(t, "abcd");
360-
t.drain(..1);
361-
assert_eq!(t, "bcd");
362-
t.drain(3..);
363-
assert_eq!(t, "bcd");
364-
t.drain(..);
365-
assert_eq!(t, "");
366-
}
367-
368351
#[bench]
369352
fn bench_with_capacity(b: &mut Bencher) {
370353
b.iter(|| {

branches/try/src/libcore/iter.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -626,10 +626,12 @@ pub trait Iterator {
626626
/// # Examples
627627
///
628628
/// ```
629+
/// # #![feature(core)]
629630
/// let a = [1, 2, 3, 4, 5];
630631
/// let mut it = a.iter();
631632
/// assert!(it.any(|x| *x == 3));
632-
/// assert_eq!(it.collect::<Vec<_>>(), [&4, &5]);
633+
/// assert_eq!(&it[..], [4, 5]);
634+
///
633635
/// ```
634636
#[inline]
635637
#[stable(feature = "rust1", since = "1.0.0")]
@@ -652,10 +654,11 @@ pub trait Iterator {
652654
/// # Examples
653655
///
654656
/// ```
657+
/// # #![feature(core)]
655658
/// let a = [1, 2, 3, 4, 5];
656659
/// let mut it = a.iter();
657660
/// assert_eq!(it.find(|&x| *x == 3).unwrap(), &3);
658-
/// assert_eq!(it.collect::<Vec<_>>(), [&4, &5]);
661+
/// assert_eq!(&it[..], [4, 5]);
659662
#[inline]
660663
#[stable(feature = "rust1", since = "1.0.0")]
661664
fn find<P>(&mut self, mut predicate: P) -> Option<Self::Item> where
@@ -675,10 +678,11 @@ pub trait Iterator {
675678
/// # Examples
676679
///
677680
/// ```
681+
/// # #![feature(core)]
678682
/// let a = [1, 2, 3, 4, 5];
679683
/// let mut it = a.iter();
680684
/// assert_eq!(it.position(|x| *x == 3).unwrap(), 2);
681-
/// assert_eq!(it.collect::<Vec<_>>(), [&4, &5]);
685+
/// assert_eq!(&it[..], [4, 5]);
682686
#[inline]
683687
#[stable(feature = "rust1", since = "1.0.0")]
684688
fn position<P>(&mut self, mut predicate: P) -> Option<usize> where
@@ -704,10 +708,11 @@ pub trait Iterator {
704708
/// # Examples
705709
///
706710
/// ```
711+
/// # #![feature(core)]
707712
/// let a = [1, 2, 2, 4, 5];
708713
/// let mut it = a.iter();
709714
/// assert_eq!(it.rposition(|x| *x == 2).unwrap(), 2);
710-
/// assert_eq!(it.collect::<Vec<_>>(), [&1, &2]);
715+
/// assert_eq!(&it[..], [1, 2]);
711716
#[inline]
712717
#[stable(feature = "rust1", since = "1.0.0")]
713718
fn rposition<P>(&mut self, mut predicate: P) -> Option<usize> where

branches/try/src/libcore/num/float_macros.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ macro_rules! from_str_radix_float_impl {
3535
}
3636

3737
let (is_positive, src) = match src.slice_shift_char() {
38-
None => return Err(PFE { __kind: Empty }),
39-
Some(('-', "")) => return Err(PFE { __kind: Empty }),
38+
None => return Err(PFE { kind: Empty }),
39+
Some(('-', "")) => return Err(PFE { kind: Empty }),
4040
Some(('-', src)) => (false, src),
4141
Some((_, _)) => (true, src),
4242
};
@@ -88,7 +88,7 @@ macro_rules! from_str_radix_float_impl {
8888
break; // start of fractional part
8989
},
9090
_ => {
91-
return Err(PFE { __kind: Invalid });
91+
return Err(PFE { kind: Invalid });
9292
},
9393
},
9494
}
@@ -122,7 +122,7 @@ macro_rules! from_str_radix_float_impl {
122122
break; // start of exponent
123123
},
124124
_ => {
125-
return Err(PFE { __kind: Invalid });
125+
return Err(PFE { kind: Invalid });
126126
},
127127
},
128128
}
@@ -135,7 +135,7 @@ macro_rules! from_str_radix_float_impl {
135135
let base = match c {
136136
'E' | 'e' if radix == 10 => 10.0,
137137
'P' | 'p' if radix == 16 => 2.0,
138-
_ => return Err(PFE { __kind: Invalid }),
138+
_ => return Err(PFE { kind: Invalid }),
139139
};
140140

141141
// Parse the exponent as decimal integer
@@ -144,13 +144,13 @@ macro_rules! from_str_radix_float_impl {
144144
Some(('-', src)) => (false, src.parse::<usize>()),
145145
Some(('+', src)) => (true, src.parse::<usize>()),
146146
Some((_, _)) => (true, src.parse::<usize>()),
147-
None => return Err(PFE { __kind: Invalid }),
147+
None => return Err(PFE { kind: Invalid }),
148148
};
149149

150150
match (is_positive, exp) {
151151
(true, Ok(exp)) => base.powi(exp as i32),
152152
(false, Ok(exp)) => 1.0 / base.powi(exp as i32),
153-
(_, Err(_)) => return Err(PFE { __kind: Invalid }),
153+
(_, Err(_)) => return Err(PFE { kind: Invalid }),
154154
}
155155
},
156156
None => 1.0, // no exponent

branches/try/src/libcore/num/mod.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1524,11 +1524,7 @@ impl fmt::Display for ParseIntError {
15241524

15251525
/// An error which can be returned when parsing a float.
15261526
#[derive(Debug, Clone, PartialEq)]
1527-
#[stable(feature = "rust1", since = "1.0.0")]
1528-
pub struct ParseFloatError {
1529-
#[doc(hidden)]
1530-
pub __kind: FloatErrorKind
1531-
}
1527+
pub struct ParseFloatError { pub kind: FloatErrorKind }
15321528

15331529
#[derive(Debug, Clone, PartialEq)]
15341530
pub enum FloatErrorKind {
@@ -1537,9 +1533,9 @@ pub enum FloatErrorKind {
15371533
}
15381534

15391535
impl ParseFloatError {
1540-
#[doc(hidden)]
1541-
pub fn __description(&self) -> &str {
1542-
match self.__kind {
1536+
#[unstable(feature = "core", reason = "available through Error trait")]
1537+
pub fn description(&self) -> &str {
1538+
match self.kind {
15431539
FloatErrorKind::Empty => "cannot parse float from empty string",
15441540
FloatErrorKind::Invalid => "invalid float literal",
15451541
}
@@ -1549,6 +1545,6 @@ impl ParseFloatError {
15491545
#[stable(feature = "rust1", since = "1.0.0")]
15501546
impl fmt::Display for ParseFloatError {
15511547
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1552-
self.__description().fmt(f)
1548+
self.description().fmt(f)
15531549
}
15541550
}

0 commit comments

Comments
 (0)