std: remove str::{connect,concat}*.

This commit is contained in:
Huon Wilson 2013-06-10 23:25:25 +10:00
parent 5a711ea7c3
commit ccd0ac59e9
38 changed files with 62 additions and 86 deletions

View File

@ -244,7 +244,7 @@ fn run_debuginfo_test(config: &config, props: &TestProps, testfile: &Path) {
None => copy *config
};
let config = &mut config;
let cmds = str::connect(props.debugger_cmds, "\n");
let cmds = props.debugger_cmds.connect("\n");
let check_lines = copy props.check_lines;
// compile test file (it shoud have 'compile-flags:-g' in the header)
@ -645,13 +645,13 @@ fn program_output(config: &config, testfile: &Path, lib_path: &str, prog: ~str,
#[cfg(target_os = "macos")]
#[cfg(target_os = "freebsd")]
fn make_cmdline(_libpath: &str, prog: &str, args: &[~str]) -> ~str {
fmt!("%s %s", prog, str::connect(args, " "))
fmt!("%s %s", prog, args.connect(" "))
}
#[cfg(target_os = "win32")]
fn make_cmdline(libpath: &str, prog: &str, args: &[~str]) -> ~str {
fmt!("%s %s %s", lib_path_cmd_prefix(libpath), prog,
str::connect(args, " "))
args.connect(" "))
}
// Build the LD_LIBRARY_PATH variable as it would be seen on the command line

View File

@ -648,14 +648,14 @@ pub mod groups {
// FIXME: #5516
// wrapped description
row += str::connect(desc_rows, desc_sep);
row += desc_rows.connect(desc_sep);
row
});
return str::to_owned(brief) +
"\n\nOptions:\n" +
str::connect(rows, "\n") +
rows.connect("\n") +
"\n\n";
}
} // end groups module

View File

@ -354,7 +354,7 @@ pub fn query_to_str(query: &Query) -> ~str {
}
}
}
return str::connect(strvec, "&");
return strvec.connect("&");
}
// returns the scheme and the rest of the url, or a parsing error

View File

@ -520,10 +520,10 @@ impl ToStrRadix for BigUint {
fn fill_concat(v: &[BigDigit], radix: uint, l: uint) -> ~str {
if v.is_empty() { return ~"0" }
let s = str::concat(vec::reversed(v).map(|n| {
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();
s.trim_left_chars(['0']).to_owned()
}
}

View File

@ -81,12 +81,12 @@ impl ToStr for Version {
let s = if self.pre.is_empty() {
s
} else {
s + "-" + str::connect(self.pre.map(|i| i.to_str()), ".")
s + "-" + self.pre.map(|i| i.to_str()).connect(".")
};
if self.build.is_empty() {
s
} else {
s + "+" + str::connect(self.build.map(|i| i.to_str()), ".")
s + "+" + self.build.map(|i| i.to_str()).connect(".")
}
}
}

View File

@ -394,7 +394,7 @@ pub mod write {
sess.err(fmt!("building with `%s` failed with code %d",
cc_prog, prog.status));
sess.note(fmt!("%s arguments: %s",
cc_prog, str::connect(cc_args, " ")));
cc_prog, cc_args.connect(" ")));
sess.note(str::from_bytes(prog.error + prog.output));
sess.abort_if_errors();
}
@ -809,14 +809,14 @@ pub fn link_binary(sess: Session,
debug!("output: %s", output.to_str());
let cc_args = link_args(sess, obj_filename, out_filename, lm);
debug!("%s link args: %s", cc_prog, str::connect(cc_args, " "));
debug!("%s link args: %s", cc_prog, cc_args.connect(" "));
// We run 'cc' here
let prog = run::process_output(cc_prog, cc_args);
if 0 != prog.status {
sess.err(fmt!("linking with `%s` failed with code %d",
cc_prog, prog.status));
sess.note(fmt!("%s arguments: %s",
cc_prog, str::connect(cc_args, " ")));
cc_prog, cc_args.connect(" ")));
sess.note(str::from_bytes(prog.error + prog.output));
sess.abort_if_errors();
}

View File

