Skip to content

Commit f0c79c7

Browse files
committed
---
yaml --- r: 167465 b: refs/heads/snap-stage3 c: e91d810 h: refs/heads/master i: 167463: 319f3ff v: v3
1 parent 6107f29 commit f0c79c7

File tree

6 files changed

+36
-60
lines changed

6 files changed

+36
-60
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 023dfb0c898d851dee6ace2f8339b73b5287136b
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 4f863a338e0a7c33f81a8ac138103f1a0e8b33c5
4+
refs/heads/snap-stage3: e91d810b9b36d6bb163970cd0e8bbf4692f704bb
55
refs/heads/try: 5204084bd2e46af7cc6e0147430e44dd0d657bbb
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d

branches/snap-stage3/src/libcollections/slice.rs

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -993,19 +993,31 @@ impl<T: Ord> OrdSliceExt<T> for [T] {
993993
}
994994
}
995995

996-
#[allow(missing_docs)]
997-
pub trait VectorVector<T> for Sized? {
998-
// FIXME #5898: calling these .concat and .connect conflicts with
999-
// StrVector::con{cat,nect}, since they have generic contents.
1000-
/// Flattens a vector of vectors of `T` into a single `Vec<T>`.
1001-
fn concat_vec(&self) -> Vec<T>;
1002-
1003-
/// Concatenate a vector of vectors, placing a given separator between each.
1004-
fn connect_vec(&self, sep: &T) -> Vec<T>;
996+
#[unstable = "U should be an associated type"]
997+
/// An extension trait for concatenating slices
998+
pub trait SliceConcatExt<Sized? T, U> for Sized? {
999+
/// Flattens a slice of `T` into a single value `U`.
1000+
#[stable]
1001+
fn concat(&self) -> U;
1002+
1003+
#[deprecated = "renamed to concat"]
1004+
fn concat_vec(&self) -> U {
1005+
self.concat()
1006+
}
1007+
1008+
/// Flattens a slice of `T` into a single value `U`, placing a
1009+
/// given seperator between each.
1010+
#[stable]
1011+
fn connect(&self, sep: &T) -> U;
1012+
1013+
#[deprecated = "renamed to connect"]
1014+
fn connect_vec(&self, sep: &T) -> U {
1015+
self.connect(sep)
1016+
}
10051017
}
10061018

1007-
impl<'a, T: Clone, V: AsSlice<T>> VectorVector<T> for [V] {
1008-
fn concat_vec(&self) -> Vec<T> {
1019+
impl<T: Clone, V: AsSlice<T>> SliceConcatExt<T, Vec<T>> for [V] {
1020+
fn concat(&self) -> Vec<T> {
10091021
let size = self.iter().fold(0u, |acc, v| acc + v.as_slice().len());
10101022
let mut result = Vec::with_capacity(size);
10111023
for v in self.iter() {
@@ -1014,7 +1026,7 @@ impl<'a, T: Clone, V: AsSlice<T>> VectorVector<T> for [V] {
10141026
result
10151027
}
10161028

1017-
fn connect_vec(&self, sep: &T) -> Vec<T> {
1029+
fn connect(&self, sep: &T) -> Vec<T> {
10181030
let size = self.iter().fold(0u, |acc, v| acc + v.as_slice().len());
10191031
let mut result = Vec::with_capacity(size + self.len());
10201032
let mut first = true;

branches/snap-stage3/src/libcollections/str.rs

Lines changed: 5 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ use slice::SliceExt;
7777
use string::String;
7878
use unicode;
7979
use vec::Vec;
80+
use slice::SliceConcatExt;
8081

8182
pub use core::str::{from_utf8, CharEq, Chars, CharIndices};
8283
pub use core::str::{Bytes, CharSplits, is_utf8};
@@ -93,36 +94,7 @@ pub use core::str::{SplitN, RSplitN};
9394
Section: Creating a string
9495
*/
9596

96-
/// Methods for vectors of strings.
97-
#[unstable = "functionality may be replaced with iterators"]
98-
pub trait StrVector for Sized? {
99-
/// Concatenates a vector of strings.
100-
///
101-
/// # Examples
102-
///
103-
/// ```rust
104-
/// let first = "Restaurant at the End of the".to_string();
105-
/// let second = " Universe".to_string();
106-
/// let string_vec = vec![first, second];
107-
/// assert_eq!(string_vec.concat(), "Restaurant at the End of the Universe".to_string());
108-
/// ```
109-
fn concat(&self) -> String;
110-
111-
/// Concatenates a vector of strings, placing a given separator between each.
112-
///
113-
/// # Examples
114-
///
115-
/// ```rust
116-
/// let first = "Roast".to_string();
117-
/// let second = "Sirloin Steak".to_string();
118-
/// let string_vec = vec![first, second];
119-
/// assert_eq!(string_vec.connect(", "), "Roast, Sirloin Steak".to_string());
120-
/// ```
121-
fn connect(&self, sep: &str) -> String;
122-
}
123-
124-
#[allow(deprecated)]
125-
impl<S: Str> StrVector for [S] {
97+
impl<S: Str> SliceConcatExt<str, String> for [S] {
12698
fn concat(&self) -> String {
12799
if self.is_empty() {
128100
return String::new();
@@ -169,16 +141,9 @@ impl<S: Str> StrVector for [S] {
169141
}
170142
}
171143

172-
impl<S: Str, T: AsSlice<S>> StrVector for T {
173-
#[inline]
174-
fn concat(&self) -> String {
175-
self.as_slice().concat()
176-
}
177-
178-
#[inline]
179-
fn connect(&self, sep: &str) -> String {
180-
self.as_slice().connect(sep)
181-
}
144+
impl<S: Str> SliceConcatExt<str, String> for Vec<S> {
145+
fn concat(&self) -> String { self[].concat() }
146+
fn connect(&self, sep: &str) -> String { self[].connect(sep) }
182147
}
183148

184149
/*

branches/snap-stage3/src/libstd/path/posix.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use option::Option::{None, Some};
2222
use kinds::Sized;
2323
use str::{FromStr, Str};
2424
use str;
25-
use slice::{CloneSliceExt, Splits, AsSlice, VectorVector,
25+
use slice::{CloneSliceExt, Split, AsSlice, SliceConcatExt,
2626
PartialEqSliceExt, SliceExt};
2727
use vec::Vec;
2828

@@ -306,7 +306,7 @@ impl GenericPath for Path {
306306
}
307307
}
308308
}
309-
Some(Path::new(comps.connect_vec(&SEP_BYTE)))
309+
Some(Path::new(comps.as_slice().connect(&SEP_BYTE)))
310310
}
311311
}
312312

branches/snap-stage3/src/libstd/path/windows.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ use iter::{Iterator, IteratorExt, Map, repeat};
2525
use mem;
2626
use option::Option;
2727
use option::Option::{Some, None};
28-
use slice::SliceExt;
29-
use str::{SplitTerminator, FromStr, StrVector, StrExt};
28+
use slice::{AsSlice, SliceExt, SliceConcatExt};
29+
use str::{CharSplits, FromStr, Str, StrAllocating, StrPrelude};
3030
use string::{String, ToString};
3131
use unicode::char::UnicodeChar;
3232
use vec::Vec;

branches/snap-stage3/src/libstd/prelude.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,9 @@
8080
#[doc(no_inline)] pub use core::prelude::{Tuple1, Tuple2, Tuple3, Tuple4};
8181
#[doc(no_inline)] pub use core::prelude::{Tuple5, Tuple6, Tuple7, Tuple8};
8282
#[doc(no_inline)] pub use core::prelude::{Tuple9, Tuple10, Tuple11, Tuple12};
83-
#[doc(no_inline)] pub use str::{Str, StrVector};
84-
#[doc(no_inline)] pub use str::StrExt;
83+
#[doc(no_inline)] pub use str::{Str, StrExt};
8584
#[doc(no_inline)] pub use slice::AsSlice;
86-
#[doc(no_inline)] pub use slice::{VectorVector, PartialEqSliceExt};
85+
#[doc(no_inline)] pub use slice::{SliceConcatExt, PartialEqSliceExt};
8786
#[doc(no_inline)] pub use slice::{CloneSliceExt, OrdSliceExt, SliceExt};
8887
#[doc(no_inline)] pub use slice::{BoxedSliceExt};
8988
#[doc(no_inline)] pub use string::{IntoString, String, ToString};

0 commit comments

Comments
 (0)