auto merge of #7566 : huonw/rust/vec-kill, r=cmr

The last remaining internal iterator in `vec` is `each_permutation`.
This commit is contained in:
bors 2013-07-03 08:16:54 -07:00
commit 0c6fc46c03
58 changed files with 826 additions and 1206 deletions

View file

@ -601,9 +601,8 @@ fn make_run_args(config: &config, _props: &TestProps, testfile: &Path) ->
ProcArgs {
// If we've got another tool to run under (valgrind),
// then split apart its command
let toolargs = split_maybe_args(&config.runtool);
let mut args = toolargs + [make_exe_name(config, testfile).to_str()];
let mut args = split_maybe_args(&config.runtool);
args.push(make_exe_name(config, testfile).to_str());
let prog = args.shift();
return ProcArgs {prog: prog, args: args};
}

View file

@ -240,7 +240,6 @@ impl Digest for Sha1 {
#[cfg(test)]
mod tests {
use std::vec;
use digest::{Digest, DigestUtil};
use sha1::Sha1;
@ -337,7 +336,7 @@ mod tests {
for tests.iter().advance |t| {
(*sh).input_str(t.input);
sh.result(out);
assert!(vec::eq(t.output, out));
assert!(t.output.as_slice() == out);
let out_str = (*sh).result_str();
assert_eq!(out_str.len(), 40);
@ -357,7 +356,7 @@ mod tests {
left = left - take;
}
sh.result(out);
assert!(vec::eq(t.output, out));
assert!(t.output.as_slice() == out);
let out_str = (*sh).result_str();
assert_eq!(out_str.len(), 40);

View file

@ -45,7 +45,7 @@ static LZ_NORM : c_int = 0x80; // LZ with 128 probes, "normal"
static LZ_BEST : c_int = 0xfff; // LZ with 4095 probes, "best"
pub fn deflate_bytes(bytes: &[u8]) -> ~[u8] {
do vec::as_imm_buf(bytes) |b, len| {
do bytes.as_imm_buf |b, len| {
unsafe {
let mut outsz : size_t = 0;
let res =
@ -63,7 +63,7 @@ pub fn deflate_bytes(bytes: &[u8]) -> ~[u8] {
}
pub fn inflate_bytes(bytes: &[u8]) -> ~[u8] {
do vec::as_imm_buf(bytes) |b, len| {
do bytes.as_imm_buf |b, len| {
unsafe {
let mut outsz : size_t = 0;
let res =

View file

@ -55,7 +55,6 @@ use std::io;
use std::comm::GenericChan;
use std::comm::GenericPort;
use std::sys::size_of;
use std::vec;
/**
A FlatPort, consisting of a `BytePort` that receives byte vectors,
@ -274,7 +273,7 @@ impl<T,U:Unflattener<T>,P:BytePort> GenericPort<T> for FlatPort<T, U, P> {
}
};
if vec::eq(command, CONTINUE) {
if CONTINUE.as_slice() == command {
let msg_len = match self.byte_port.try_recv(size_of::<u64>()) {
Some(bytes) => {
io::u64_from_be_bytes(bytes, 0, size_of::<u64>())
@ -931,7 +930,7 @@ mod test {
fn test_try_recv_none3<P:BytePort>(loader: PortLoader<P>) {
static CONTINUE: [u8, ..4] = [0xAA, 0xBB, 0xCC, 0xDD];
// The control word is followed by garbage
let bytes = CONTINUE.to_owned() + [0];
let bytes = CONTINUE.to_owned() + &[0u8];
let port = loader(bytes);
let res: Option<int> = port.try_recv();
assert!(res.is_none());
@ -955,7 +954,7 @@ mod test {
1, sys::size_of::<u64>()) |len_bytes| {
len_bytes.to_owned()
};
let bytes = CONTINUE.to_owned() + len_bytes + [0, 0, 0, 0];
let bytes = CONTINUE.to_owned() + len_bytes + &[0u8, 0, 0, 0];
let port = loader(bytes);

View file

@ -24,7 +24,6 @@ use std::io::{WriterUtil, ReaderUtil};
use std::io;
use std::str;
use std::to_str;
use std::vec;
use serialize::Encodable;
use serialize;
@ -941,7 +940,7 @@ impl serialize::Decoder for Decoder {
let name = match self.stack.pop() {
String(s) => s,
List(list) => {
do vec::consume_reverse(list) |_i, v| {
for list.consume_rev_iter().advance |v| {
self.stack.push(v);
}
match self.stack.pop() {
@ -1059,7 +1058,7 @@ impl serialize::Decoder for Decoder {
let len = match self.stack.pop() {
List(list) => {
let len = list.len();
do vec::consume_reverse(list) |_i, v| {
for list.consume_rev_iter().advance |v| {
self.stack.push(v);
}
len

View file

@ -207,7 +207,7 @@ impl Add<BigUint, BigUint> for BigUint {
let new_len = uint::max(self.data.len(), other.data.len());
let mut carry = 0;
let sum = do vec::from_fn(new_len) |i| {
let mut sum = do vec::from_fn(new_len) |i| {
let ai = if i < self.data.len() { self.data[i] } else { 0 };
let bi = if i < other.data.len() { other.data[i] } else { 0 };
let (hi, lo) = BigDigit::from_uint(
@ -216,8 +216,8 @@ impl Add<BigUint, BigUint> for BigUint {
carry = hi;
lo
};
if carry == 0 { return BigUint::new(sum) };
return BigUint::new(sum + [carry]);
if carry != 0 { sum.push(carry); }
return BigUint::new(sum);
}
}
@ -284,15 +284,15 @@ impl Mul<BigUint, BigUint> for BigUint {
if n == 1 { return copy *a; }
let mut carry = 0;
let prod = do a.data.iter().transform |ai| {
let mut prod = do a.data.iter().transform |ai| {
let (hi, lo) = BigDigit::from_uint(
(*ai as uint) * (n as uint) + (carry as uint)
);
carry = hi;
lo
}.collect::<~[BigDigit]>();
if carry == 0 { return BigUint::new(prod) };
return BigUint::new(prod + [carry]);
if carry != 0 { prod.push(carry); }
return BigUint::new(prod);
}
@ -520,10 +520,12 @@ impl ToStrRadix for BigUint {
fn fill_concat(v: &[BigDigit], radix: uint, l: uint) -> ~str {
if v.is_empty() { return ~"0" }
let s = vec::reversed(v).map(|n| {
let s = uint::to_str_radix(*n as uint, radix);
str::from_chars(vec::from_elem(l - s.len(), '0')) + s
}).concat();
let mut s = str::with_capacity(v.len() * l);
for v.rev_iter().advance |n| {
let ss = uint::to_str_radix(*n as uint, radix);
s.push_str("0".repeat(l - ss.len()));
s.push_str(ss);
}
s.trim_left_chars(&'0').to_owned()
}
}
@ -619,15 +621,15 @@ impl BigUint {
if n_bits == 0 || self.is_zero() { return copy *self; }
let mut carry = 0;
let shifted = do self.data.iter().transform |elem| {
let mut shifted = do self.data.iter().transform |elem| {
let (hi, lo) = BigDigit::from_uint(
(*elem as uint) << n_bits | (carry as uint)
);
carry = hi;
lo
}.collect::<~[BigDigit]>();
if carry == 0 { return BigUint::new(shifted); }
return BigUint::new(shifted + [carry]);
if carry != 0 { shifted.push(carry); }
return BigUint::new(shifted);
}
@ -1629,7 +1631,6 @@ mod bigint_tests {
use std::int;
use std::num::{IntConvertible, Zero, One, FromStrRadix};
use std::uint;
use std::vec;
#[test]
fn test_from_biguint() {
@ -1646,9 +1647,11 @@ mod bigint_tests {
#[test]
fn test_cmp() {
let vs = [ &[2], &[1, 1], &[2, 1], &[1, 1, 1] ];
let mut nums = vec::reversed(vs)
.map(|s| BigInt::from_slice(Minus, *s));
let vs = [ &[2 as BigDigit], &[1, 1], &[2, 1], &[1, 1, 1] ];
let mut nums = ~[];
for vs.rev_iter().advance |s| {
nums.push(BigInt::from_slice(Minus, *s));
}
nums.push(Zero::zero());
nums.push_all_move(vs.map(|s| BigInt::from_slice(Plus, *s)));

View file

@ -53,7 +53,7 @@ fn map_slices<A:Copy + Send,B:Copy + Send>(
info!("spawning tasks");
while base < len {
let end = uint::min(len, base + items_per_task);
do vec::as_imm_buf(xs) |p, _len| {
do xs.as_imm_buf |p, _len| {
let f = f();
let base = base;
let f = do future_spawn() || {
@ -78,11 +78,10 @@ fn map_slices<A:Copy + Send,B:Copy + Send>(
info!("num_tasks: %?", (num_tasks, futures.len()));
assert_eq!(num_tasks, futures.len());
let r = do vec::map_consume(futures) |ys| {
do futures.consume_iter().transform |ys| {
let mut ys = ys;
ys.get()
};
r
}.collect()
}
}

View file

@ -477,7 +477,7 @@ fn run_tests(opts: &TestOpts,
}
// All benchmarks run at the end, in serial.
do vec::consume(filtered_benchs) |_, b| {
for filtered_benchs.consume_iter().advance |b| {
callback(TeWait(copy b.desc));
run_test(!opts.run_benchmarks, b, ch.clone());
let (test, result) = p.recv();
@ -523,7 +523,7 @@ pub fn filter_tests(
} else { return option::None; }
}
vec::filter_map(filtered, |x| filter_fn(x, filter_str))
filtered.consume_iter().filter_map(|x| filter_fn(x, filter_str)).collect()
};
// Maybe pull out the ignored test and unignore them
@ -541,7 +541,7 @@ pub fn filter_tests(
None
}
};
vec::filter_map(filtered, |x| filter(x))
filtered.consume_iter().filter_map(|x| filter(x)).collect()
};
// Sort the tests alphabetically
@ -720,9 +720,9 @@ impl BenchHarness {
// Eliminate outliers
let med = samples.median();
let mad = samples.median_abs_dev();
let samples = do vec::filter(samples) |f| {
let samples = do samples.consume_iter().filter |f| {
num::abs(*f - med) <= 3.0 * mad
};
}.collect::<~[f64]>();
debug!("%u samples, median %f, MAD=%f, %u survived filter",
n_samples, med as float, mad as float,

View file

@ -1046,7 +1046,7 @@ pub unsafe fn ip4_name(src: &sockaddr_in) -> ~str {
// ipv4 addr max size: 15 + 1 trailing null byte
let dst: ~[u8] = ~[0u8,0u8,0u8,0u8,0u8,0u8,0u8,0u8,
0u8,0u8,0u8,0u8,0u8,0u8,0u8,0u8];
do vec::as_imm_buf(dst) |dst_buf, size| {
do dst.as_imm_buf |dst_buf, size| {
rust_uv_ip4_name(to_unsafe_ptr(src),
dst_buf, size as libc::size_t);
// seems that checking the result of uv_ip4_name
@ -1066,7 +1066,7 @@ pub unsafe fn ip6_name(src: &sockaddr_in6) -> ~str {
0u8,0u8,0u8,0u8,0u8,0u8,0u8,0u8,
0u8,0u8,0u8,0u8,0u8,0u8,0u8,0u8,
0u8,0u8,0u8,0u8,0u8,0u8];
do vec::as_imm_buf(dst) |dst_buf, size| {
do dst.as_imm_buf |dst_buf, size| {
let src_unsafe_ptr = to_unsafe_ptr(src);
let result = rust_uv_ip6_name(src_unsafe_ptr,
dst_buf, size as libc::size_t);

View file

@ -893,7 +893,7 @@ pub fn link_args(sess: Session,
// Add all the link args for external crates.
do cstore::iter_crate_data(cstore) |crate_num, _| {
let link_args = csearch::get_link_args_for_crate(cstore, crate_num);
do vec::consume(link_args) |_, link_arg| {
for link_args.consume_iter().advance |link_arg| {
args.push(link_arg);
}
}

View file

@ -123,10 +123,10 @@ pub fn build_configuration(sess: Session, argv0: @str, input: &input) ->
// Convert strings provided as --cfg [cfgspec] into a crate_cfg
fn parse_cfgspecs(cfgspecs: ~[~str],
demitter: diagnostic::Emitter) -> ast::crate_cfg {
do vec::map_consume(cfgspecs) |s| {
do cfgspecs.consume_iter().transform |s| {
let sess = parse::new_parse_sess(Some(demitter));
parse::parse_meta_from_source_str(@"cfgspec", s.to_managed(), ~[], sess)
}
}.collect()
}
pub enum input {

View file

@ -10,7 +10,6 @@
use std::option;
use std::vec;
use syntax::{ast, fold, attr};
type in_cfg_pred = @fn(attrs: ~[ast::attribute]) -> bool;
@ -61,13 +60,15 @@ fn filter_view_item(cx: @Context, view_item: @ast::view_item
}
fn fold_mod(cx: @Context, m: &ast::_mod, fld: @fold::ast_fold) -> ast::_mod {
let filtered_items =
m.items.filter_mapped(|a| filter_item(cx, *a));
let filtered_view_items =
m.view_items.filter_mapped(|a| filter_view_item(cx, *a));
let filtered_items = do m.items.iter().filter_map |a| {
filter_item(cx, *a).chain(|x| fld.fold_item(x))
}.collect();
let filtered_view_items = do m.view_items.iter().filter_map |a| {
filter_view_item(cx, *a).map(|x| fld.fold_view_item(*x))
}.collect();
ast::_mod {
view_items: filtered_view_items.map(|x| fld.fold_view_item(*x)),
items: vec::filter_map(filtered_items, |x| fld.fold_item(x))
view_items: filtered_view_items,
items: filtered_items
}
}
@ -83,14 +84,14 @@ fn fold_foreign_mod(
nm: &ast::foreign_mod,
fld: @fold::ast_fold
) -> ast::foreign_mod {
let filtered_items =
nm.items.filter_mapped(|a| filter_foreign_item(cx, *a));
let filtered_view_items =
nm.view_items.filter_mapped(|a| filter_view_item(cx, *a));
let filtered_items = nm.items.iter().filter_map(|a| filter_foreign_item(cx, *a)).collect();
let filtered_view_items = do nm.view_items.iter().filter_map |a| {
filter_view_item(cx, *a).map(|x| fld.fold_view_item(*x))
}.collect();
ast::foreign_mod {
sort: nm.sort,
abis: nm.abis,
view_items: filtered_view_items.iter().transform(|x| fld.fold_view_item(*x)).collect(),
view_items: filtered_view_items,
items: filtered_items
}
}
@ -99,11 +100,13 @@ fn fold_item_underscore(cx: @Context, item: &ast::item_,
fld: @fold::ast_fold) -> ast::item_ {
let item = match *item {
ast::item_impl(ref a, b, c, ref methods) => {
let methods = methods.filtered(|m| method_in_cfg(cx, *m) );
let methods = methods.iter().filter(|m| method_in_cfg(cx, **m))
.transform(|x| *x).collect();
ast::item_impl(/*bad*/ copy *a, b, c, methods)
}
ast::item_trait(ref a, ref b, ref methods) => {
let methods = methods.filtered(|m| trait_method_in_cfg(cx, m) );
let methods = methods.iter().filter(|m| trait_method_in_cfg(cx, *m) )
.transform(|x| /* bad */copy *x).collect();
ast::item_trait(/*bad*/copy *a, /*bad*/copy *b, methods)
}
ref item => /*bad*/ copy *item
@ -134,19 +137,12 @@ fn fold_block(
b: &ast::blk_,
fld: @fold::ast_fold
) -> ast::blk_ {
let filtered_stmts =
b.stmts.filter_mapped(|a| filter_stmt(cx, *a));
let filtered_view_items =
b.view_items.filter_mapped(|a| filter_view_item(cx, *a));
let filtered_view_items =
filtered_view_items.map(|x| fld.fold_view_item(*x));
let mut resulting_stmts = ~[];
for filtered_stmts.iter().advance |stmt| {
match fld.fold_stmt(*stmt) {
None => {}
Some(stmt) => resulting_stmts.push(stmt),
}
}
let resulting_stmts = do b.stmts.iter().filter_map |a| {
filter_stmt(cx, *a).chain(|stmt| fld.fold_stmt(stmt))
}.collect();
let filtered_view_items = do b.view_items.iter().filter_map |a| {
filter_view_item(cx, *a).map(|x| fld.fold_view_item(*x))
}.collect();
ast::blk_ {
view_items: filtered_view_items,
stmts: resulting_stmts,
@ -193,7 +189,9 @@ pub fn metas_in_cfg(cfg: &[@ast::meta_item],
// Pull the inner meta_items from the #[cfg(meta_item, ...)] attributes,
// so we can match against them. This is the list of configurations for
// which the item is valid
let cfg_metas = vec::filter_map(cfg_metas, |i| attr::get_meta_item_list(i));
let cfg_metas = cfg_metas.consume_iter()
.filter_map(|i| attr::get_meta_item_list(i))
.collect::<~[~[@ast::meta_item]]>();
if cfg_metas.iter().all(|c| c.is_empty()) { return true; }

View file

@ -109,9 +109,11 @@ fn fold_mod(cx: @mut TestCtxt,
fn nomain(cx: @mut TestCtxt, item: @ast::item) -> @ast::item {
if !*cx.sess.building_library {
@ast::item{attrs: item.attrs.filtered(|attr| {
"main" != attr::get_attr_name(attr)
}),.. copy *item}
@ast::item{
attrs: do item.attrs.iter().filter_map |attr| {
if "main" != attr::get_attr_name(attr) {Some(*attr)} else {None}
}.collect(),
.. copy *item}
} else { item }
}
@ -229,10 +231,10 @@ fn is_ignored(cx: @mut TestCtxt, i: @ast::item) -> bool {
let ignoreattrs = attr::find_attrs_by_name(i.attrs, "ignore");
let ignoreitems = attr::attr_metas(ignoreattrs);
return if !ignoreitems.is_empty() {
let cfg_metas =
vec::concat(
vec::filter_map(ignoreitems,
|i| attr::get_meta_item_list(i)));
let cfg_metas = ignoreitems.consume_iter()
.filter_map(|i| attr::get_meta_item_list(i))
.collect::<~[~[@ast::meta_item]]>()
.concat_vec();
config::metas_in_cfg(/*bad*/copy cx.crate.node.config, cfg_metas)
} else {
false

View file

@ -291,16 +291,16 @@ fn encode_ast(ebml_w: &mut writer::Encoder, item: ast::inlined_item) {
// inlined items.
fn simplify_ast(ii: &ast::inlined_item) -> ast::inlined_item {
fn drop_nested_items(blk: &ast::blk_, fld: @fold::ast_fold) -> ast::blk_ {
let stmts_sans_items = do blk.stmts.filtered |stmt| {
let stmts_sans_items = do blk.stmts.iter().filter_map |stmt| {
match stmt.node {
ast::stmt_expr(_, _) | ast::stmt_semi(_, _) |
ast::stmt_decl(@codemap::spanned { node: ast::decl_local(_),
span: _}, _) => true,
ast::stmt_decl(@codemap::spanned { node: ast::decl_item(_),
span: _}, _) => false,
ast::stmt_decl(@codemap::spanned { node: ast::decl_local(_), span: _}, _)
=> Some(*stmt),
ast::stmt_decl(@codemap::spanned { node: ast::decl_item(_), span: _}, _)
=> None,
ast::stmt_mac(*) => fail!("unexpanded macro in astencode")
}
};
}.collect();
let blk_sans_items = ast::blk_ {
view_items: ~[], // I don't know if we need the view_items here,
// but it doesn't break tests!

View file

@ -95,7 +95,7 @@ pub fn check_expr(cx: @MatchCheckCtxt, ex: @expr, (s, v): ((), visit::vt<()>)) {
}
_ => { /* We assume only enum types can be uninhabited */ }
}
let arms = vec::concat(arms.filter_mapped(unguarded_pat));
let arms = arms.iter().filter_map(unguarded_pat).collect::<~[~[@pat]]>().concat_vec();
if arms.is_empty() {
cx.tcx.sess.span_err(ex.span, "non-exhaustive patterns");
} else {
@ -265,7 +265,7 @@ pub fn is_useful(cx: &MatchCheckCtxt, m: &matrix, v: &[@pat]) -> useful {
}
Some(ref ctor) => {
match is_useful(cx,
&m.filter_mapped(|r| default(cx, *r)),
&m.iter().filter_map(|r| default(cx, *r)).collect::<matrix>(),
v.tail()) {
useful_ => useful(left_ty, /*bad*/copy *ctor),
ref u => (/*bad*/copy *u)
@ -287,7 +287,7 @@ pub fn is_useful_specialized(cx: &MatchCheckCtxt,
arity: uint,
lty: ty::t)
-> useful {
let ms = m.filter_mapped(|r| specialize(cx, *r, &ctor, arity, lty));
let ms = m.iter().filter_map(|r| specialize(cx, *r, &ctor, arity, lty)).collect::<matrix>();
let could_be_useful = is_useful(
cx, &ms, specialize(cx, v, &ctor, arity, lty).get());
match could_be_useful {
@ -397,14 +397,14 @@ pub fn missing_ctor(cx: &MatchCheckCtxt,
ty::ty_unboxed_vec(*) | ty::ty_evec(*) => {
// Find the lengths and slices of all vector patterns.
let vec_pat_lens = do m.filter_mapped |r| {
let vec_pat_lens = do m.iter().filter_map |r| {
match r[0].node {
pat_vec(ref before, ref slice, ref after) => {
Some((before.len() + after.len(), slice.is_some()))
}
_ => None
}
};
}.collect::<~[(uint, bool)]>();
// Sort them by length such that for patterns of the same length,
// those with a destructured slice come first.

View file

@ -24,7 +24,6 @@ use std::u16;
use std::u32;
use std::u64;
use std::u8;
use std::vec;
use extra::smallintmap::SmallIntMap;
use syntax::attr;
use syntax::codemap::span;
@ -987,7 +986,7 @@ fn lint_session() -> visit::vt<@mut Context> {
match cx.tcx.sess.lints.pop(&id) {
None => {},
Some(l) => {
do vec::consume(l) |_, (lint, span, msg)| {
for l.consume_iter().advance |(lint, span, msg)| {
cx.span_lint(lint, span, msg)
}
}

View file

@ -41,7 +41,6 @@ use syntax::opt_vec::OptVec;
use std::str;
use std::uint;
use std::vec;
use std::hashmap::{HashMap, HashSet};
use std::util;
@ -5362,7 +5361,7 @@ impl Resolver {
if idents.len() == 0 {
return ~"???";
}
return self.idents_to_str(vec::reversed(idents));
return self.idents_to_str(idents.consume_rev_iter().collect::<~[ast::ident]>());
}
pub fn dump_module(@mut self, module_: @mut Module) {

View file

@ -131,13 +131,13 @@ fn represent_type_uncached(cx: &mut CrateContext, t: ty::t) -> Repr {
}
ty::ty_struct(def_id, ref substs) => {
let fields = ty::lookup_struct_fields(cx.tcx, def_id);
let ftys = do fields.map |field| {
let mut ftys = do fields.map |field| {
ty::lookup_field_type(cx.tcx, def_id, field.id, substs)
};
let packed = ty::lookup_packed(cx.tcx, def_id);
let dtor = ty::ty_dtor(cx.tcx, def_id).has_drop_flag();
let ftys =
if dtor { ftys + [ty::mk_bool()] } else { ftys };
if dtor { ftys.push(ty::mk_bool()); }
return Univariant(mk_struct(cx, ftys, packed), dtor)
}
ty::ty_enum(def_id, ref substs) => {
@ -263,7 +263,7 @@ fn generic_fields_of(cx: &mut CrateContext, r: &Repr, sizing: bool) -> ~[Type] {
let padding = largest_size - most_aligned.size;
struct_llfields(cx, most_aligned, sizing)
+ [Type::array(&Type::i8(), padding)]
+ &[Type::array(&Type::i8(), padding)]
}
}
}
@ -512,7 +512,7 @@ pub fn trans_const(ccx: &mut CrateContext, r: &Repr, discr: int,
let discr_ty = C_int(ccx, discr);
let contents = build_const_struct(ccx, case,
~[discr_ty] + vals);
C_struct(contents + [padding(max_sz - case.size)])
C_struct(contents + &[padding(max_sz - case.size)])
}
NullablePointer{ nonnull: ref nonnull, nndiscr, ptrfield, _ } => {
if discr == nndiscr {

View file

@ -565,7 +565,7 @@ pub fn LoadRangeAssert(cx: block, PointerVal: ValueRef, lo: c_ulonglong,
let min = llvm::LLVMConstInt(t, lo, signed);
let max = llvm::LLVMConstInt(t, hi, signed);
do vec::as_imm_buf([min, max]) |ptr, len| {
do [min, max].as_imm_buf |ptr, len| {
llvm::LLVMSetMetadata(value, lib::llvm::MD_range as c_uint,
llvm::LLVMMDNodeInContext(cx.fcx.ccx.llcx,
ptr, len as c_uint));
@ -942,7 +942,7 @@ pub fn Call(cx: block, Fn: ValueRef, Args: &[ValueRef]) -> ValueRef {
cx.val_to_str(Fn),
Args.map(|arg| cx.val_to_str(*arg)));
do vec::as_imm_buf(Args) |ptr, len| {
do Args.as_imm_buf |ptr, len| {
llvm::LLVMBuildCall(B(cx), Fn, ptr, len as c_uint, noname())
}
}

View file

@ -774,7 +774,7 @@ pub fn C_zero_byte_arr(size: uint) -> ValueRef {
pub fn C_struct(elts: &[ValueRef]) -> ValueRef {
unsafe {
do vec::as_imm_buf(elts) |ptr, len| {
do elts.as_imm_buf |ptr, len| {
llvm::LLVMConstStructInContext(base::task_llcx(), ptr, len as c_uint, False)
}
}
@ -782,7 +782,7 @@ pub fn C_struct(elts: &[ValueRef]) -> ValueRef {
pub fn C_packed_struct(elts: &[ValueRef]) -> ValueRef {
unsafe {
do vec::as_imm_buf(elts) |ptr, len| {
do elts.as_imm_buf |ptr, len| {
llvm::LLVMConstStructInContext(base::task_llcx(), ptr, len as c_uint, True)
}
}
@ -790,7 +790,7 @@ pub fn C_packed_struct(elts: &[ValueRef]) -> ValueRef {
pub fn C_named_struct(T: Type, elts: &[ValueRef]) -> ValueRef {
unsafe {
do vec::as_imm_buf(elts) |ptr, len| {
do elts.as_imm_buf |ptr, len| {
llvm::LLVMConstNamedStruct(T.to_ref(), ptr, len as c_uint)
}
}
@ -826,7 +826,7 @@ pub fn get_param(fndecl: ValueRef, param: uint) -> ValueRef {
pub fn const_get_elt(cx: &CrateContext, v: ValueRef, us: &[c_uint])
-> ValueRef {
unsafe {
let r = do vec::as_imm_buf(us) |p, len| {
let r = do us.as_imm_buf |p, len| {
llvm::LLVMConstExtractValue(v, p, len as c_uint)
};

View file

@ -26,7 +26,6 @@ use util::ppaux;
use middle::trans::type_::Type;
use std::str;
use std::vec;
use syntax::ast;
use syntax::ast::ident;
use syntax::ast_map::path_mod;
@ -190,9 +189,13 @@ pub fn trans_log(log_ex: &ast::expr,
let (modpath, modname) = {
let path = &mut bcx.fcx.path;
let modpath = vec::append(
~[path_mod(ccx.sess.ident_of(ccx.link_meta.name))],
path.filtered(|e| match *e { path_mod(_) => true, _ => false }));
let mut modpath = ~[path_mod(ccx.sess.ident_of(ccx.link_meta.name))];
for path.iter().advance |e| {
match *e {
path_mod(_) => { modpath.push(*e) }
_ => {}
}
}
let modname = path_str(ccx.sess, modpath);
(modpath, modname)
};

View file

@ -113,7 +113,7 @@ fn shim_types(ccx: @mut CrateContext, id: ast::node_id) -> ShimTypes {
_ => ccx.sess.bug("c_arg_and_ret_lltys called on non-function type")
};
let llsig = foreign_signature(ccx, &fn_sig);
let bundle_ty = Type::struct_(llsig.llarg_tys + [llsig.llret_ty.ptr_to()], false);
let bundle_ty = Type::struct_(llsig.llarg_tys + &[llsig.llret_ty.ptr_to()], false);
let ret_def = !ty::type_is_bot(fn_sig.output) &&
!ty::type_is_nil(fn_sig.output);
let fn_ty = abi_info(ccx).compute_info(llsig.llarg_tys, llsig.llret_ty, ret_def);

View file

@ -278,7 +278,7 @@ impl Reflector {
let opaqueptrty = ty::mk_ptr(ccx.tcx, ty::mt { ty: opaquety, mutbl: ast::m_imm });
let make_get_disr = || {
let sub_path = bcx.fcx.path + [path_name(special_idents::anon)];
let sub_path = bcx.fcx.path + &[path_name(special_idents::anon)];
let sym = mangle_internal_name_by_path_and_seq(ccx,
sub_path,
"get_disr");

View file

@ -245,7 +245,7 @@ impl Type {
}
pub fn box(ctx: &CrateContext, ty: &Type) -> Type {
Type::struct_(Type::box_header_fields(ctx) + [*ty], false)
Type::struct_(Type::box_header_fields(ctx) + &[*ty], false)
}
pub fn opaque_box(ctx: &CrateContext) -> Type {

View file

@ -45,9 +45,9 @@ pub fn parse_crate(attrs: ~[ast::attribute]) -> CrateAttrs {
}
pub fn parse_desc(attrs: ~[ast::attribute]) -> Option<~str> {
let doc_strs = do doc_metas(attrs).filter_mapped |meta| {
attr::get_meta_item_value_str(*meta).map(|s| s.to_owned())
};
let doc_strs = do doc_metas(attrs).consume_iter().filter_map |meta| {
attr::get_meta_item_value_str(meta).map(|s| s.to_owned())
}.collect::<~[~str]>();
if doc_strs.is_empty() {
None
} else {

View file

@ -141,7 +141,7 @@ fn first_sentence_(s: &str) -> ~str {
pub fn paragraphs(s: &str) -> ~[~str] {
let mut whitespace_lines = 0;
let mut accum = ~"";
let paras = do s.any_line_iter().fold(~[]) |paras, line| {
let mut paras = do s.any_line_iter().fold(~[]) |paras, line| {
let mut res = paras;
if line.is_whitespace() {
@ -166,11 +166,8 @@ pub fn paragraphs(s: &str) -> ~[~str] {
res
};
if !accum.is_empty() {
paras + [accum]
} else {
paras
}
if !accum.is_empty() { paras.push(accum); }
paras
}
#[cfg(test)]

View file

@ -13,8 +13,6 @@
use doc;
use std::vec;
pub type AstId = int;
#[deriving(Eq)]
@ -186,87 +184,64 @@ impl Doc {
}
}
macro_rules! filt_mapper {
($vec:expr, $pat:pat) => {
do ($vec).iter().filter_map |thing| {
match thing {
&$pat => Some(copy *x),
_ => None
}
}.collect()
}
}
macro_rules! md {
($id:ident) => {
filt_mapper!(self.items, $id(ref x))
}
}
/// Some helper methods on ModDoc, mostly for testing
impl ModDoc {
pub fn mods(&self) -> ~[ModDoc] {
do vec::filter_mapped(self.items) |itemtag| {
match copy *itemtag {
ModTag(ModDoc) => Some(ModDoc),
_ => None
}
}
md!(ModTag)
}
pub fn nmods(&self) -> ~[NmodDoc] {
do vec::filter_mapped(self.items) |itemtag| {
match copy *itemtag {
NmodTag(nModDoc) => Some(nModDoc),
_ => None
}
}
md!(NmodTag)
}
pub fn fns(&self) -> ~[FnDoc] {
do vec::filter_mapped(self.items) |itemtag| {
match copy *itemtag {
FnTag(FnDoc) => Some(FnDoc),
_ => None
}
}
md!(FnTag)
}
pub fn consts(&self) -> ~[ConstDoc] {
do vec::filter_mapped(self.items) |itemtag| {
match copy *itemtag {
ConstTag(ConstDoc) => Some(ConstDoc),
_ => None
}
}
md!(ConstTag)
}
pub fn enums(&self) -> ~[EnumDoc] {
do vec::filter_mapped(self.items) |itemtag| {
match copy *itemtag {
EnumTag(EnumDoc) => Some(EnumDoc),
_ => None
}
}
md!(EnumTag)
}
pub fn traits(&self) -> ~[TraitDoc] {
do vec::filter_mapped(self.items) |itemtag| {
match copy *itemtag {
TraitTag(TraitDoc) => Some(TraitDoc),
_ => None
}
}
md!(TraitTag)
}
pub fn impls(&self) -> ~[ImplDoc] {
do vec::filter_mapped(self.items) |itemtag| {
match copy *itemtag {
ImplTag(ImplDoc) => Some(ImplDoc),
_ => None
}
}
md!(ImplTag)
}
pub fn types(&self) -> ~[TyDoc] {
do vec::filter_mapped(self.items) |itemtag| {
match copy *itemtag {
TyTag(TyDoc) => Some(TyDoc),
_ => None
}
}
md!(TyTag)
}
pub fn structs(&self) -> ~[StructDoc] {
do vec::filter_mapped(self.items) |itemtag| {
match copy *itemtag {
StructTag(StructDoc) => Some(StructDoc),
_ => None
}
}
md!(StructTag)
}
}
macro_rules! pu {
($id:ident) => {
filt_mapper!(*self, ItemPage($id(ref x)))
}
}
@ -284,75 +259,35 @@ pub trait PageUtils {
impl PageUtils for ~[Page] {
fn mods(&self) -> ~[ModDoc] {
do vec::filter_mapped(*self) |page| {
match copy *page {
ItemPage(ModTag(ModDoc)) => Some(ModDoc),
_ => None
}
}
pu!(ModTag)
}
fn nmods(&self) -> ~[NmodDoc] {
do vec::filter_mapped(*self) |page| {
match copy *page {
ItemPage(NmodTag(nModDoc)) => Some(nModDoc),
_ => None
}
}
pu!(NmodTag)
}
fn fns(&self) -> ~[FnDoc] {
do vec::filter_mapped(*self) |page| {
match copy *page {
ItemPage(FnTag(FnDoc)) => Some(FnDoc),
_ => None
}
}
pu!(FnTag)
}
fn consts(&self) -> ~[ConstDoc] {
do vec::filter_mapped(*self) |page| {
match copy *page {
ItemPage(ConstTag(ConstDoc)) => Some(ConstDoc),
_ => None
}
}
pu!(ConstTag)
}
fn enums(&self) -> ~[EnumDoc] {
do vec::filter_mapped(*self) |page| {
match copy *page {
ItemPage(EnumTag(EnumDoc)) => Some(EnumDoc),
_ => None
}
}
pu!(EnumTag)
}
fn traits(&self) -> ~[TraitDoc] {
do vec::filter_mapped(*self) |page| {
match copy *page {
ItemPage(TraitTag(TraitDoc)) => Some(TraitDoc),
_ => None
}
}
pu!(TraitTag)
}
fn impls(&self) -> ~[ImplDoc] {
do vec::filter_mapped(*self) |page| {
match copy *page {
ItemPage(ImplTag(ImplDoc)) => Some(ImplDoc),
_ => None
}
}
pu!(ImplTag)
}
fn types(&self) -> ~[TyDoc] {
do vec::filter_mapped(*self) |page| {
match copy *page {
ItemPage(TyTag(TyDoc)) => Some(TyDoc),
_ => None
}
}
pu!(TyTag)
}
}

View file

@ -15,7 +15,6 @@ use astsrv;
use doc::ItemUtils;
use doc;
use std::vec;
use syntax::ast;
use syntax::parse::token::{ident_interner, ident_to_str};
use syntax::parse::token;
@ -83,7 +82,7 @@ fn moddoc_from_mod(
) -> doc::ModDoc {
doc::ModDoc {
item: itemdoc,
items: do vec::filter_mapped(module_.items) |item| {
items: do module_.items.iter().filter_map |item| {
let ItemDoc = mk_itemdoc(item.id, to_str(item.ident));
match copy item.node {
ast::item_mod(m) => {
@ -133,7 +132,7 @@ fn moddoc_from_mod(
}
_ => None
}
},
}.collect(),
index: None
}
}

View file

@ -172,7 +172,7 @@ pub fn header_kind(doc: doc::ItemTag) -> ~str {
}
pub fn header_name(doc: doc::ItemTag) -> ~str {
let fullpath = (doc.path() + [doc.name()]).connect("::");
let fullpath = (doc.path() + &[doc.name()]).connect("::");
match &doc {
&doc::ModTag(_) if doc.id() != syntax::ast::crate_node_id => {
fullpath

View file

@ -163,7 +163,7 @@ pub fn make_filename(
}
}
doc::ItemPage(doc) => {
(doc.path() + [doc.name()]).connect("_")
(doc.path() + &[doc.name()]).connect("_")
}
}
};

View file

@ -128,13 +128,12 @@ fn fold_mod(
fn strip_mod(doc: doc::ModDoc) -> doc::ModDoc {
doc::ModDoc {
items: do doc.items.filtered |item| {
match *item {
doc::ModTag(_) => false,
doc::NmodTag(_) => false,
items: do doc.items.iter().filter |item| {
match **item {
doc::ModTag(_) | doc::NmodTag(_) => false,
_ => true
}
},
}.transform(|x| copy *x).collect::<~[doc::ItemTag]>(),
.. copy doc
}
}

View file

@ -41,9 +41,9 @@ fn fold_mod(
let doc = fold::default_any_fold_mod(fold, doc);
doc::ModDoc {
items: do doc.items.filtered |ItemTag| {
!is_hidden(fold.ctxt.clone(), ItemTag.item())
},
items: do doc.items.iter().filter |item_tag| {
!is_hidden(fold.ctxt.clone(), item_tag.item())
}.transform(|x| copy *x).collect(),
.. doc
}
}

View file

@ -80,7 +80,7 @@ fn strip_priv_methods(
methods: &[@ast::method],
item_vis: ast::visibility
) -> doc::ImplDoc {
let methods = do (&doc.methods).filtered |method| {
let methods = do doc.methods.iter().filter |method| {
let ast_method = do methods.iter().find_ |m| {
extract::to_str(m.ident) == method.name
};
@ -91,7 +91,7 @@ fn strip_priv_methods(
ast::private => false,
ast::inherited => item_vis == ast::public
}
};
}.transform(|x| copy *x).collect();
doc::ImplDoc {
methods: methods,
@ -106,9 +106,9 @@ fn fold_mod(
let doc = fold::default_any_fold_mod(fold, doc);
doc::ModDoc {
items: doc.items.filtered(|ItemTag| {
match ItemTag {
&doc::ImplTag(ref doc) => {
items: doc.items.iter().filter(|item_tag| {
match item_tag {
& &doc::ImplTag(ref doc) => {
if doc.trait_types.is_empty() {
// This is an associated impl. We have already pruned the
// non-visible methods. If there are any left then
@ -123,10 +123,10 @@ fn fold_mod(
}
}
_ => {
is_visible(fold.ctxt.clone(), ItemTag.item())
is_visible(fold.ctxt.clone(), item_tag.item())
}
}
}),
}).transform(|x| copy *x).collect(),
.. doc
}
}

View file

@ -77,9 +77,9 @@ fn fold_mod(_ctx: @mut ReadyCtx,
fold: @fold::ast_fold) -> ast::_mod {
fn strip_main(item: @ast::item) -> @ast::item {
@ast::item {
attrs: do item.attrs.filtered |attr| {
"main" != attr::get_attr_name(attr)
},
attrs: do item.attrs.iter().filter_map |attr| {
if "main" != attr::get_attr_name(attr) {Some(*attr)} else {None}
}.collect(),
.. copy *item
}
}

View file

@ -34,6 +34,7 @@ pub fn each_pkg_parent_workspace(pkgid: &PkgId, action: &fn(&Path) -> bool) -> b
}
pub fn pkg_parent_workspaces(pkgid: &PkgId) -> ~[Path] {
rust_path().filtered(|ws|
workspace_contains_package_id(pkgid, ws))
rust_path().consume_iter()
.filter(|ws| workspace_contains_package_id(pkgid, ws))
.collect()
}

View file

@ -17,8 +17,7 @@ use kinds::Copy;
use option::Option;
use sys;
use uint;
use vec;
use vec::ImmutableVector;
use vec::{ImmutableVector, OwnedVector};
/// Code for dealing with @-vectors. This is pretty incomplete, and
/// contains a bunch of duplication from the code for ~-vectors.
@ -159,7 +158,7 @@ pub fn to_managed_consume<T>(v: ~[T]) -> @[T] {
let mut av = @[];
unsafe {
raw::reserve(&mut av, v.len());
do vec::consume(v) |_i, x| {
for v.consume_iter().advance |x| {
raw::push(&mut av, x);
}
transmute(av)
@ -177,13 +176,14 @@ pub fn to_managed<T:Copy>(v: &[T]) -> @[T] {
#[cfg(not(test))]
pub mod traits {
use at_vec::append;
use vec::Vector;
use kinds::Copy;
use ops::Add;
impl<'self,T:Copy> Add<&'self [T],@[T]> for @[T] {
impl<'self,T:Copy, V: Vector<T>> Add<V,@[T]> for @[T] {
#[inline]
fn add(&self, rhs: & &'self [T]) -> @[T] {
append(*self, (*rhs))
fn add(&self, rhs: &V) -> @[T] {
append(*self, rhs.as_slice())
}
}
}
@ -313,7 +313,7 @@ mod test {
#[test]
fn append_test() {
assert_eq!(@[1,2,3] + [4,5,6], @[1,2,3,4,5,6]);
assert_eq!(@[1,2,3] + &[4,5,6], @[1,2,3,4,5,6]);
}
#[test]

View file

@ -73,7 +73,7 @@ pub fn rights<T, U: Copy>(eithers: &[Either<T, U>]) -> ~[U] {
pub fn partition<T, U>(eithers: ~[Either<T, U>]) -> (~[T], ~[U]) {
let mut lefts: ~[T] = ~[];
let mut rights: ~[U] = ~[];
do vec::consume(eithers) |_i, elt| {
for eithers.consume_iter().advance |elt| {
match elt {
Left(l) => lefts.push(l),
Right(r) => rights.push(r)

View file

@ -24,7 +24,7 @@ use rand::RngUtil;
use rand;
use uint;
use vec;
use vec::{ImmutableVector, MutableVector};
use vec::{ImmutableVector, MutableVector, OwnedVector};
use kinds::Copy;
use util::{replace, unreachable};
@ -175,7 +175,8 @@ impl<K:Hash + Eq,V> HashMap<K, V> {
vec::from_fn(new_capacity, |_| None));
self.size = 0;
do vec::consume(old_buckets) |_, bucket| {
// consume_rev_iter is more efficient
for old_buckets.consume_rev_iter().advance |bucket| {
self.insert_opt_bucket(bucket);
}
}
@ -441,7 +442,7 @@ impl<K: Hash + Eq, V> HashMap<K, V> {
vec::from_fn(INITIAL_CAPACITY, |_| None));
self.size = 0;
do vec::consume(buckets) |_, bucket| {
for buckets.consume_iter().advance |bucket| {
match bucket {
None => {},
Some(Bucket{key, value, _}) => {

View file

@ -917,7 +917,7 @@ fn convert_whence(whence: SeekStyle) -> i32 {
impl Reader for *libc::FILE {
fn read(&self, bytes: &mut [u8], len: uint) -> uint {
unsafe {
do vec::as_mut_buf(bytes) |buf_p, buf_len| {
do bytes.as_mut_buf |buf_p, buf_len| {
assert!(buf_len >= len);
let count = libc::fread(buf_p as *mut c_void, 1u as size_t,
@ -1152,7 +1152,7 @@ impl<W:Writer,C> Writer for Wrapper<W, C> {
impl Writer for *libc::FILE {
fn write(&self, v: &[u8]) {
unsafe {
do vec::as_imm_buf(v) |vbuf, len| {
do v.as_imm_buf |vbuf, len| {
let nout = libc::fwrite(vbuf as *c_void,
1,
len as size_t,
@ -1203,7 +1203,7 @@ impl Writer for fd_t {
fn write(&self, v: &[u8]) {
unsafe {
let mut count = 0u;
do vec::as_imm_buf(v) |vbuf, len| {
do v.as_imm_buf |vbuf, len| {
while count < len {
let vb = ptr::offset(vbuf, count) as *c_void;
let nout = libc::write(*self, vb, len as size_t);

View file

@ -92,7 +92,7 @@ pub fn as_c_charp<T>(s: &str, f: &fn(*c_char) -> T) -> T {
pub fn fill_charp_buf(f: &fn(*mut c_char, size_t) -> bool)
-> Option<~str> {
let mut buf = vec::from_elem(TMPBUF_SZ, 0u8 as c_char);
do vec::as_mut_buf(buf) |b, sz| {
do buf.as_mut_buf |b, sz| {
if f(b, sz as size_t) {
unsafe {
Some(str::raw::from_buf(b as *u8))
@ -122,7 +122,7 @@ pub mod win32 {
while !done {
let mut k: DWORD = 0;
let mut buf = vec::from_elem(n as uint, 0u16);
do vec::as_mut_buf(buf) |b, _sz| {
do buf.as_mut_buf |b, _sz| {
k = f(b, TMPBUF_SZ as DWORD);
if k == (0 as DWORD) {
done = true;
@ -147,7 +147,7 @@ pub mod win32 {
let mut t = s.to_utf16();
// Null terminate before passing on.
t.push(0u16);
vec::as_imm_buf(t, |buf, _len| f(buf))
t.as_imm_buf(|buf, _len| f(buf))
}
}
@ -777,9 +777,9 @@ pub fn list_dir(p: &Path) -> ~[~str] {
strings
}
}
do get_list(p).filtered |filename| {
*filename != ~"." && *filename != ~".."
}
do get_list(p).consume_iter().filter |filename| {
"." != *filename && ".." != *filename
}.collect()
}
}
@ -937,7 +937,7 @@ pub fn copy_file(from: &Path, to: &Path) -> bool {
let mut done = false;
let mut ok = true;
while !done {
do vec::as_mut_buf(buf) |b, _sz| {
do buf.as_mut_buf |b, _sz| {
let nread = libc::fread(b as *mut c_void, 1u as size_t,
bufsize as size_t,
istream);
@ -1683,7 +1683,7 @@ mod tests {
let s = ~"hello";
let mut buf = s.as_bytes_with_null().to_owned();
let len = buf.len();
do vec::as_mut_buf(buf) |b, _len| {
do buf.as_mut_buf |b, _len| {
assert_eq!(libc::fwrite(b as *c_void, 1u as size_t,
(s.len() + 1u) as size_t, ostream),
len as size_t)

View file

@ -72,7 +72,7 @@ pub use tuple::{CloneableTuple10, CloneableTuple11, CloneableTuple12};
pub use tuple::{ImmutableTuple2, ImmutableTuple3, ImmutableTuple4, ImmutableTuple5};
pub use tuple::{ImmutableTuple6, ImmutableTuple7, ImmutableTuple8, ImmutableTuple9};
pub use tuple::{ImmutableTuple10, ImmutableTuple11, ImmutableTuple12};
pub use vec::{VectorVector, CopyableVector, ImmutableVector};
pub use vec::{Vector, VectorVector, CopyableVector, ImmutableVector};
pub use vec::{ImmutableEqVector, ImmutableTotalOrdVector, ImmutableCopyableVector};
pub use vec::{OwnedVector, OwnedCopyableVector,OwnedEqVector, MutableVector};
pub use io::{Reader, ReaderUtil, Writer, WriterUtil};

View file

@ -406,7 +406,7 @@ pub mod ptr_tests {
do str::as_c_str(s1) |p1| {
do str::as_c_str(s2) |p2| {
let v = ~[p0, p1, p2, null()];
do vec::as_imm_buf(v) |vp, len| {
do v.as_imm_buf |vp, len| {
assert_eq!(unsafe { buf_len(vp) }, 3u);
assert_eq!(len, 4u);
}

View file

@ -830,7 +830,7 @@ pub fn seed() -> ~[u8] {
unsafe {
let n = rustrt::rand_seed_size() as uint;
let mut s = vec::from_elem(n, 0_u8);
do vec::as_mut_buf(s) |p, sz| {
do s.as_mut_buf |p, sz| {
rustrt::rand_gen_seed(p, sz as size_t)
}
s
@ -1087,7 +1087,7 @@ mod tests {
for 10.times {
unsafe {
let seed = super::seed();
let rt_rng = do vec::as_imm_buf(seed) |p, sz| {
let rt_rng = do seed.as_imm_buf |p, sz| {
rustrt::rand_new_seeded(p, sz as size_t)
};
let mut rng = IsaacRng::new_seeded(seed);

View file

@ -40,6 +40,7 @@ use str::raw::from_c_str;
use to_str::ToStr;
use ptr::RawPtr;
use vec;
use vec::ImmutableVector;
use ptr;
use str;
use libc::{c_void, c_int, size_t, malloc, free};
@ -300,7 +301,7 @@ pub fn vec_to_uv_buf(v: ~[u8]) -> Buf {
unsafe {
let data = malloc(v.len() as size_t) as *u8;
assert!(data.is_not_null());
do vec::as_imm_buf(v) |b, l| {
do v.as_imm_buf |b, l| {
let data = data as *mut u8;
ptr::copy_memory(data, b, l)
}

View file

@ -24,7 +24,7 @@ use prelude::*;
use ptr;
use str;
use task;
use vec;
use vec::ImmutableVector;
/**
* A value representing a child process.
@ -703,7 +703,7 @@ fn with_argv<T>(prog: &str, args: &[~str],
argptrs.push(str::as_c_str(*t, |b| b));
}
argptrs.push(ptr::null());
vec::as_imm_buf(argptrs, |buf, _len| cb(buf))
argptrs.as_imm_buf(|buf, _len| cb(buf))
}
#[cfg(unix)]
@ -722,7 +722,7 @@ fn with_envp<T>(env: Option<&[(~str, ~str)]>, cb: &fn(*c_void) -> T) -> T {
}
ptrs.push(ptr::null());
vec::as_imm_buf(ptrs, |p, _len|
ptrs.as_imm_buf(|p, _len|
unsafe { cb(::cast::transmute(p)) }
)
}
@ -743,7 +743,7 @@ fn with_envp<T>(env: Option<&[(~str, ~str)]>, cb: &fn(*mut c_void) -> T) -> T {
blk.push_all(kv.as_bytes_with_null_consume());
}
blk.push(0);
vec::as_imm_buf(blk, |p, _len|
blk.as_imm_buf(|p, _len|
unsafe { cb(::cast::transmute(p)) }
)
}

View file

@ -826,6 +826,7 @@ pub mod raw {
use str::raw;
use str::{as_buf, is_utf8};
use vec;
use vec::MutableVector;
/// Create a Rust string from a null-terminated *u8 buffer
pub unsafe fn from_buf(buf: *u8) -> ~str {
@ -841,7 +842,7 @@ pub mod raw {
/// Create a Rust string from a *u8 buffer of the given length
pub unsafe fn from_buf_len(buf: *u8, len: uint) -> ~str {
let mut v: ~[u8] = vec::with_capacity(len + 1);
vec::as_mut_buf(v, |vbuf, _len| {
v.as_mut_buf(|vbuf, _len| {
ptr::copy_memory(vbuf, buf as *u8, len)
});
vec::raw::set_len(&mut v, len);
@ -863,7 +864,7 @@ pub mod raw {
/// Converts a vector of bytes to a new owned string.
pub unsafe fn from_bytes(v: &[u8]) -> ~str {
do vec::as_imm_buf(v) |buf, len| {
do v.as_imm_buf |buf, len| {
from_buf_len(buf, len)
}
}
@ -917,7 +918,7 @@ pub mod raw {
assert!((end <= n));
let mut v = vec::with_capacity(end - begin + 1u);
do vec::as_imm_buf(v) |vbuf, _vlen| {
do v.as_imm_buf |vbuf, _vlen| {
let vbuf = ::cast::transmute_mut_unsafe(vbuf);
let src = ptr::offset(sbuf, begin);
ptr::copy_memory(vbuf, src, end - begin);

File diff suppressed because it is too large Load diff

View file

@ -238,12 +238,12 @@ pub fn unguarded_pat(a: &arm) -> Option<~[@pat]> {
}
pub fn public_methods(ms: ~[@method]) -> ~[@method] {
do ms.filtered |m| {
do ms.consume_iter().filter |m| {
match m.vis {
public => true,
_ => false
}
}
}.collect()
}
// extract a ty_method from a trait_method. if the trait_method is

View file

@ -143,13 +143,13 @@ pub fn get_name_value_str_pair(item: @ast::meta_item)
/// Search a list of attributes and return only those with a specific name
pub fn find_attrs_by_name(attrs: &[ast::attribute], name: &str) ->
~[ast::attribute] {
do vec::filter_mapped(attrs) |a| {
do attrs.iter().filter_map |a| {
if name == get_attr_name(a) {
Some(*a)
} else {
None
}
}
}.collect()
}
/// Search a list of meta items and return only those with a specific name
@ -277,14 +277,7 @@ pub fn sort_meta_items(items: &[@ast::meta_item]) -> ~[@ast::meta_item] {
pub fn remove_meta_items_by_name(items: ~[@ast::meta_item], name: &str) ->
~[@ast::meta_item] {
return vec::filter_mapped(items, |item| {
if name != get_meta_item_name(*item) {
Some(*item)
} else {
None
}
});
items.consume_iter().filter(|item| name != get_meta_item_name(*item)).collect()
}
/**

View file

@ -22,7 +22,6 @@ use ext::build::AstBuilder;
use std::option;
use std::unstable::extfmt::ct::*;
use std::vec;
use parse::token::{str_to_ident};
pub fn expand_syntax_ext(cx: @ExtCtxt, sp: span, tts: &[ast::token_tree])
@ -268,7 +267,7 @@ fn pieces_to_expr(cx: @ExtCtxt, sp: span,
corresponding function in std::unstable::extfmt. Each function takes a
buffer to insert data into along with the data being formatted. */
let npieces = pieces.len();
do vec::consume(pieces) |i, pc| {
for pieces.consume_iter().enumerate().advance |(i, pc)| {
match pc {
/* Raw strings get appended via str::push_str */
PieceString(s) => {

View file

@ -14,8 +14,6 @@ use codemap::{span, spanned};
use parse::token;
use opt_vec::OptVec;
use std::vec;
pub trait ast_fold {
fn fold_crate(@self, &crate) -> crate;
fn fold_view_item(@self, @view_item) -> @view_item;
@ -700,7 +698,7 @@ pub fn noop_fold_ty(t: &ty_, fld: @ast_fold) -> ty_ {
pub fn noop_fold_mod(m: &_mod, fld: @ast_fold) -> _mod {
ast::_mod {
view_items: m.view_items.iter().transform(|x| fld.fold_view_item(*x)).collect(),
items: vec::filter_mapped(m.items, |x| fld.fold_item(*x)),
items: m.items.iter().filter_map(|x| fld.fold_item(*x)).collect(),
}
}

View file

@ -95,13 +95,13 @@ fn make_graph(N: uint, edges: ~[(node_id, node_id)]) -> graph {
}
}
do vec::map_consume(graph) |mut v| {
do graph.consume_iter().transform |mut v| {
let mut vec = ~[];
do v.consume |i| {
vec.push(i);
}
vec
}
}.collect()
}
fn gen_search_keys(graph: &[~[node_id]], n: uint) -> ~[node_id] {

View file

@ -96,7 +96,7 @@ fn recurse_or_fail(depth: int, st: Option<State>) {
fn_box: || @Cons((), fn_box()),
tuple: (@Cons((), st.tuple.first()),
~Cons((), @*st.tuple.second())),
vec: st.vec + [@Cons((), *st.vec.last())],
vec: st.vec + &[@Cons((), *st.vec.last())],
res: r(@Cons((), st.res._l))
}
}

View file

@ -28,20 +28,21 @@ fn calc(children: uint, parent_wait_chan: &Chan<Chan<Chan<int>>>) {
wait_port
};
let child_start_chans: ~[Chan<Chan<int>>] = vec::map_consume(wait_ports, |port| port.recv());
let child_start_chans: ~[Chan<Chan<int>>] =
wait_ports.consume_iter().transform(|port| port.recv()).collect();
let (start_port, start_chan) = stream::<Chan<int>>();
parent_wait_chan.send(start_chan);
let parent_result_chan: Chan<int> = start_port.recv();
let child_sum_ports: ~[Port<int>] = do vec::map_consume(child_start_chans) |child_start_chan| {
let (child_sum_port, child_sum_chan) = stream::<int>();
child_start_chan.send(child_sum_chan);
child_sum_port
};
let child_sum_ports: ~[Port<int>] =
do child_start_chans.consume_iter().transform |child_start_chan| {
let (child_sum_port, child_sum_chan) = stream::<int>();
child_start_chan.send(child_sum_chan);
child_sum_port
}.collect();
let mut sum = 0;
vec::consume(child_sum_ports, |_, sum_port| sum += sum_port.recv() );
let sum = child_sum_ports.consume_iter().fold(0, |sum, sum_port| sum + sum_port.recv() );
parent_result_chan.send(sum + 1);
}

View file

@ -30,7 +30,7 @@ use std::io::WriterUtil;
// Make sure this import is warned about when at least one of its imported names
// is unused
use std::vec::{filter, from_elem}; //~ ERROR unused import
use std::vec::{from_fn, from_elem}; //~ ERROR unused import
mod foo {
pub struct Point{x: int, y: int}

View file

@ -11,7 +11,6 @@
// error-pattern:index out of bounds
use std::sys;
use std::vec;
fn main() {
@ -22,7 +21,7 @@ fn main() {
// huge).
let x = ~[1u,2u,3u];
do vec::as_imm_buf(x) |p, _len| {
do x.as_imm_buf |p, _len| {
let base = p as uint;
let idx = base / sys::size_of::<uint>();
error!("ov1 base = 0x%x", base);

View file

@ -17,5 +17,5 @@ use std::vec::*;
pub fn main() {
let mut v = from_elem(0u, 0);
v = append(v, ~[4, 2]);
assert_eq!(reversed(v), ~[2, 4]);
assert_eq!(from_fn(2, |i| 2*(i+1)), ~[2, 4]);
}