Skip to content

Commit 11c6817

Browse files
committed
auto merge of #13090 : thestinger/rust/iter, r=Aatch
This has been rendered obsolete by partial type hints. Since the `~[T]` type is in the process of being removed, it needs to go away.
2 parents 2ddb605 + ae42905 commit 11c6817

File tree

18 files changed

+48
-61
lines changed

18 files changed

+48
-61
lines changed

src/compiletest/runtest.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ fn run_debuginfo_test(config: &config, props: &TestProps, testfile: &Path) {
452452
let options_to_remove = [~"-O", ~"-g", ~"--debuginfo"];
453453
let new_options = split_maybe_args(options).move_iter()
454454
.filter(|x| !options_to_remove.contains(x))
455-
.to_owned_vec()
455+
.collect::<~[~str]>()
456456
.connect(" ");
457457
Some(new_options)
458458
}

src/libglob/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ impl Pattern {
223223
*/
224224
pub fn new(pattern: &str) -> Pattern {
225225

226-
let chars = pattern.chars().to_owned_vec();
226+
let chars = pattern.chars().collect::<~[_]>();
227227
let mut tokens = Vec::new();
228228
let mut i = 0;
229229

src/librand/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -826,7 +826,7 @@ mod test {
826826
let max_val = 100;
827827

828828
let mut r = task_rng();
829-
let vals = range(min_val, max_val).to_owned_vec();
829+
let vals = range(min_val, max_val).collect::<~[int]>();
830830
let small_sample = r.sample(vals.iter(), 5);
831831
let large_sample = r.sample(vals.iter(), vals.len() + 5);
832832

src/librustc/metadata/creader.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ fn visit_item(e: &Env, i: &ast::Item) {
197197
} else {
198198
None
199199
})
200-
.to_owned_vec();
200+
.collect::<~[&ast::Attribute]>();
201201
for m in link_args.iter() {
202202
match m.value_str() {
203203
Some(linkarg) => e.sess.cstore.add_used_link_args(linkarg.get()),
@@ -212,7 +212,7 @@ fn visit_item(e: &Env, i: &ast::Item) {
212212
} else {
213213
None
214214
})
215-
.to_owned_vec();
215+
.collect::<~[&ast::Attribute]>();
216216
for m in link_args.iter() {
217217
match m.meta_item_list() {
218218
Some(items) => {

src/librustc/middle/trans/base.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ fn get_extern_rust_fn(ccx: &CrateContext, inputs: &[ty::t], output: ty::t,
236236

237237
let f = decl_rust_fn(ccx, false, inputs, output, name);
238238
csearch::get_item_attrs(&ccx.sess().cstore, did, |meta_items| {
239-
set_llvm_fn_attrs(meta_items.iter().map(|&x| attr::mk_attr(x)).to_owned_vec(), f)
239+
set_llvm_fn_attrs(meta_items.iter().map(|&x| attr::mk_attr(x)).collect::<~[_]>(), f)
240240
});
241241

242242
ccx.externs.borrow_mut().insert(name.to_owned(), f);

src/librustc/middle/trans/consts.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ fn const_expr_unadjusted(cx: &CrateContext, e: &ast::Expr,
538538
};
539539

540540
expr::with_field_tys(tcx, ety, Some(e.id), |discr, field_tys| {
541-
let cs = field_tys.iter().enumerate()
541+
let (cs, inlineable) = slice::unzip(field_tys.iter().enumerate()
542542
.map(|(ix, &field_ty)| {
543543
match fs.iter().find(|f| field_ty.ident.name == f.ident.node.name) {
544544
Some(f) => const_expr(cx, (*f).expr, is_local),
@@ -552,8 +552,7 @@ fn const_expr_unadjusted(cx: &CrateContext, e: &ast::Expr,
552552
}
553553
}
554554
}
555-
}).to_owned_vec();
556-
let (cs, inlineable) = slice::unzip(cs.move_iter());
555+
}));
557556
(adt::trans_const(cx, repr, discr, cs),
558557
inlineable.iter().fold(true, |a, &b| a && b))
559558
})

src/librustdoc/html/markdown.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ pub fn render(w: &mut io::Writer, s: &str, print_toc: bool) -> fmt::Result {
133133
slice::raw::buf_as_slice((*text).data, (*text).size as uint, |text| {
134134
let text = str::from_utf8(text).unwrap();
135135
let mut lines = text.lines().filter(|l| stripped_filtered_line(*l).is_none());
136-
let text = lines.to_owned_vec().connect("\n");
136+
let text = lines.collect::<~[&str]>().connect("\n");
137137

138138
let buf = buf {
139139
data: text.as_bytes().as_ptr(),
@@ -186,7 +186,7 @@ pub fn render(w: &mut io::Writer, s: &str, print_toc: bool) -> fmt::Result {
186186
Some(s) => s.to_lower().into_str(),
187187
None => s.to_owned()
188188
}
189-
}).to_owned_vec().connect("-");
189+
}).collect::<~[~str]>().connect("-");
190190

191191
let opaque = unsafe {&mut *(opaque as *mut my_opaque)};
192192

@@ -284,7 +284,7 @@ pub fn find_testable_code(doc: &str, tests: &mut ::test::Collector) {
284284
let tests = &mut *(opaque as *mut ::test::Collector);
285285
let text = str::from_utf8(text).unwrap();
286286
let mut lines = text.lines().map(|l| stripped_filtered_line(l).unwrap_or(l));
287-
let text = lines.to_owned_vec().connect("\n");
287+
let text = lines.collect::<~[&str]>().connect("\n");
288288
tests.add_test(text, should_fail, no_run);
289289
})
290290
}

src/librustdoc/html/render.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1205,8 +1205,8 @@ fn item_trait(w: &mut Writer, it: &clean::Item,
12051205
it.name.get_ref().as_slice(),
12061206
t.generics,
12071207
parents));
1208-
let required = t.methods.iter().filter(|m| m.is_req()).to_owned_vec();
1209-
let provided = t.methods.iter().filter(|m| !m.is_req()).to_owned_vec();
1208+
let required = t.methods.iter().filter(|m| m.is_req()).collect::<~[&clean::TraitMethod]>();
1209+
let provided = t.methods.iter().filter(|m| !m.is_req()).collect::<~[&clean::TraitMethod]>();
12101210

12111211
if t.methods.len() == 0 {
12121212
try!(write!(w, "\\{ \\}"));
@@ -1502,11 +1502,11 @@ fn render_methods(w: &mut Writer, it: &clean::Item) -> fmt::Result {
15021502
let mut non_trait = v.iter().filter(|p| {
15031503
p.ref0().trait_.is_none()
15041504
});
1505-
let non_trait = non_trait.to_owned_vec();
1505+
let non_trait = non_trait.collect::<~[&(clean::Impl, Option<~str>)]>();
15061506
let mut traits = v.iter().filter(|p| {
15071507
p.ref0().trait_.is_some()
15081508
});
1509-
let traits = traits.to_owned_vec();
1509+
let traits = traits.collect::<~[&(clean::Impl, Option<~str>)]>();
15101510

15111511
if non_trait.len() > 0 {
15121512
try!(write!(w, "<h2 id='methods'>Methods</h2>"));

src/libstd/ascii.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ unsafe fn str_map_bytes(string: ~str, map: &'static [u8]) -> ~str {
400400

401401
#[inline]
402402
unsafe fn str_copy_map_bytes(string: &str, map: &'static [u8]) -> ~str {
403-
let bytes = string.bytes().map(|b| map[b]).to_owned_vec();
403+
let bytes = string.bytes().map(|b| map[b]).collect::<~[_]>();
404404

405405
str::raw::from_utf8_owned(bytes)
406406
}

src/libstd/iter.rs

-15
Original file line numberDiff line numberDiff line change
@@ -463,21 +463,6 @@ pub trait Iterator<A> {
463463
FromIterator::from_iterator(self)
464464
}
465465

466-
/// Loops through the entire iterator, collecting all of the elements into
467-
/// a unique vector. This is simply collect() specialized for vectors.
468-
///
469-
/// # Example
470-
///
471-
/// ```rust
472-
/// let a = [1, 2, 3, 4, 5];
473-
/// let b: ~[int] = a.iter().map(|&x| x).to_owned_vec();
474-
/// assert!(a == b);
475-
/// ```
476-
#[inline]
477-
fn to_owned_vec(&mut self) -> ~[A] {
478-
self.collect()
479-
}
480-
481466
/// Loops through `n` iterations, returning the `n`th element of the
482467
/// iterator.
483468
///

src/libstd/path/posix.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -1179,26 +1179,26 @@ mod tests {
11791179
(s: $path:expr, $exp:expr) => (
11801180
{
11811181
let path = Path::new($path);
1182-
let comps = path.components().to_owned_vec();
1182+
let comps = path.components().collect::<~[&[u8]]>();
11831183
let exp: &[&str] = $exp;
1184-
let exps = exp.iter().map(|x| x.as_bytes()).to_owned_vec();
1184+
let exps = exp.iter().map(|x| x.as_bytes()).collect::<~[&[u8]]>();
11851185
assert!(comps == exps, "components: Expected {:?}, found {:?}",
11861186
comps, exps);
1187-
let comps = path.rev_components().to_owned_vec();
1188-
let exps = exps.move_rev_iter().to_owned_vec();
1187+
let comps = path.rev_components().collect::<~[&[u8]]>();
1188+
let exps = exps.move_rev_iter().collect::<~[&[u8]]>();
11891189
assert!(comps == exps, "rev_components: Expected {:?}, found {:?}",
11901190
comps, exps);
11911191
}
11921192
);
11931193
(v: [$($arg:expr),+], [$([$($exp:expr),*]),*]) => (
11941194
{
11951195
let path = Path::new(b!($($arg),+));
1196-
let comps = path.components().to_owned_vec();
1196+
let comps = path.components().collect::<~[&[u8]]>();
11971197
let exp: &[&[u8]] = [$(b!($($exp),*)),*];
11981198
assert!(comps.as_slice() == exp, "components: Expected {:?}, found {:?}",
11991199
comps.as_slice(), exp);
1200-
let comps = path.rev_components().to_owned_vec();
1201-
let exp = exp.rev_iter().map(|&x|x).to_owned_vec();
1200+
let comps = path.rev_components().collect::<~[&[u8]]>();
1201+
let exp = exp.rev_iter().map(|&x|x).collect::<~[&[u8]]>();
12021202
assert!(comps.as_slice() == exp,
12031203
"rev_components: Expected {:?}, found {:?}",
12041204
comps.as_slice(), exp);
@@ -1228,13 +1228,13 @@ mod tests {
12281228
(v: [$($arg:expr),+], $exp:expr) => (
12291229
{
12301230
let path = Path::new(b!($($arg),+));
1231-
let comps = path.str_components().to_owned_vec();
1231+
let comps = path.str_components().collect::<~[Option<&str>]>();
12321232
let exp: &[Option<&str>] = $exp;
12331233
assert!(comps.as_slice() == exp,
12341234
"str_components: Expected {:?}, found {:?}",
12351235
comps.as_slice(), exp);
1236-
let comps = path.rev_str_components().to_owned_vec();
1237-
let exp = exp.rev_iter().map(|&x|x).to_owned_vec();
1236+
let comps = path.rev_str_components().collect::<~[Option<&str>]>();
1237+
let exp = exp.rev_iter().map(|&x|x).collect::<~[Option<&str>]>();
12381238
assert!(comps.as_slice() == exp,
12391239
"rev_str_components: Expected {:?}, found {:?}",
12401240
comps.as_slice(), exp);

src/libstd/path/windows.rs

+12-9
Original file line numberDiff line numberDiff line change
@@ -2226,13 +2226,15 @@ mod tests {
22262226
(s: $path:expr, $exp:expr) => (
22272227
{
22282228
let path = Path::new($path);
2229-
let comps = path.str_components().map(|x|x.unwrap()).to_owned_vec();
2229+
let comps = path.str_components().map(|x|x.unwrap())
2230+
.collect::<~[&str]>();
22302231
let exp: &[&str] = $exp;
22312232
assert!(comps.as_slice() == exp,
22322233
"str_components: Expected {:?}, found {:?}",
22332234
comps.as_slice(), exp);
2234-
let comps = path.rev_str_components().map(|x|x.unwrap()).to_owned_vec();
2235-
let exp = exp.rev_iter().map(|&x|x).to_owned_vec();
2235+
let comps = path.rev_str_components().map(|x|x.unwrap())
2236+
.collect::<~[&str]>();
2237+
let exp = exp.rev_iter().map(|&x|x).collect::<~[&str]>();
22362238
assert!(comps.as_slice() == exp,
22372239
"rev_str_components: Expected {:?}, found {:?}",
22382240
comps.as_slice(), exp);
@@ -2241,13 +2243,14 @@ mod tests {
22412243
(v: [$($arg:expr),+], $exp:expr) => (
22422244
{
22432245
let path = Path::new(b!($($arg),+));
2244-
let comps = path.str_components().map(|x|x.unwrap()).to_owned_vec();
2246+
let comps = path.str_components().map(|x|x.unwrap()).collect::<~[&str]>();
22452247
let exp: &[&str] = $exp;
22462248
assert!(comps.as_slice() == exp,
22472249
"str_components: Expected {:?}, found {:?}",
22482250
comps.as_slice(), exp);
2249-
let comps = path.rev_str_components().map(|x|x.unwrap()).to_owned_vec();
2250-
let exp = exp.rev_iter().map(|&x|x).to_owned_vec();
2251+
let comps = path.rev_str_components().map(|x|x.unwrap())
2252+
.collect::<~[&str]>();
2253+
let exp = exp.rev_iter().map(|&x|x).collect::<~[&str]>();
22512254
assert!(comps.as_slice() == exp,
22522255
"rev_str_components: Expected {:?}, found {:?}",
22532256
comps.as_slice(), exp);
@@ -2301,12 +2304,12 @@ mod tests {
23012304
(s: $path:expr, $exp:expr) => (
23022305
{
23032306
let path = Path::new($path);
2304-
let comps = path.components().to_owned_vec();
2307+
let comps = path.components().collect::<~[&[u8]]>();
23052308
let exp: &[&[u8]] = $exp;
23062309
assert!(comps.as_slice() == exp, "components: Expected {:?}, found {:?}",
23072310
comps.as_slice(), exp);
2308-
let comps = path.rev_components().to_owned_vec();
2309-
let exp = exp.rev_iter().map(|&x|x).to_owned_vec();
2311+
let comps = path.rev_components().collect::<~[&[u8]]>();
2312+
let exp = exp.rev_iter().map(|&x|x).collect::<~[&[u8]]>();
23102313
assert!(comps.as_slice() == exp,
23112314
"rev_components: Expected {:?}, found {:?}",
23122315
comps.as_slice(), exp);

src/libstd/slice.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ impl ElementSwaps {
436436
emit_reset: true,
437437
sdir: range(0, length)
438438
.map(|i| SizeDirection{ size: i, dir: Neg })
439-
.to_owned_vec()
439+
.collect::<~[_]>()
440440
}
441441
}
442442
}
@@ -3539,7 +3539,7 @@ mod tests {
35393539
let n = task_rng().gen::<uint>() % 10;
35403540
counts[n] += 1;
35413541
(n, counts[n])
3542-
}).to_owned_vec();
3542+
}).collect::<~[(uint, int)]>();
35433543

35443544
// only sort on the first element, so an unstable sort
35453545
// may mix up the counts.
@@ -4207,7 +4207,7 @@ mod tests {
42074207
assert_eq!(xs.capacity(), 128);
42084208
xs.shrink_to_fit();
42094209
assert_eq!(xs.capacity(), 100);
4210-
assert_eq!(xs, range(0, 100).to_owned_vec());
4210+
assert_eq!(xs, range(0, 100).collect::<~[_]>());
42114211
}
42124212
42134213
#[test]

src/libstd/str.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -937,7 +937,7 @@ impl<'a> Iterator<UTF16Item> for UTF16Items<'a> {
937937
/// 0x0073, 0xDD1E, 0x0069, 0x0063,
938938
/// 0xD834];
939939
///
940-
/// assert_eq!(str::utf16_items(v).to_owned_vec(),
940+
/// assert_eq!(str::utf16_items(v).collect::<~[_]>(),
941941
/// ~[ScalarValue('𝄞'),
942942
/// ScalarValue('m'), ScalarValue('u'), ScalarValue('s'),
943943
/// LoneSurrogate(0xDD1E),

src/libstd/sync/deque.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ mod tests {
494494
}
495495
}
496496
})
497-
}).to_owned_vec();
497+
}).collect::<~[Thread<()>]>();
498498

499499
while remaining.load(SeqCst) > 0 {
500500
match w.pop() {
@@ -525,7 +525,7 @@ mod tests {
525525
Thread::start(proc() {
526526
stampede(w, s, 4, 10000);
527527
})
528-
}).to_owned_vec();
528+
}).collect::<~[Thread<()>]>();
529529

530530
for thread in threads.move_iter() {
531531
thread.join();
@@ -556,7 +556,7 @@ mod tests {
556556
}
557557
}
558558
})
559-
}).to_owned_vec();
559+
}).collect::<~[Thread<()>]>();
560560

561561
let mut rng = rand::task_rng();
562562
let mut expected = 0;

src/test/bench/shootout-binarytrees.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ fn main() {
7676
format!("{}\t trees of depth {}\t check: {}",
7777
iterations * 2, depth, chk)
7878
})
79-
}).to_owned_vec();
79+
}).collect::<~[Future<~str>]>();
8080

8181
for message in messages.mut_iter() {
8282
println!("{}", *message.get_ref());

src/test/run-pass/send_str_treemap.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ pub fn main() {
6262
6363
assert!(map.pop(&Slice("foo")).is_some());
6464
assert_eq!(map.move_iter().map(|(k, v)| k.to_str() + v.to_str())
65-
.to_owned_vec()
65+
.collect::<~[~str]>()
6666
.concat(),
6767
~"abc50bcd51cde52def53");
6868
}

src/test/run-pass/trait-to-str.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ impl to_str for int {
2121

2222
impl<T:to_str> to_str for Vec<T> {
2323
fn to_string(&self) -> ~str {
24-
format!("[{}]", self.iter().map(|e| e.to_string()).to_owned_vec().connect(", "))
24+
format!("[{}]", self.iter().map(|e| e.to_string()).collect::<~[~str]>().connect(", "))
2525
}
2626
}
2727

0 commit comments

Comments
 (0)