Skip to content

Commit

Permalink
std::vec: Remove functions concat, connect
Browse files Browse the repository at this point in the history
std::vec::{concat, connect, concat_slices, connect_slices} are replaced
by the already existing trait methods .concat_vec() and .connect_vec().
  • Loading branch information
blake2-ppc committed Sep 28, 2013
1 parent 24a4d0d commit 3709aa7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 28 deletions.
4 changes: 2 additions & 2 deletions src/librustc/middle/check_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -773,12 +773,12 @@ pub fn specialize(cx: &MatchCheckCtxt,
let num_elements = before.len() + after.len();
if num_elements < arity && slice.is_some() {
Some(vec::append(
vec::concat(&[
[
before,
vec::from_elem(
arity - num_elements, wild()),
after
]),
].concat_vec(),
r.tail()
))
} else if num_elements == arity {
Expand Down
11 changes: 5 additions & 6 deletions src/librustdoc/clean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,11 @@ impl Clean<Item> for doctree::Module {
visibility: self.vis.clean(),
id: self.id,
inner: ModuleItem(Module {
items: std::vec::concat(&[self.structs.clean(),
self.enums.clean(), self.fns.clean(),
std::vec::concat(self.foreigns.clean()),
self.mods.clean(), self.typedefs.clean(),
self.statics.clean(), self.traits.clean(),
self.impls.clean(), self.view_items.clean()])
items: [self.structs.clean(), self.enums.clean(),
self.fns.clean(), self.foreigns.clean().concat_vec(),
self.mods.clean(), self.typedefs.clean(),
self.statics.clean(), self.traits.clean(),
self.impls.clean(), self.view_items.clean()].concat_vec()
})
}
}
Expand Down
25 changes: 5 additions & 20 deletions src/libstd/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,18 +340,6 @@ pub fn flat_map<T, U>(v: &[T], f: &fn(t: &T) -> ~[U]) -> ~[U] {
result
}

/// Flattens a vector of vectors of T into a single vector of T.
pub fn concat<T:Clone>(v: &[~[T]]) -> ~[T] { v.concat_vec() }

/// Concatenate a vector of vectors, placing a given separator between each
pub fn connect<T:Clone>(v: &[~[T]], sep: &T) -> ~[T] { v.connect_vec(sep) }

/// Flattens a vector of vectors of T into a single vector of T.
pub fn concat_slices<T:Clone>(v: &[&[T]]) -> ~[T] { v.concat_vec() }

/// Concatenate a vector of vectors, placing a given separator between each
pub fn connect_slices<T:Clone>(v: &[&[T]], sep: &T) -> ~[T] { v.connect_vec(sep) }

#[allow(missing_doc)]
pub trait VectorVector<T> {
// FIXME #5898: calling these .concat and .connect conflicts with
Expand Down Expand Up @@ -3098,24 +3086,21 @@ mod tests {

#[test]
fn test_concat() {
assert_eq!(concat([~[1], ~[2,3]]), ~[1, 2, 3]);
let v: [~[int], ..0] = [];
assert_eq!(v.concat_vec(), ~[]);
assert_eq!([~[1], ~[2,3]].concat_vec(), ~[1, 2, 3]);

assert_eq!(concat_slices([&[1], &[2,3]]), ~[1, 2, 3]);
assert_eq!([&[1], &[2,3]].concat_vec(), ~[1, 2, 3]);
}

#[test]
fn test_connect() {
assert_eq!(connect([], &0), ~[]);
assert_eq!(connect([~[1], ~[2, 3]], &0), ~[1, 0, 2, 3]);
assert_eq!(connect([~[1], ~[2], ~[3]], &0), ~[1, 0, 2, 0, 3]);
let v: [~[int], ..0] = [];
assert_eq!(v.connect_vec(&0), ~[]);
assert_eq!([~[1], ~[2, 3]].connect_vec(&0), ~[1, 0, 2, 3]);
assert_eq!([~[1], ~[2], ~[3]].connect_vec(&0), ~[1, 0, 2, 0, 3]);

assert_eq!(connect_slices([], &0), ~[]);
assert_eq!(connect_slices([&[1], &[2, 3]], &0), ~[1, 0, 2, 3]);
assert_eq!(connect_slices([&[1], &[2], &[3]], &0), ~[1, 0, 2, 0, 3]);
assert_eq!(v.connect_vec(&0), ~[]);
assert_eq!([&[1], &[2, 3]].connect_vec(&0), ~[1, 0, 2, 3]);
assert_eq!([&[1], &[2], &[3]].connect_vec(&0), ~[1, 0, 2, 0, 3]);
}
Expand Down

9 comments on commit 3709aa7

@bors
Copy link
Contributor

@bors bors commented on 3709aa7 Sep 28, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on 3709aa7 Sep 28, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging blake2-ppc/rust/connect-vec = 3709aa7 into auto

@bors
Copy link
Contributor

@bors bors commented on 3709aa7 Sep 28, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

blake2-ppc/rust/connect-vec = 3709aa7 merged ok, testing candidate = 6a66414e

@bors
Copy link
Contributor

@bors bors commented on 3709aa7 Sep 28, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on 3709aa7 Sep 28, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging blake2-ppc/rust/connect-vec = 3709aa7 into auto

@bors
Copy link
Contributor

@bors bors commented on 3709aa7 Sep 28, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

blake2-ppc/rust/connect-vec = 3709aa7 merged ok, testing candidate = c635fba

@bors
Copy link
Contributor

@bors bors commented on 3709aa7 Sep 28, 2013

@bors
Copy link
Contributor

@bors bors commented on 3709aa7 Sep 28, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = c635fba

Please sign in to comment.