Skip to content

Commit 3709aa7

Browse files
author
blake2-ppc
committed
std::vec: Remove functions concat, connect
std::vec::{concat, connect, concat_slices, connect_slices} are replaced by the already existing trait methods .concat_vec() and .connect_vec().
1 parent 24a4d0d commit 3709aa7

File tree

3 files changed

+12
-28
lines changed

3 files changed

+12
-28
lines changed

src/librustc/middle/check_match.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -773,12 +773,12 @@ pub fn specialize(cx: &MatchCheckCtxt,
773773
let num_elements = before.len() + after.len();
774774
if num_elements < arity && slice.is_some() {
775775
Some(vec::append(
776-
vec::concat(&[
776+
[
777777
before,
778778
vec::from_elem(
779779
arity - num_elements, wild()),
780780
after
781-
]),
781+
].concat_vec(),
782782
r.tail()
783783
))
784784
} else if num_elements == arity {

src/librustdoc/clean.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -173,12 +173,11 @@ impl Clean<Item> for doctree::Module {
173173
visibility: self.vis.clean(),
174174
id: self.id,
175175
inner: ModuleItem(Module {
176-
items: std::vec::concat(&[self.structs.clean(),
177-
self.enums.clean(), self.fns.clean(),
178-
std::vec::concat(self.foreigns.clean()),
179-
self.mods.clean(), self.typedefs.clean(),
180-
self.statics.clean(), self.traits.clean(),
181-
self.impls.clean(), self.view_items.clean()])
176+
items: [self.structs.clean(), self.enums.clean(),
177+
self.fns.clean(), self.foreigns.clean().concat_vec(),
178+
self.mods.clean(), self.typedefs.clean(),
179+
self.statics.clean(), self.traits.clean(),
180+
self.impls.clean(), self.view_items.clean()].concat_vec()
182181
})
183182
}
184183
}

src/libstd/vec.rs

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -340,18 +340,6 @@ pub fn flat_map<T, U>(v: &[T], f: &fn(t: &T) -> ~[U]) -> ~[U] {
340340
result
341341
}
342342

343-
/// Flattens a vector of vectors of T into a single vector of T.
344-
pub fn concat<T:Clone>(v: &[~[T]]) -> ~[T] { v.concat_vec() }
345-
346-
/// Concatenate a vector of vectors, placing a given separator between each
347-
pub fn connect<T:Clone>(v: &[~[T]], sep: &T) -> ~[T] { v.connect_vec(sep) }
348-
349-
/// Flattens a vector of vectors of T into a single vector of T.
350-
pub fn concat_slices<T:Clone>(v: &[&[T]]) -> ~[T] { v.concat_vec() }
351-
352-
/// Concatenate a vector of vectors, placing a given separator between each
353-
pub fn connect_slices<T:Clone>(v: &[&[T]], sep: &T) -> ~[T] { v.connect_vec(sep) }
354-
355343
#[allow(missing_doc)]
356344
pub trait VectorVector<T> {
357345
// FIXME #5898: calling these .concat and .connect conflicts with
@@ -3098,24 +3086,21 @@ mod tests {
30983086

30993087
#[test]
31003088
fn test_concat() {
3101-
assert_eq!(concat([~[1], ~[2,3]]), ~[1, 2, 3]);
3089+
let v: [~[int], ..0] = [];
3090+
assert_eq!(v.concat_vec(), ~[]);
31023091
assert_eq!([~[1], ~[2,3]].concat_vec(), ~[1, 2, 3]);
31033092

3104-
assert_eq!(concat_slices([&[1], &[2,3]]), ~[1, 2, 3]);
31053093
assert_eq!([&[1], &[2,3]].concat_vec(), ~[1, 2, 3]);
31063094
}
31073095

31083096
#[test]
31093097
fn test_connect() {
3110-
assert_eq!(connect([], &0), ~[]);
3111-
assert_eq!(connect([~[1], ~[2, 3]], &0), ~[1, 0, 2, 3]);
3112-
assert_eq!(connect([~[1], ~[2], ~[3]], &0), ~[1, 0, 2, 0, 3]);
3098+
let v: [~[int], ..0] = [];
3099+
assert_eq!(v.connect_vec(&0), ~[]);
31133100
assert_eq!([~[1], ~[2, 3]].connect_vec(&0), ~[1, 0, 2, 3]);
31143101
assert_eq!([~[1], ~[2], ~[3]].connect_vec(&0), ~[1, 0, 2, 0, 3]);
31153102

3116-
assert_eq!(connect_slices([], &0), ~[]);
3117-
assert_eq!(connect_slices([&[1], &[2, 3]], &0), ~[1, 0, 2, 3]);
3118-
assert_eq!(connect_slices([&[1], &[2], &[3]], &0), ~[1, 0, 2, 0, 3]);
3103+
assert_eq!(v.connect_vec(&0), ~[]);
31193104
assert_eq!([&[1], &[2, 3]].connect_vec(&0), ~[1, 0, 2, 3]);
31203105
assert_eq!([&[1], &[2], &[3]].connect_vec(&0), ~[1, 0, 2, 0, 3]);
31213106
}

0 commit comments

Comments
 (0)