@ -328,8 +328,8 @@ pub fn compile_rest(sess: Session,
let outputs = outputs.get_ref();
if (sess.opts.debugging_opts & session::print_link_args) != 0 {
io::println(str::connect(link::link_args(sess,
&outputs.obj_filename, &outputs.out_filename, link_meta), " "));
io::println(link::link_args(sess, &outputs.obj_filename,
&outputs.out_filename, link_meta).connect(" "));
}
// NB: Android hack

View File

@ -87,7 +87,7 @@ pub fn trans_inline_asm(bcx: block, ia: &ast::inline_asm) -> block {
revoke_clean(bcx, *c);
}
let mut constraints = str::connect(constraints, ",");
let mut constraints = constraints.connect(",");
let mut clobbers = getClobbers();
if *ia.clobbers != ~"" && clobbers != ~"" {

View File

@ -1995,7 +1995,7 @@ pub fn trans_enum_variant(ccx: @CrateContext,
debug!("trans_enum_variant: name=%s tps=%s repr=%? enum_ty=%s",
unsafe { str::raw::from_c_str(llvm::LLVMGetValueName(llfndecl)) },
~"[" + str::connect(ty_param_substs.map(|&t| ty_to_str(ccx.tcx, t)), ", ") + "]",
~"[" + ty_param_substs.map(|&t| ty_to_str(ccx.tcx.connect(t)), ", ") + "]",
repr, ty_to_str(ccx.tcx, enum_ty));
adt::trans_start_init(bcx, repr, fcx.llretptr.get(), disr);

View File

@ -192,7 +192,7 @@ pub fn Invoke(cx: block,
terminate(cx, "Invoke");
debug!("Invoke(%s with arguments (%s))",
val_str(cx.ccx().tn, Fn),
str::connect(vec::map(Args, |a| val_str(cx.ccx().tn,
vec::map(Args.connect(|a| val_str(cx.ccx().tn,
*a).to_owned()),
", "));
unsafe {

View File

@ -1483,7 +1483,7 @@ pub fn node_id_type_params(bcx: block, id: ast::node_id) -> ~[ty::t] {
if !params.all(|t| !ty::type_needs_infer(*t)) {
bcx.sess().bug(
fmt!("Type parameters for node %d include inference types: %s",
id, str::connect(params.map(|t| bcx.ty_to_str(*t)), ",")));
id, params.map(|t| bcx.ty_to_str(*t)).connect(",")));
}
match bcx.fcx.param_substs {

View File

@ -1879,7 +1879,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
} else {
"s"
},
str::connect(missing_fields, ", ")));
missing_fields.connect(", ")));
}
}

View File

@ -100,7 +100,7 @@ impl Env {
return match search_mod(self, &self.crate.node.module, 0, names) {
Some(id) => id,
None => {
fail!("No item found: `%s`", str::connect(names, "::"));
fail!("No item found: `%s`", names.connect("::"));
}
};

View File

@ -35,7 +35,7 @@ impl InferStr for ty::t {
impl InferStr for FnSig {
fn inf_str(&self, cx: &InferCtxt) -> ~str {
fmt!("(%s) -> %s",
str::connect(self.inputs.map(|a| a.inf_str(cx)), ", "),
self.inputs.map(|a| a.inf_str(cx)).connect(", "),
self.output.inf_str(cx))
}
}

View File

@ -111,7 +111,7 @@ pub fn local_rhs_span(l: @ast::local, def: span) -> span {
pub fn pluralize(n: uint, s: ~str) -> ~str {
if n == 1 { s }
else { str::concat([s, ~"s"]) }
else { fmt!("%ss", s) }
}
// A set of node IDs (used to keep track of which node IDs are for statements)

View File

@ -281,7 +281,7 @@ pub fn vstore_ty_to_str(cx: ctxt, mt: &mt, vs: ty::vstore) -> ~str {
pub fn tys_to_str(cx: ctxt, ts: &[t]) -> ~str {
let tstrs = ts.map(|t| ty_to_str(cx, *t));
fmt!("(%s)", str::connect(tstrs, ", "))
fmt!("(%s)", tstrs.connect(", "))
}
pub fn fn_sig_to_str(cx: ctxt, typ: &ty::FnSig) -> ~str {
@ -369,7 +369,7 @@ pub fn ty_to_str(cx: ctxt, typ: t) -> ~str {
fn push_sig_to_str(cx: ctxt, s: &mut ~str, sig: &ty::FnSig) {
s.push_char('(');
let strs = sig.inputs.map(|a| fn_input_to_str(cx, *a));
s.push_str(str::connect(strs, ", "));
s.push_str(strs.connect(", "));
s.push_char(')');
if ty::get(sig.output).sty != ty_nil {
s.push_str(" -> ");
@ -420,7 +420,7 @@ pub fn ty_to_str(cx: ctxt, typ: t) -> ~str {
ty_type => ~"type",
ty_tup(ref elems) => {
let strs = elems.map(|elem| ty_to_str(cx, *elem));
~"(" + str::connect(strs, ",") + ")"
~"(" + strs.connect(",") + ")"
}
ty_closure(ref f) => {
closure_to_str(cx, f)
@ -477,7 +477,7 @@ pub fn parameterized(cx: ctxt,
if tps.len() > 0u {
let strs = vec::map(tps, |t| ty_to_str(cx, *t));
fmt!("%s%s<%s>", base, r_str, str::connect(strs, ","))
fmt!("%s%s<%s>", base, r_str, strs.connect(","))
} else {
fmt!("%s%s", base, r_str)
}
@ -515,7 +515,7 @@ impl<T:Repr> Repr for ~T {
*/
fn repr_vec<T:Repr>(tcx: ctxt, v: &[T]) -> ~str {
fmt!("[%s]", str::connect(v.map(|t| t.repr(tcx)), ","))
fmt!("[%s]", v.map(|t| t.repr(tcx)).connect(","))
}
impl<'self, T:Repr> Repr for &'self [T] {
@ -569,7 +569,7 @@ impl Repr for ty::ParamBounds {
for self.trait_bounds.each |t| {
res.push(t.repr(tcx));
}
str::connect(res, "+")
res.connect("+")
}
}
@ -787,7 +787,7 @@ impl UserString for ty::BuiltinBounds {
for self.each |bb| {
result.push(bb.user_string(tcx));
}
str::connect(result, "+")
result.connect("+")
}
}
}

View File

@ -53,7 +53,7 @@ pub fn parse_desc(attrs: ~[ast::attribute]) -> Option<~str> {
if doc_strs.is_empty() {
None
} else {
Some(str::connect(doc_strs, "\n"))
Some(doc_strs.connect("\n"))
}
}

View File

@ -173,7 +173,7 @@ pub fn header_kind(doc: doc::ItemTag) -> ~str {
}
pub fn header_name(doc: doc::ItemTag) -> ~str {
let fullpath = str::connect(doc.path() + [doc.name()], "::");
let fullpath = (doc.path() + [doc.name()]).connect("::");
match &doc {
&doc::ModTag(_) if doc.id() != syntax::ast::crate_node_id => {
fullpath
@ -414,7 +414,7 @@ fn code_block_indent(s: ~str) -> ~str {
for str::each_line_any(s) |line| {
indented.push(fmt!(" %s", line));
}
str::connect(indented, "\n")
indented.connect("\n")
}
fn write_const(
@ -476,7 +476,7 @@ fn list_item_indent(item: &str) -> ~str {
// separate markdown elements within `*` lists must be indented by four
// spaces, or they will escape the list context. indenting everything
// seems fine though.
str::connect_slices(indented, "\n ")
indented.connect("\n ")
}
fn write_trait(ctxt: &Ctxt, doc: doc::TraitDoc) {

View File

@ -107,7 +107,7 @@ fn pandoc_writer(
use core::io::WriterUtil;
debug!("pandoc cmd: %s", pandoc_cmd);
debug!("pandoc args: %s", str::connect(pandoc_args, " "));
debug!("pandoc args: %s", pandoc_args.connect(" "));
let mut proc = run::Process::new(pandoc_cmd, pandoc_args, run::ProcessOptions::new());
@ -164,7 +164,7 @@ pub fn make_filename(
}
}
doc::ItemPage(doc) => {
str::connect(doc.path() + [doc.name()], "_")
(doc.path() + [doc.name()]).connect("_")
}
}
};

View File

@ -87,7 +87,7 @@ fn unindent(s: &str) -> ~str {
line.slice(min_indent, line.len()).to_owned()
}
};
str::connect(unindented, "\n")
unindented.connect("\n")
} else {
s.to_str()
}

View File

@ -308,7 +308,7 @@ fn run_cmd(repl: &mut Repl, _in: @io::Reader, _out: @io::Writer,
println("no crates loaded");
} else {
println(fmt!("crates loaded: %s",
str::connect(loaded_crates, ", ")));
loaded_crates.connect(", ")));
}
}
~"{" => {

View File

@ -207,8 +207,8 @@ pub fn compile_input(ctxt: &Ctx,
let binary = @(copy os::args()[0]);
debug!("flags: %s", str::connect(flags, " "));
debug!("cfgs: %s", str::connect(cfgs, " "));
debug!("flags: %s", flags.connect(" "));
debug!("cfgs: %s", cfgs.connect(" "));
debug!("compile_input's sysroot = %?", ctxt.sysroot_opt);
let crate_type = match what {

View File

@ -22,7 +22,7 @@ use iterator::IteratorUtil;
use libc;
use option::{None, Option, Some};
use str;
use str::StrSlice;
use str::{StrSlice, StrVector};
use to_str::ToStr;
use ascii::{AsciiCast, AsciiStr};
use old_iter::BaseIter;
@ -442,7 +442,7 @@ impl ToStr for PosixPath {
if self.is_absolute {
s += "/";
}
s + str::connect(self.components, "/")
s + self.components.connect("/")
}
}
@ -629,7 +629,7 @@ impl ToStr for WindowsPath {
if self.is_absolute {
s += "\\";
}
s + str::connect(self.components, "\\")
s + self.components.connect("\\")
}
}

View File

@ -170,18 +170,6 @@ pub fn append(lhs: ~str, rhs: &str) -> ~str {
v
}
/// Concatenate a vector of strings
pub fn concat(v: &[~str]) -> ~str { v.concat() }
/// Concatenate a vector of strings
pub fn concat_slices(v: &[&str]) -> ~str { v.concat() }
/// Concatenate a vector of strings, placing a given separator between each
pub fn connect(v: &[~str], sep: &str) -> ~str { v.connect(sep) }
/// Concatenate a vector of strings, placing a given separator between each
pub fn connect_slices(v: &[&str], sep: &str) -> ~str { v.connect(sep) }
#[allow(missing_doc)]
pub trait StrVector {
pub fn concat(&self) -> ~str;
@ -2495,7 +2483,6 @@ mod tests {
#[test]
fn test_concat() {
fn t(v: &[~str], s: &str) {
assert_eq!(concat(v), s.to_str());
assert_eq!(v.concat(), s.to_str());
}
t([~"you", ~"know", ~"I'm", ~"no", ~"good"], "youknowI'mnogood");
@ -2507,7 +2494,6 @@ mod tests {
#[test]
fn test_connect() {
fn t(v: &[~str], sep: &str, s: &str) {
assert_eq!(connect(v, sep), s.to_str());
assert_eq!(v.connect(sep), s.to_str());
}
t([~"you", ~"know", ~"I'm", ~"no", ~"good"],
@ -2520,7 +2506,6 @@ mod tests {
#[test]
fn test_concat_slices() {
fn t(v: &[&str], s: &str) {
assert_eq!(concat_slices(v), s.to_str());
assert_eq!(v.concat(), s.to_str());
}
t(["you", "know", "I'm", "no", "good"], "youknowI'mnogood");
@ -2532,7 +2517,6 @@ mod tests {
#[test]
fn test_connect_slices() {
fn t(v: &[&str], sep: &str, s: &str) {
assert_eq!(connect_slices(v, sep), s.to_str());
assert_eq!(v.connect(sep), s.to_str());
}
t(["you", "know", "I'm", "no", "good"],
@ -3307,7 +3291,6 @@ mod tests {
assert_eq!(lines, ~["", "Märy häd ä little lämb", "", "Little lämb"]);
}
#[test]
fn test_split_str_iterator() {
fn t<'a>(s: &str, sep: &'a str, u: ~[&str]) {

View File

@ -10,7 +10,6 @@
use core::prelude::*;
use core::str;
use core::to_bytes;
#[deriving(Eq)]
@ -267,7 +266,7 @@ impl ToStr for AbiSet {
for self.each |abi| {
strs.push(abi.data().name);
}
fmt!("\"%s\"", str::connect_slices(strs, " "))
fmt!("\"%s\"", strs.connect(" "))
}
}

View File

@ -62,7 +62,7 @@ pub fn path_to_str_with_sep(p: &[path_elt], sep: &str, itr: @ident_interner)
path_name(s) => copy *itr.get(s.name)
}
};
str::connect(strs, sep)
strs.connect(sep)
}
pub fn path_ident_to_str(p: &path, i: ident, itr: @ident_interner) -> ~str {

View File

@ -28,7 +28,7 @@ use core::to_bytes;
pub fn path_name_i(idents: &[ident]) -> ~str {
// FIXME: Bad copies (#2543 -- same for everything else that says "bad")
str::connect(idents.map(|i| copy *token::interner_get(i.name)), "::")
idents.map(|i| copy *token::interner_get(i.name)).connect("::")
}
pub fn path_to_ident(p: @Path) -> ident { copy *p.idents.last() }

View File

@ -120,7 +120,7 @@ pub fn expand_asm(cx: @ExtCtxt, sp: span, tts: &[ast::token_tree])
clobs.push(clob);
}
cons = str::connect(clobs, ",");
cons = clobs.connect(",");
}
Options => {
let option = p.parse_str();

View File

@ -88,7 +88,7 @@ pub fn analyze(proto: @mut protocol_, _cx: @ExtCtxt) {
}
if self_live.len() > 0 {
let states = str::connect(self_live.map(|s| copy s.name), " ");
let states = self_live.map(|s| copy s.name).connect(" ");
debug!("protocol %s is unbounded due to loops involving: %s",
copy proto.name, states);

View File

@ -24,7 +24,6 @@ use opt_vec;
use opt_vec::OptVec;
use core::iterator::IteratorUtil;
use core::str;
use core::vec;
pub trait gen_send {
@ -100,9 +99,9 @@ impl gen_send for message {
}
body += fmt!("let message = %s(%s);\n",
name,
str::connect(vec::append_one(
arg_names.map(|x| cx.str_of(*x)),
~"s"), ", "));
vec::append_one(
arg_names.map(|x| cx.str_of(*x)),
~"s").connect(", "));
if !try {
body += fmt!("::std::pipes::send(pipe, message);\n");
@ -155,8 +154,7 @@ impl gen_send for message {
~""
}
else {
~"(" + str::connect(arg_names.map(|x| copy *x),
", ") + ")"
~"(" + arg_names.map(|x| copy *x).connect(", ") + ")"
};
let mut body = ~"{ ";

View File

@ -92,7 +92,7 @@ pub mod rt {
impl<'self> ToSource for &'self [@ast::item] {
fn to_source(&self) -> ~str {
str::connect(self.map(|i| i.to_source()), "\n\n")
self.map(|i| i.to_source()).connect("\n\n")
}
}
@ -104,7 +104,7 @@ pub mod rt {
impl<'self> ToSource for &'self [@ast::Ty] {
fn to_source(&self) -> ~str {
str::connect(self.map(|i| i.to_source()), ", ")
self.map(|i| i.to_source()).connect(", ")
}
}

View File

@ -23,7 +23,6 @@ use print::pprust;
use core::io;
use core::result;
use core::str;
use core::vec;
// These macros all relate to the file system; they either return
@ -74,8 +73,7 @@ pub fn expand_mod(cx: @ExtCtxt, sp: span, tts: &[ast::token_tree])
-> base::MacResult {
base::check_zero_tts(cx, sp, tts, "module_path!");
base::MRExpr(cx.expr_str(sp,
str::connect(cx.mod_path().map(
|x| cx.str_of(*x)), "::")))
cx.mod_path().map(|x| cx.str_of(*x)).connect("::")))
}
// include! : parse the given file as an expr

View File

@ -371,7 +371,7 @@ pub fn parse(
} else {
if (bb_eis.len() > 0u && next_eis.len() > 0u)
|| bb_eis.len() > 1u {
let nts = str::connect(vec::map(bb_eis, |ei| {
let nts = vec::map(bb_eis.connect(|ei| {
match ei.elts[ei.idx].node {
match_nonterminal(ref bind,ref name,_) => {
fmt!("%s ('%s')", *ident_to_str(name),

View File

@ -116,7 +116,7 @@ pub fn strip_doc_comment_decoration(comment: &str) -> ~str {
let lines = block_trim(lines, ~"\t ", None);
let lines = block_trim(lines, ~"*", Some(1u));
let lines = block_trim(lines, ~"\t ", None);
return str::connect(lines, "\n");
return lines.connect("\n");
}
fail!("not a doc-comment: %s", comment);

View File

@ -4002,9 +4002,7 @@ impl Parser {
fmt!("illegal ABI: \
expected one of [%s], \
found `%s`",
str::connect_slices(
abi::all_names(),
", "),
abi::all_names().connect(", "),
word));
}
}

View File

@ -120,7 +120,7 @@ impl ToStr for AsciiArt {
let lines = do self.lines.map |line| {str::from_chars(*line)};
// Concatenate the lines together using a new-line.
str::connect(lines, "\n")
lines.connect("\n")
}
}

View File

@ -98,8 +98,8 @@ priv fn cmd_to_str(cmd: ~[~str]) -> ~str {
res.push_str(cmd.len().to_str());
res.push_str("\r\n");
for cmd.each |s| {
res.push_str(str::concat(~[~"$", s.len().to_str(), ~"\r\n",
copy *s, ~"\r\n"]));
res.push_str([~"$", s.len().to_str(), ~"\r\n",
copy *s, ~"\r\n"].concat()));
}
res
}

View File

@ -26,7 +26,7 @@ impl to_str for int {
impl<T:to_str> to_str for ~[T] {
fn to_str(&self) -> ~str {
~"[" + str::connect(vec::map(*self, |e| e.to_str() ), ", ") + "]"
~"[" + self.map(|e| e.to_str()).connect(", ") + "]"
}
}