Remove the global 'vec::to_owned' function
This commit is contained in:
parent
2b96408600
commit
1ec06e0124
@ -446,7 +446,7 @@ pub mod flatteners {
|
||||
T: Decodable<D>>(
|
||||
buf: &[u8])
|
||||
-> T {
|
||||
let buf = vec::to_owned(buf);
|
||||
let buf = buf.to_owned();
|
||||
let buf_reader = @BufReader::new(buf);
|
||||
let reader = buf_reader as @Reader;
|
||||
let mut deser: D = FromReader::from_reader(reader);
|
||||
|
@ -343,7 +343,7 @@ pub fn getopts(args: &[~str], opts: &[Opt]) -> Result {
|
||||
}
|
||||
i += 1;
|
||||
}
|
||||
return Ok(Matches {opts: vec::to_owned(opts),
|
||||
return Ok(Matches {opts: opts.to_owned(),
|
||||
vals: vals,
|
||||
free: free});
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ pub fn md4(msg: &[u8]) -> Quad {
|
||||
let orig_len: u64 = (msg.len() * 8u) as u64;
|
||||
|
||||
// pad message
|
||||
let mut msg = vec::append(vec::to_owned(msg), [0x80u8]);
|
||||
let mut msg = vec::append(msg.to_owned(), [0x80u8]);
|
||||
let mut bitlen = orig_len + 8u64;
|
||||
while (bitlen + 64u64) % 512u64 > 0u64 {
|
||||
msg.push(0u8);
|
||||
|
@ -567,7 +567,7 @@ impl BigUint {
|
||||
/// Creates and initializes an BigUint.
|
||||
|
||||
pub fn from_slice(slice: &[BigDigit]) -> BigUint {
|
||||
return BigUint::new(vec::to_owned(slice));
|
||||
return BigUint::new(slice.to_owned());
|
||||
}
|
||||
|
||||
/// Creates and initializes an BigUint.
|
||||
|
@ -12,7 +12,6 @@ use sort;
|
||||
use std::cmp;
|
||||
use std::io;
|
||||
use std::num;
|
||||
use std::vec;
|
||||
|
||||
// NB: this can probably be rewritten in terms of num::Num
|
||||
// to be less f64-specific.
|
||||
@ -200,13 +199,13 @@ impl<'self> Stats for &'self [f64] {
|
||||
}
|
||||
|
||||
fn percentile(self, pct: f64) -> f64 {
|
||||
let mut tmp = vec::to_owned(self);
|
||||
let mut tmp = self.to_owned();
|
||||
sort::tim_sort(tmp);
|
||||
percentile_of_sorted(tmp, pct)
|
||||
}
|
||||
|
||||
fn quartiles(self) -> (f64,f64,f64) {
|
||||
let mut tmp = vec::to_owned(self);
|
||||
let mut tmp = self.to_owned();
|
||||
sort::tim_sort(tmp);
|
||||
let a = percentile_of_sorted(tmp, 25.0);
|
||||
let b = percentile_of_sorted(tmp, 50.0);
|
||||
@ -251,7 +250,7 @@ priv fn percentile_of_sorted(sorted_samples: &[f64],
|
||||
///
|
||||
/// See: http://en.wikipedia.org/wiki/Winsorising
|
||||
pub fn winsorize(samples: &mut [f64], pct: f64) {
|
||||
let mut tmp = vec::to_owned(samples);
|
||||
let mut tmp = samples.to_owned();
|
||||
sort::tim_sort(tmp);
|
||||
let lo = percentile_of_sorted(tmp, pct);
|
||||
let hi = percentile_of_sorted(tmp, 100.0-pct);
|
||||
|
@ -714,7 +714,7 @@ pub fn maybe_get_item_ast(cdata: cmd, tcx: ty::ctxt,
|
||||
let item_doc = lookup_item(id, cdata.data);
|
||||
let path = {
|
||||
let item_path = item_path(item_doc);
|
||||
vec::to_owned(item_path.init())
|
||||
item_path.init().to_owned()
|
||||
};
|
||||
match decode_inlined_item(cdata, tcx, copy path, item_doc) {
|
||||
Some(ref ii) => csearch::found((/*bad*/copy *ii)),
|
||||
|
@ -1659,7 +1659,7 @@ pub fn encode_metadata(parms: EncodeParams, crate: &crate) -> ~[u8] {
|
||||
|
||||
let writer_bytes: &mut ~[u8] = wr.bytes;
|
||||
|
||||
vec::to_owned(metadata_encoding_version) +
|
||||
metadata_encoding_version.to_owned() +
|
||||
flate::deflate_bytes(*writer_bytes)
|
||||
}
|
||||
|
||||
|
@ -484,7 +484,7 @@ pub fn specialize(cx: &MatchCheckCtxt,
|
||||
match cx.tcx.def_map.find(&pat_id) {
|
||||
Some(&def_variant(_, id)) => {
|
||||
if variant(id) == *ctor_id {
|
||||
Some(vec::to_owned(r.tail()))
|
||||
Some(r.tail().to_owned())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
@ -522,7 +522,7 @@ pub fn specialize(cx: &MatchCheckCtxt,
|
||||
_ => fail!("type error")
|
||||
};
|
||||
if match_ {
|
||||
Some(vec::to_owned(r.tail()))
|
||||
Some(r.tail().to_owned())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
@ -569,7 +569,7 @@ pub fn specialize(cx: &MatchCheckCtxt,
|
||||
_ => fail!("type error")
|
||||
};
|
||||
if match_ {
|
||||
Some(vec::to_owned(r.tail()))
|
||||
Some(r.tail().to_owned())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
@ -579,7 +579,7 @@ pub fn specialize(cx: &MatchCheckCtxt,
|
||||
Some(args) => args,
|
||||
None => vec::from_elem(arity, wild())
|
||||
};
|
||||
Some(vec::append(args, vec::to_owned(r.tail())))
|
||||
Some(vec::append(args, r.tail()))
|
||||
}
|
||||
def_variant(_, _) => None,
|
||||
|
||||
@ -591,7 +591,7 @@ pub fn specialize(cx: &MatchCheckCtxt,
|
||||
Some(args) => new_args = args,
|
||||
None => new_args = vec::from_elem(arity, wild())
|
||||
}
|
||||
Some(vec::append(new_args, vec::to_owned(r.tail())))
|
||||
Some(vec::append(new_args, r.tail()))
|
||||
}
|
||||
_ => None
|
||||
}
|
||||
@ -609,7 +609,7 @@ pub fn specialize(cx: &MatchCheckCtxt,
|
||||
_ => wild()
|
||||
}
|
||||
});
|
||||
Some(vec::append(args, vec::to_owned(r.tail())))
|
||||
Some(vec::append(args, r.tail()))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
@ -640,7 +640,7 @@ pub fn specialize(cx: &MatchCheckCtxt,
|
||||
_ => wild()
|
||||
}
|
||||
}).collect();
|
||||
Some(vec::append(args, vec::to_owned(r.tail())))
|
||||
Some(vec::append(args, r.tail()))
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -676,14 +676,14 @@ pub fn specialize(cx: &MatchCheckCtxt,
|
||||
single => true,
|
||||
_ => fail!("type error")
|
||||
};
|
||||
if match_ { Some(vec::to_owned(r.tail())) } else { None }
|
||||
if match_ { Some(r.tail().to_owned()) } else { None }
|
||||
}
|
||||
pat_range(lo, hi) => {
|
||||
let (c_lo, c_hi) = match *ctor_id {
|
||||
val(ref v) => ((/*bad*/copy *v), (/*bad*/copy *v)),
|
||||
range(ref lo, ref hi) =>
|
||||
((/*bad*/copy *lo), (/*bad*/copy *hi)),
|
||||
single => return Some(vec::to_owned(r.tail())),
|
||||
single => return Some(r.tail().to_owned()),
|
||||
_ => fail!("type error")
|
||||
};
|
||||
let v_lo = eval_const_expr(cx.tcx, lo);
|
||||
@ -693,7 +693,7 @@ pub fn specialize(cx: &MatchCheckCtxt,
|
||||
let m2 = compare_const_vals(&c_hi, &v_hi);
|
||||
match (m1, m2) {
|
||||
(Some(val1), Some(val2)) if val1 >= 0 && val2 <= 0 => {
|
||||
Some(vec::to_owned(r.tail()))
|
||||
Some(r.tail().to_owned())
|
||||
},
|
||||
(Some(_), Some(_)) => None,
|
||||
_ => {
|
||||
@ -734,7 +734,7 @@ pub fn specialize(cx: &MatchCheckCtxt,
|
||||
}
|
||||
|
||||
pub fn default(cx: &MatchCheckCtxt, r: &[@pat]) -> Option<~[@pat]> {
|
||||
if is_wild(cx, r[0]) { Some(vec::to_owned(r.tail())) }
|
||||
if is_wild(cx, r[0]) { Some(r.tail().to_owned()) }
|
||||
else { None }
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,6 @@
|
||||
use std::container::Map;
|
||||
use std::libc::c_ulonglong;
|
||||
use std::option::{Option, Some, None};
|
||||
use std::vec;
|
||||
|
||||
use lib::llvm::{ValueRef, True, IntEQ, IntNE};
|
||||
use middle::trans::_match;
|
||||
@ -219,7 +218,7 @@ fn mk_struct(cx: &mut CrateContext, tys: &[ty::t], packed: bool) -> Struct {
|
||||
size: machine::llsize_of_alloc(cx, llty_rec) /*bad*/as u64,
|
||||
align: machine::llalign_of_min(cx, llty_rec) /*bad*/as u64,
|
||||
packed: packed,
|
||||
fields: vec::to_owned(tys)
|
||||
fields: tys.to_owned(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3782,7 +3782,7 @@ pub fn item_path(cx: ctxt, id: ast::def_id) -> ast_map::path {
|
||||
}
|
||||
|
||||
ast_map::node_variant(ref variant, _, path) => {
|
||||
vec::append_one(vec::to_owned(path.init()),
|
||||
vec::append_one(path.init().to_owned(),
|
||||
ast_map::path_name((*variant).node.name))
|
||||
}
|
||||
|
||||
|
@ -591,7 +591,7 @@ impl<R: Rng> RngUtil for R {
|
||||
|
||||
/// Shuffle a vec
|
||||
fn shuffle<T:Copy>(&mut self, values: &[T]) -> ~[T] {
|
||||
let mut m = vec::to_owned(values);
|
||||
let mut m = values.to_owned();
|
||||
self.shuffle_mut(m);
|
||||
m
|
||||
}
|
||||
|
@ -91,11 +91,6 @@ pub fn from_elem<T:Copy>(n_elts: uint, t: T) -> ~[T] {
|
||||
}
|
||||
}
|
||||
|
||||
/// Creates a new unique vector with the same contents as the slice
|
||||
pub fn to_owned<T:Copy>(t: &[T]) -> ~[T] {
|
||||
from_fn(t.len(), |i| copy t[i])
|
||||
}
|
||||
|
||||
/// Creates a new vector with a capacity of `capacity`
|
||||
#[cfg(stage0)]
|
||||
pub fn with_capacity<T>(capacity: uint) -> ~[T] {
|
||||
|
@ -20,7 +20,6 @@ use diagnostic::span_handler;
|
||||
use parse::comments::{doc_comment_style, strip_doc_comment_decoration};
|
||||
|
||||
use std::hashmap::HashSet;
|
||||
use std::vec;
|
||||
/* Constructors */
|
||||
|
||||
pub fn mk_name_value_item_str(name: @str, value: @str)
|
||||
@ -256,7 +255,7 @@ pub fn last_meta_item_list_by_name(items: ~[@ast::meta_item], name: &str)
|
||||
|
||||
pub fn sort_meta_items(items: &[@ast::meta_item]) -> ~[@ast::meta_item] {
|
||||
// This is sort of stupid here, converting to a vec of mutables and back
|
||||
let mut v = vec::to_owned(items);
|
||||
let mut v = items.to_owned();
|
||||
do extra::sort::quick_sort(v) |ma, mb| {
|
||||
get_meta_item_name(*ma) <= get_meta_item_name(*mb)
|
||||
}
|
||||
|
@ -19,8 +19,6 @@ use ext::base::*;
|
||||
use parse;
|
||||
use parse::token;
|
||||
|
||||
use std::vec;
|
||||
|
||||
enum State {
|
||||
Asm,
|
||||
Outputs,
|
||||
@ -43,7 +41,7 @@ pub fn expand_asm(cx: @ExtCtxt, sp: span, tts: &[ast::token_tree])
|
||||
-> base::MacResult {
|
||||
let p = parse::new_parser_from_tts(cx.parse_sess(),
|
||||
cx.cfg(),
|
||||
vec::to_owned(tts));
|
||||
tts.to_owned());
|
||||
|
||||
let mut asm = @"";
|
||||
let mut outputs = ~[];
|
||||
|
@ -18,7 +18,6 @@ use parse;
|
||||
use parse::token;
|
||||
use parse::token::{ident_to_str, intern, str_to_ident};
|
||||
|
||||
use std::vec;
|
||||
use std::hashmap::HashMap;
|
||||
|
||||
// new-style macro! tt code:
|
||||
@ -362,7 +361,7 @@ pub fn get_exprs_from_tts(cx: @ExtCtxt, tts: &[ast::token_tree])
|
||||
-> ~[@ast::expr] {
|
||||
let p = parse::new_parser_from_tts(cx.parse_sess(),
|
||||
cx.cfg(),
|
||||
vec::to_owned(tts));
|
||||
tts.to_owned());
|
||||
let mut es = ~[];
|
||||
while *p.token != token::EOF {
|
||||
if es.len() != 0 {
|
||||
|
@ -15,7 +15,6 @@ use ext::base;
|
||||
use print;
|
||||
use parse::token::{get_ident_interner};
|
||||
|
||||
use std::vec;
|
||||
use std::io;
|
||||
|
||||
pub fn expand_syntax_ext(cx: @ExtCtxt,
|
||||
@ -26,7 +25,7 @@ pub fn expand_syntax_ext(cx: @ExtCtxt,
|
||||
cx.print_backtrace();
|
||||
io::stdout().write_line(
|
||||
print::pprust::tt_to_str(
|
||||
&ast::tt_delim(vec::to_owned(tt)),
|
||||
&ast::tt_delim(tt.to_owned()),
|
||||
get_ident_interner()));
|
||||
|
||||
//trivial expression
|
||||
|
@ -17,8 +17,6 @@ use parse::token::*;
|
||||
use parse::token;
|
||||
use parse;
|
||||
|
||||
use std::vec;
|
||||
|
||||
/**
|
||||
*
|
||||
* Quasiquoting works via token trees.
|
||||
@ -653,7 +651,7 @@ fn expand_tts(cx: @ExtCtxt,
|
||||
let p = parse::new_parser_from_tts(
|
||||
cx.parse_sess(),
|
||||
cx.cfg(),
|
||||
vec::to_owned(tts)
|
||||
tts.to_owned()
|
||||
);
|
||||
*p.quote_depth += 1u;
|
||||
let tts = p.parse_all_token_trees();
|
||||
|
@ -16,8 +16,6 @@ use parse::lexer::{new_tt_reader, reader};
|
||||
use parse::parser::Parser;
|
||||
use parse::token::keywords;
|
||||
|
||||
use std::vec;
|
||||
|
||||
pub fn expand_trace_macros(cx: @ExtCtxt,
|
||||
sp: span,
|
||||
tt: &[ast::token_tree])
|
||||
@ -27,7 +25,7 @@ pub fn expand_trace_macros(cx: @ExtCtxt,
|
||||
let tt_rdr = new_tt_reader(
|
||||
copy cx.parse_sess().span_diagnostic,
|
||||
None,
|
||||
vec::to_owned(tt)
|
||||
tt.to_owned()
|
||||
);
|
||||
let rdr = tt_rdr as @reader;
|
||||
let rust_parser = Parser(
|
||||
|
@ -23,7 +23,6 @@ use parse::token::{get_ident_interner, special_idents, gensym_ident, ident_to_st
|
||||
use parse::token::{FAT_ARROW, SEMI, nt_matchers, nt_tt};
|
||||
use print;
|
||||
|
||||
use std::vec;
|
||||
use std::io;
|
||||
|
||||
pub fn add_new_extension(cx: @ExtCtxt,
|
||||
@ -82,7 +81,7 @@ pub fn add_new_extension(cx: @ExtCtxt,
|
||||
io::println(fmt!("%s! { %s }",
|
||||
cx.str_of(name),
|
||||
print::pprust::tt_to_str(
|
||||
&ast::tt_delim(vec::to_owned(arg)),
|
||||
&ast::tt_delim(arg.to_owned()),
|
||||
get_ident_interner())));
|
||||
}
|
||||
|
||||
@ -99,7 +98,7 @@ pub fn add_new_extension(cx: @ExtCtxt,
|
||||
let arg_rdr = new_tt_reader(
|
||||
s_d,
|
||||
None,
|
||||
vec::to_owned(arg)
|
||||
arg.to_owned()
|
||||
) as @reader;
|
||||
match parse(cx.parse_sess(), cx.cfg(), arg_rdr, *mtcs) {
|
||||
success(named_matches) => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user