diff --git a/src/test/auxiliary/cci_class_4.rs b/src/test/auxiliary/cci_class_4.rs index 733509753d38..67e57de085aa 100644 --- a/src/test/auxiliary/cci_class_4.rs +++ b/src/test/auxiliary/cci_class_4.rs @@ -13,7 +13,7 @@ pub mod kitties { meows : uint, pub how_hungry : int, - pub name : ~str, + pub name : StrBuf, } impl cat { @@ -41,7 +41,7 @@ pub mod kitties { } } - pub fn cat(in_x : uint, in_y : int, in_name: ~str) -> cat { + pub fn cat(in_x : uint, in_y : int, in_name: StrBuf) -> cat { cat { meows: in_x, how_hungry: in_y, diff --git a/src/test/auxiliary/cci_class_cast.rs b/src/test/auxiliary/cci_class_cast.rs index 2ce4f818659e..0abacf9ecdd2 100644 --- a/src/test/auxiliary/cci_class_cast.rs +++ b/src/test/auxiliary/cci_class_cast.rs @@ -14,7 +14,7 @@ pub mod kitty { pub struct cat { meows : uint, pub how_hungry : int, - pub name : ~str, + pub name : StrBuf, } impl fmt::Show for cat { @@ -50,7 +50,7 @@ pub mod kitty { } } - pub fn cat(in_x : uint, in_y : int, in_name: ~str) -> cat { + pub fn cat(in_x : uint, in_y : int, in_name: StrBuf) -> cat { cat { meows: in_x, how_hungry: in_y, diff --git a/src/test/auxiliary/crate-method-reexport-grrrrrrr2.rs b/src/test/auxiliary/crate-method-reexport-grrrrrrr2.rs index f7b42e05d7f8..36e46f6c8c28 100644 --- a/src/test/auxiliary/crate-method-reexport-grrrrrrr2.rs +++ b/src/test/auxiliary/crate-method-reexport-grrrrrrr2.rs @@ -17,11 +17,11 @@ pub mod name_pool { pub type name_pool = (); pub trait add { - fn add(&self, s: ~str); + fn add(&self, s: StrBuf); } impl add for name_pool { - fn add(&self, _s: ~str) { + fn add(&self, _s: StrBuf) { } } } diff --git a/src/test/auxiliary/crateresolve5-1.rs b/src/test/auxiliary/crateresolve5-1.rs index 8c9ce5dda66f..ca3cf1bd857a 100644 --- a/src/test/auxiliary/crateresolve5-1.rs +++ b/src/test/auxiliary/crateresolve5-1.rs @@ -12,10 +12,10 @@ #![crate_type = "lib"] -pub struct NameVal { pub name: ~str, pub val: int } +pub struct NameVal { pub name: StrBuf, pub val: int } pub fn struct_nameval() -> NameVal { - NameVal { name: "crateresolve5".to_owned(), val: 10 } + NameVal { name: "crateresolve5".to_strbuf(), val: 10 } } pub enum e { diff --git a/src/test/auxiliary/crateresolve5-2.rs b/src/test/auxiliary/crateresolve5-2.rs index 52296e2c054a..631f68d0b847 100644 --- a/src/test/auxiliary/crateresolve5-2.rs +++ b/src/test/auxiliary/crateresolve5-2.rs @@ -12,9 +12,9 @@ #![crate_type = "lib"] -pub struct NameVal { pub name: ~str, pub val: int } +pub struct NameVal { pub name: StrBuf, pub val: int } pub fn struct_nameval() -> NameVal { - NameVal { name: "crateresolve5".to_owned(), val: 10 } + NameVal { name: "crateresolve5".to_strbuf(), val: 10 } } pub enum e { diff --git a/src/test/auxiliary/explicit_self_xcrate.rs b/src/test/auxiliary/explicit_self_xcrate.rs index e482e8c62cab..c23af84b3f5e 100644 --- a/src/test/auxiliary/explicit_self_xcrate.rs +++ b/src/test/auxiliary/explicit_self_xcrate.rs @@ -14,7 +14,7 @@ pub trait Foo { } pub struct Bar { - pub x: ~str + pub x: StrBuf } impl Foo for Bar { diff --git a/src/test/auxiliary/issue-2414-a.rs b/src/test/auxiliary/issue-2414-a.rs index 0e444a43c7ce..7767859144ac 100644 --- a/src/test/auxiliary/issue-2414-a.rs +++ b/src/test/auxiliary/issue-2414-a.rs @@ -17,6 +17,6 @@ trait foo { fn foo(&self); } -impl foo for ~str { +impl foo for StrBuf { fn foo(&self) {} } diff --git a/src/test/auxiliary/issue-2631-a.rs b/src/test/auxiliary/issue-2631-a.rs index 5da5653f26e6..495999bfcbcb 100644 --- a/src/test/auxiliary/issue-2631-a.rs +++ b/src/test/auxiliary/issue-2631-a.rs @@ -17,9 +17,11 @@ extern crate collections; use std::cell::RefCell; use collections::HashMap; -pub type header_map = HashMap<~str, @RefCell>>; +pub type header_map = HashMap>>; // the unused ty param is necessary so this gets monomorphized pub fn request(req: &header_map) { - let _x = (**((**req.get(&"METHOD".to_owned())).clone()).borrow().clone().get(0)).clone(); + let _x = (**((**req.get(&"METHOD".to_strbuf())).clone()).borrow() + .clone() + .get(0)).clone(); } diff --git a/src/test/auxiliary/issue13507.rs b/src/test/auxiliary/issue13507.rs index 2b4df978cc8c..3c860958e2c1 100644 --- a/src/test/auxiliary/issue13507.rs +++ b/src/test/auxiliary/issue13507.rs @@ -48,7 +48,7 @@ pub mod testtypes { // Tests ty_float (does not test all variants of FloatTy) pub type FooFloat = f64; - // For ty_str, what kind of string should I use? &'static str? ~str? Raw str? + // For ty_str, what kind of string should I use? &'static str? StrBuf? Raw str? // Tests ty_enum pub enum FooEnum { diff --git a/src/test/auxiliary/issue_2242_a.rs b/src/test/auxiliary/issue_2242_a.rs index e51624dec388..855e48f3f91a 100644 --- a/src/test/auxiliary/issue_2242_a.rs +++ b/src/test/auxiliary/issue_2242_a.rs @@ -12,9 +12,9 @@ #![crate_type = "lib"] trait to_strz { - fn to_strz() -> ~str; + fn to_strz() -> StrBuf; } -impl to_strz for ~str { - fn to_strz() -> ~str { self.clone() } +impl to_strz for StrBuf { + fn to_strz() -> StrBuf { self.clone() } } diff --git a/src/test/auxiliary/issue_2242_c.rs b/src/test/auxiliary/issue_2242_c.rs index 4beb8118e210..6c04a742efb8 100644 --- a/src/test/auxiliary/issue_2242_c.rs +++ b/src/test/auxiliary/issue_2242_c.rs @@ -16,5 +16,5 @@ extern crate a; use a::to_strz; impl to_strz for bool { - fn to_strz() -> ~str { fmt!("%b", self) } + fn to_strz() -> StrBuf { fmt!("%b", self) } } diff --git a/src/test/auxiliary/reexported_static_methods.rs b/src/test/auxiliary/reexported_static_methods.rs index 6d94bfcf613b..f93bd5e2e497 100644 --- a/src/test/auxiliary/reexported_static_methods.rs +++ b/src/test/auxiliary/reexported_static_methods.rs @@ -31,7 +31,7 @@ pub mod sub_foo { } pub struct Boz { - unused_str: ~str + unused_str: StrBuf } impl Boz { @@ -46,8 +46,8 @@ pub mod sub_foo { } impl Bort { - pub fn bort() -> ~str { - "bort()".to_owned() + pub fn bort() -> StrBuf { + "bort()".to_strbuf() } } } diff --git a/src/test/auxiliary/static-methods-crate.rs b/src/test/auxiliary/static-methods-crate.rs index 4e0489b06850..367ab47ceaa1 100644 --- a/src/test/auxiliary/static-methods-crate.rs +++ b/src/test/auxiliary/static-methods-crate.rs @@ -14,17 +14,17 @@ use std::int; pub trait read { - fn readMaybe(s: ~str) -> Option; + fn readMaybe(s: StrBuf) -> Option; } impl read for int { - fn readMaybe(s: ~str) -> Option { - from_str::(s) + fn readMaybe(s: StrBuf) -> Option { + from_str::(s.as_slice()) } } impl read for bool { - fn readMaybe(s: ~str) -> Option { + fn readMaybe(s: StrBuf) -> Option { match s.as_slice() { "true" => Some(true), "false" => Some(false), @@ -33,7 +33,7 @@ impl read for bool { } } -pub fn read(s: ~str) -> T { +pub fn read(s: StrBuf) -> T { match read::readMaybe(s) { Some(x) => x, _ => fail!("read failed!") diff --git a/src/test/bench/core-set.rs b/src/test/bench/core-set.rs index b1181a3c17c5..33f0d3f6fba8 100644 --- a/src/test/bench/core-set.rs +++ b/src/test/bench/core-set.rs @@ -80,7 +80,7 @@ impl Results { } } - pub fn bench_str, + pub fn bench_str, R:rand::Rng>( &mut self, rng: &mut R, @@ -90,11 +90,11 @@ impl Results { let mut set = f(); timed(&mut self.sequential_strings, || { for i in range(0u, num_keys) { - set.insert(i.to_str()); + set.insert(i.to_str().to_strbuf()); } for i in range(0u, num_keys) { - assert!(set.contains(&i.to_str())); + assert!(set.contains(&i.to_str().to_strbuf())); } }) } @@ -103,7 +103,7 @@ impl Results { let mut set = f(); timed(&mut self.random_strings, || { for _ in range(0, num_keys) { - let s = rng.gen::().to_str(); + let s = rng.gen::().to_str().to_strbuf(); set.insert(s); } }) @@ -112,11 +112,11 @@ impl Results { { let mut set = f(); for i in range(0u, num_keys) { - set.insert(i.to_str()); + set.insert(i.to_str().to_strbuf()); } timed(&mut self.delete_strings, || { for i in range(0u, num_keys) { - assert!(set.remove(&i.to_str())); + assert!(set.remove(&i.to_str().to_strbuf())); } }) } @@ -175,7 +175,7 @@ fn main() { s }); results.bench_str(&mut rng, num_keys, || { - let s: HashSet<~str> = HashSet::new(); + let s: HashSet = HashSet::new(); s }); write_results("collections::HashSet", &results); @@ -189,7 +189,7 @@ fn main() { s }); results.bench_str(&mut rng, num_keys, || { - let s: TreeSet<~str> = TreeSet::new(); + let s: TreeSet = TreeSet::new(); s }); write_results("collections::TreeSet", &results); diff --git a/src/test/bench/core-std.rs b/src/test/bench/core-std.rs index 7e54198bd396..9c854a31c1e5 100644 --- a/src/test/bench/core-std.rs +++ b/src/test/bench/core-std.rs @@ -24,11 +24,13 @@ use std::vec; use std::io::File; macro_rules! bench ( - ($argv:expr, $id:ident) => (maybe_run_test($argv.as_slice(), stringify!($id).to_owned(), $id)) + ($argv:expr, $id:ident) => (maybe_run_test($argv.as_slice(), + stringify!($id).to_strbuf(), + $id)) ) fn main() { - let argv = os::args(); + let argv = os::args().move_iter().map(|x| x.to_strbuf()).collect::>(); let _tests = argv.slice(1, argv.len()); bench!(argv, shift_push); @@ -40,13 +42,13 @@ fn main() { bench!(argv, is_utf8_multibyte); } -fn maybe_run_test(argv: &[~str], name: ~str, test: ||) { +fn maybe_run_test(argv: &[StrBuf], name: StrBuf, test: ||) { let mut run_test = false; if os::getenv("RUST_BENCH").is_some() { run_test = true } else if argv.len() > 0 { - run_test = argv.iter().any(|x| x == &"all".to_owned()) || argv.iter().any(|x| x == &name) + run_test = argv.iter().any(|x| x == &"all".to_strbuf()) || argv.iter().any(|x| x == &name) } if !run_test { diff --git a/src/test/bench/msgsend-pipes-shared.rs b/src/test/bench/msgsend-pipes-shared.rs index 5a42d2e3c59f..0135688a81cb 100644 --- a/src/test/bench/msgsend-pipes-shared.rs +++ b/src/test/bench/msgsend-pipes-shared.rs @@ -52,12 +52,12 @@ fn server(requests: &Receiver, responses: &Sender) { //println!("server exiting"); } -fn run(args: &[~str]) { +fn run(args: &[StrBuf]) { let (to_parent, from_child) = channel(); let (to_child, from_parent) = channel(); - let size = from_str::(args[1]).unwrap(); - let workers = from_str::(args[2]).unwrap(); + let size = from_str::(args[1].as_slice()).unwrap(); + let workers = from_str::(args[2].as_slice()).unwrap(); let num_bytes = 100; let start = time::precise_time_s(); let mut worker_results = Vec::new(); @@ -97,13 +97,13 @@ fn run(args: &[~str]) { fn main() { let args = os::args(); let args = if os::getenv("RUST_BENCH").is_some() { - vec!("".to_owned(), "1000000".to_owned(), "10000".to_owned()) + vec!("".to_strbuf(), "1000000".to_strbuf(), "10000".to_strbuf()) } else if args.len() <= 1u { - vec!("".to_owned(), "10000".to_owned(), "4".to_owned()) + vec!("".to_strbuf(), "10000".to_strbuf(), "4".to_strbuf()) } else { - args.clone().move_iter().collect() + args.move_iter().map(|x| x.to_strbuf()).collect() }; - println!("{:?}", args); + println!("{}", args); run(args.as_slice()); } diff --git a/src/test/bench/msgsend-pipes.rs b/src/test/bench/msgsend-pipes.rs index 741cc4be4fae..20ed7efcb831 100644 --- a/src/test/bench/msgsend-pipes.rs +++ b/src/test/bench/msgsend-pipes.rs @@ -47,11 +47,11 @@ fn server(requests: &Receiver, responses: &Sender) { //println!("server exiting"); } -fn run(args: &[~str]) { +fn run(args: &[StrBuf]) { let (to_parent, from_child) = channel(); - let size = from_str::(args[1]).unwrap(); - let workers = from_str::(args[2]).unwrap(); + let size = from_str::(args[1].as_slice()).unwrap(); + let workers = from_str::(args[2].as_slice()).unwrap(); let num_bytes = 100; let start = time::precise_time_s(); let mut worker_results = Vec::new(); @@ -107,11 +107,11 @@ fn run(args: &[~str]) { fn main() { let args = os::args(); let args = if os::getenv("RUST_BENCH").is_some() { - vec!("".to_owned(), "1000000".to_owned(), "8".to_owned()) + vec!("".to_strbuf(), "1000000".to_strbuf(), "8".to_strbuf()) } else if args.len() <= 1u { - vec!("".to_owned(), "10000".to_owned(), "4".to_owned()) + vec!("".to_strbuf(), "10000".to_strbuf(), "4".to_strbuf()) } else { - args.clone().move_iter().collect() + args.clone().move_iter().map(|x| x.to_strbuf()).collect() }; println!("{:?}", args); diff --git a/src/test/bench/shootout-binarytrees.rs b/src/test/bench/shootout-binarytrees.rs index 8914c5b327ec..181d19ade3ab 100644 --- a/src/test/bench/shootout-binarytrees.rs +++ b/src/test/bench/shootout-binarytrees.rs @@ -74,10 +74,10 @@ fn main() { let b = bottom_up_tree(&arena, -i, depth); chk += item_check(a) + item_check(b); } - format!("{}\t trees of depth {}\t check: {}", - iterations * 2, depth, chk) + format_strbuf!("{}\t trees of depth {}\t check: {}", + iterations * 2, depth, chk) }) - }).collect::>>(); + }).collect::>>(); for message in messages.mut_iter() { println!("{}", *message.get_ref()); diff --git a/src/test/bench/shootout-chameneos-redux.rs b/src/test/bench/shootout-chameneos-redux.rs index 07e5b08c37cc..9db068e56c29 100644 --- a/src/test/bench/shootout-chameneos-redux.rs +++ b/src/test/bench/shootout-chameneos-redux.rs @@ -107,7 +107,7 @@ fn creature( mut color: Color, from_rendezvous: Receiver, to_rendezvous: Sender, - to_rendezvous_log: Sender<~str> + to_rendezvous_log: Sender ) { let mut creatures_met = 0; let mut evil_clones_met = 0; @@ -132,7 +132,9 @@ fn creature( } } // log creatures met and evil clones of self - let report = format!("{}{}", creatures_met, Number(evil_clones_met)); + let report = format_strbuf!("{}{}", + creatures_met, + Number(evil_clones_met)); to_rendezvous_log.send(report); } @@ -141,7 +143,7 @@ fn rendezvous(nn: uint, set: Vec) { let (to_rendezvous, from_creatures) = channel::(); // these channels will be passed to the creatures so they can talk to us - let (to_rendezvous_log, from_creatures_log) = channel::<~str>(); + let (to_rendezvous_log, from_creatures_log) = channel::(); // these channels will allow us to talk to each creature by 'name'/index let mut to_creature: Vec> = diff --git a/src/test/bench/shootout-k-nucleotide-pipes.rs b/src/test/bench/shootout-k-nucleotide-pipes.rs index e2bcc55d1398..3a337b3d191e 100644 --- a/src/test/bench/shootout-k-nucleotide-pipes.rs +++ b/src/test/bench/shootout-k-nucleotide-pipes.rs @@ -37,7 +37,7 @@ fn f64_cmp(x: f64, y: f64) -> Ordering { } // given a map, print a sorted version of it -fn sort_and_fmt(mm: &HashMap , uint>, total: uint) -> ~str { +fn sort_and_fmt(mm: &HashMap , uint>, total: uint) -> StrBuf { fn pct(xx: uint, yy: uint) -> f64 { return (xx as f64) * 100.0 / (yy as f64); } @@ -67,12 +67,12 @@ fn sort_and_fmt(mm: &HashMap , uint>, total: uint) -> ~str { .into_str(), v)); } - return buffer.into_owned(); + return buffer } // given a map, search for the frequency of a pattern -fn find(mm: &HashMap , uint>, key: ~str) -> uint { - let key = key.into_ascii().as_slice().to_lower().into_str(); +fn find(mm: &HashMap , uint>, key: StrBuf) -> uint { + let key = key.to_owned().into_ascii().as_slice().to_lower().into_str(); match mm.find_equiv(&key.as_bytes()) { option::None => { return 0u; } option::Some(&num) => { return num; } @@ -106,7 +106,7 @@ fn windows_with_carry(bb: &[u8], nn: uint, it: |window: &[u8]|) -> Vec { fn make_sequence_processor(sz: uint, from_parent: &Receiver>, - to_parent: &Sender<~str>) { + to_parent: &Sender) { let mut freqs: HashMap, uint> = HashMap::new(); let mut carry = Vec::new(); let mut total: uint = 0u; @@ -129,13 +129,13 @@ fn make_sequence_processor(sz: uint, let buffer = match sz { 1u => { sort_and_fmt(&freqs, total) } 2u => { sort_and_fmt(&freqs, total) } - 3u => { format!("{}\t{}", find(&freqs, "GGT".to_owned()), "GGT") } - 4u => { format!("{}\t{}", find(&freqs, "GGTA".to_owned()), "GGTA") } - 6u => { format!("{}\t{}", find(&freqs, "GGTATT".to_owned()), "GGTATT") } - 12u => { format!("{}\t{}", find(&freqs, "GGTATTTTAATT".to_owned()), "GGTATTTTAATT") } - 18u => { format!("{}\t{}", find(&freqs, "GGTATTTTAATTTATAGT".to_owned()), + 3u => { format_strbuf!("{}\t{}", find(&freqs, "GGT".to_strbuf()), "GGT") } + 4u => { format_strbuf!("{}\t{}", find(&freqs, "GGTA".to_strbuf()), "GGTA") } + 6u => { format_strbuf!("{}\t{}", find(&freqs, "GGTATT".to_strbuf()), "GGTATT") } + 12u => { format_strbuf!("{}\t{}", find(&freqs, "GGTATTTTAATT".to_strbuf()), "GGTATTTTAATT") } + 18u => { format_strbuf!("{}\t{}", find(&freqs, "GGTATTTTAATTTATAGT".to_strbuf()), "GGTATTTTAATTTATAGT") } - _ => { "".to_owned() } + _ => { "".to_strbuf() } }; to_parent.send(buffer); @@ -155,7 +155,7 @@ fn main() { // initialize each sequence sorter let sizes = vec!(1u,2,3,4,6,12,18); - let mut streams = Vec::from_fn(sizes.len(), |_| Some(channel::<~str>())); + let mut streams = Vec::from_fn(sizes.len(), |_| Some(channel::())); let mut from_child = Vec::new(); let to_child = sizes.iter().zip(streams.mut_iter()).map(|(sz, stream_ref)| { let sz = *sz; diff --git a/src/test/bench/shootout-meteor.rs b/src/test/bench/shootout-meteor.rs index 45f8b1b9a839..dd795b7faea8 100644 --- a/src/test/bench/shootout-meteor.rs +++ b/src/test/bench/shootout-meteor.rs @@ -184,7 +184,7 @@ fn get_id(m: u64) -> u8 { fail!("{:016x} does not have a valid identifier", m); } -// Converts a list of mask to a ~str. +// Converts a list of mask to a StrBuf. fn to_vec(raw_sol: &List) -> Vec { let mut sol = Vec::from_elem(50, '.' as u8); for &m in raw_sol.iter() { @@ -198,7 +198,7 @@ fn to_vec(raw_sol: &List) -> Vec { sol } -// Prints a solution in ~str form. +// Prints a solution in StrBuf form. fn print_sol(sol: &Vec) { for (i, c) in sol.iter().enumerate() { if (i) % 5 == 0 { println!(""); } diff --git a/src/test/bench/shootout-pfib.rs b/src/test/bench/shootout-pfib.rs index 0819b71853a4..a6e579689ed4 100644 --- a/src/test/bench/shootout-pfib.rs +++ b/src/test/bench/shootout-pfib.rs @@ -52,9 +52,10 @@ struct Config { stress: bool } -fn parse_opts(argv: Vec<~str> ) -> Config { +fn parse_opts(argv: Vec ) -> Config { let opts = vec!(getopts::optflag("", "stress", "")); + let argv = argv.iter().map(|x| x.to_str()).collect::>(); let opt_args = argv.slice(1, argv.len()); match getopts::getopts(opt_args, opts.as_slice()) { @@ -92,11 +93,11 @@ fn stress(num_tasks: int) { fn main() { let args = os::args(); let args = if os::getenv("RUST_BENCH").is_some() { - vec!("".to_owned(), "20".to_owned()) + vec!("".to_strbuf(), "20".to_strbuf()) } else if args.len() <= 1u { - vec!("".to_owned(), "8".to_owned()) + vec!("".to_strbuf(), "8".to_strbuf()) } else { - args.move_iter().collect() + args.move_iter().map(|x| x.to_strbuf()).collect() }; let opts = parse_opts(args.clone()); diff --git a/src/test/compile-fail/bad-const-type.rs b/src/test/compile-fail/bad-const-type.rs index 92643eca3c83..ab5735150fdc 100644 --- a/src/test/compile-fail/bad-const-type.rs +++ b/src/test/compile-fail/bad-const-type.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// error-pattern:expected `~str` but found `int` +// error-pattern:expected `std::strbuf::StrBuf` but found `int` -static i: ~str = 10i; -fn main() { println!("{:?}", i); } +static i: StrBuf = 10i; +fn main() { println!("{}", i); } diff --git a/src/test/compile-fail/bad-expr-path.rs b/src/test/compile-fail/bad-expr-path.rs index 6e73427f80f9..0fadbbe785d9 100644 --- a/src/test/compile-fail/bad-expr-path.rs +++ b/src/test/compile-fail/bad-expr-path.rs @@ -12,4 +12,4 @@ mod m1 {} -fn main(args: Vec<~str>) { log(debug, m1::a); } +fn main(args: Vec) { log(debug, m1::a); } diff --git a/src/test/compile-fail/bad-expr-path2.rs b/src/test/compile-fail/bad-expr-path2.rs index d2b3a5786868..84bdf40dbabe 100644 --- a/src/test/compile-fail/bad-expr-path2.rs +++ b/src/test/compile-fail/bad-expr-path2.rs @@ -14,6 +14,6 @@ mod m1 { pub mod a {} } -fn main(args: Vec<~str>) { +fn main(args: Vec) { log(debug, m1::a); } diff --git a/src/test/compile-fail/binop-bitxor-str.rs b/src/test/compile-fail/binop-bitxor-str.rs index d97628bad7a7..c0da78737ca9 100644 --- a/src/test/compile-fail/binop-bitxor-str.rs +++ b/src/test/compile-fail/binop-bitxor-str.rs @@ -8,6 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// error-pattern:`^` cannot be applied to type `~str` +// error-pattern:`^` cannot be applied to type `std::strbuf::StrBuf` -fn main() { let x = "a".to_owned() ^ "b".to_owned(); } +fn main() { let x = "a".to_strbuf() ^ "b".to_strbuf(); } diff --git a/src/test/compile-fail/borrowck-move-error-with-note.rs b/src/test/compile-fail/borrowck-move-error-with-note.rs index 72101d86960c..de77bb8144d8 100644 --- a/src/test/compile-fail/borrowck-move-error-with-note.rs +++ b/src/test/compile-fail/borrowck-move-error-with-note.rs @@ -26,15 +26,15 @@ fn blah() { } struct S { - f: ~str, - g: ~str + f: StrBuf, + g: StrBuf } impl Drop for S { fn drop(&mut self) { println!("{}", self.f); } } fn move_in_match() { - match S {f: "foo".to_owned(), g: "bar".to_owned()} { + match S {f: "foo".to_strbuf(), g: "bar".to_strbuf()} { S { //~ ERROR cannot move out of type `S`, which defines the `Drop` trait f: _s, //~ NOTE attempting to move value to here g: _t //~ NOTE and here diff --git a/src/test/compile-fail/borrowck-move-in-irrefut-pat.rs b/src/test/compile-fail/borrowck-move-in-irrefut-pat.rs index 2be5d5701352..c65f2523f9bd 100644 --- a/src/test/compile-fail/borrowck-move-in-irrefut-pat.rs +++ b/src/test/compile-fail/borrowck-move-in-irrefut-pat.rs @@ -8,9 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn with(f: |&~str|) {} +fn with(f: |&StrBuf|) {} -fn arg_item(&_x: &~str) {} +fn arg_item(&_x: &StrBuf) {} //~^ ERROR cannot move out of dereference of `&`-pointer fn arg_closure() { diff --git a/src/test/compile-fail/borrowck-move-out-of-struct-with-dtor.rs b/src/test/compile-fail/borrowck-move-out-of-struct-with-dtor.rs index e40fc4e4b236..1de48b619209 100644 --- a/src/test/compile-fail/borrowck-move-out-of-struct-with-dtor.rs +++ b/src/test/compile-fail/borrowck-move-out-of-struct-with-dtor.rs @@ -8,20 +8,20 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -struct S {f:~str} +struct S {f:StrBuf} impl Drop for S { fn drop(&mut self) { println!("{}", self.f); } } fn move_in_match() { - match S {f:"foo".to_owned()} { + match S {f:"foo".to_strbuf()} { S {f:_s} => {} //~^ ERROR cannot move out of type `S`, which defines the `Drop` trait } } fn move_in_let() { - let S {f:_s} = S {f:"foo".to_owned()}; + let S {f:_s} = S {f:"foo".to_strbuf()}; //~^ ERROR cannot move out of type `S`, which defines the `Drop` trait } diff --git a/src/test/compile-fail/borrowck-move-out-of-tuple-struct-with-dtor.rs b/src/test/compile-fail/borrowck-move-out-of-tuple-struct-with-dtor.rs index 9701283469b1..0b7939f18980 100644 --- a/src/test/compile-fail/borrowck-move-out-of-tuple-struct-with-dtor.rs +++ b/src/test/compile-fail/borrowck-move-out-of-tuple-struct-with-dtor.rs @@ -8,20 +8,20 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -struct S(~str); +struct S(StrBuf); impl Drop for S { fn drop(&mut self) { } } fn move_in_match() { - match S("foo".to_owned()) { + match S("foo".to_strbuf()) { S(_s) => {} //~^ ERROR cannot move out of type `S`, which defines the `Drop` trait } } fn move_in_let() { - let S(_s) = S("foo".to_owned()); + let S(_s) = S("foo".to_strbuf()); //~^ ERROR cannot move out of type `S`, which defines the `Drop` trait } diff --git a/src/test/compile-fail/borrowck-move-out-of-vec-tail.rs b/src/test/compile-fail/borrowck-move-out-of-vec-tail.rs index 317c30c6e19b..a30d8d44ca07 100644 --- a/src/test/compile-fail/borrowck-move-out-of-vec-tail.rs +++ b/src/test/compile-fail/borrowck-move-out-of-vec-tail.rs @@ -12,14 +12,14 @@ #[deriving(Clone)] struct Foo { - string: ~str + string: StrBuf } pub fn main() { let x = vec!( - Foo { string: "foo".to_owned() }, - Foo { string: "bar".to_owned() }, - Foo { string: "baz".to_owned() } + Foo { string: "foo".to_strbuf() }, + Foo { string: "bar".to_strbuf() }, + Foo { string: "baz".to_strbuf() } ); let x: &[Foo] = x.as_slice(); match x { diff --git a/src/test/compile-fail/break-outside-loop.rs b/src/test/compile-fail/break-outside-loop.rs index 210e3d3af800..5a5b63ba8466 100644 --- a/src/test/compile-fail/break-outside-loop.rs +++ b/src/test/compile-fail/break-outside-loop.rs @@ -9,7 +9,7 @@ // except according to those terms. struct Foo { - t: ~str + t: StrBuf } fn cond() -> bool { true } diff --git a/src/test/compile-fail/by-move-pattern-binding.rs b/src/test/compile-fail/by-move-pattern-binding.rs index 986db86a6c1e..12d9e1610a53 100644 --- a/src/test/compile-fail/by-move-pattern-binding.rs +++ b/src/test/compile-fail/by-move-pattern-binding.rs @@ -10,17 +10,17 @@ enum E { Foo, - Bar(~str) + Bar(StrBuf) } struct S { x: E } -fn f(x: ~str) {} +fn f(x: StrBuf) {} fn main() { - let s = S { x: Bar("hello".to_owned()) }; + let s = S { x: Bar("hello".to_strbuf()) }; match &s.x { &Foo => {} &Bar(identifier) => f(identifier.clone()) //~ ERROR cannot move diff --git a/src/test/compile-fail/check-static-values-constraints.rs b/src/test/compile-fail/check-static-values-constraints.rs index 6c1e759cc2fa..06317f06f262 100644 --- a/src/test/compile-fail/check-static-values-constraints.rs +++ b/src/test/compile-fail/check-static-values-constraints.rs @@ -27,7 +27,7 @@ enum SafeEnum { Variant1, Variant2(int), Variant3(WithDtor), - Variant4(~str) + Variant4(StrBuf) } // These should be ok @@ -106,8 +106,11 @@ static mut STATIC12: UnsafeStruct = UnsafeStruct; static mut STATIC13: SafeStruct = SafeStruct{field1: Variant1, field2: Variant3(WithDtor)}; //~^ ERROR mutable static items are not allowed to have destructors -static mut STATIC14: SafeStruct = SafeStruct{field1: Variant1, field2: Variant4("str".to_owned())}; +static mut STATIC14: SafeStruct = SafeStruct { //~^ ERROR mutable static items are not allowed to have destructors + field1: Variant1, + field2: Variant4("str".to_strbuf()) +}; static STATIC15: &'static [Box] = &'static [box MyOwned, box MyOwned]; //~^ ERROR static items are not allowed to have owned pointers diff --git a/src/test/compile-fail/circular_modules_main.rs b/src/test/compile-fail/circular_modules_main.rs index a1739849807c..bc9f3247db70 100644 --- a/src/test/compile-fail/circular_modules_main.rs +++ b/src/test/compile-fail/circular_modules_main.rs @@ -11,7 +11,7 @@ mod circular_modules_hello; //~ERROR: circular modules -pub fn hi_str() -> ~str { +pub fn hi_str() -> StrBuf { "Hi!".to_owned() } diff --git a/src/test/compile-fail/class-cast-to-trait.rs b/src/test/compile-fail/class-cast-to-trait.rs index c4344db027ba..b28d9dabbb93 100644 --- a/src/test/compile-fail/class-cast-to-trait.rs +++ b/src/test/compile-fail/class-cast-to-trait.rs @@ -17,7 +17,7 @@ struct cat { meows : uint, how_hungry : int, - name : ~str, + name : StrBuf, } impl cat { @@ -49,7 +49,7 @@ impl cat { } } -fn cat(in_x : uint, in_y : int, in_name: ~str) -> cat { +fn cat(in_x : uint, in_y : int, in_name: StrBuf) -> cat { cat { meows: in_x, how_hungry: in_y, @@ -58,6 +58,6 @@ fn cat(in_x : uint, in_y : int, in_name: ~str) -> cat { } fn main() { - let nyan: Box = box cat(0, 2, "nyan".to_owned()) as Box; + let nyan: Box = box cat(0, 2, "nyan".to_strbuf()) as Box; nyan.eat(); //~ ERROR does not implement any method in scope named `eat` } diff --git a/src/test/compile-fail/disallowed-deconstructing-destructing-struct-let.rs b/src/test/compile-fail/disallowed-deconstructing-destructing-struct-let.rs index 40bb63907c9f..acf825f8913f 100644 --- a/src/test/compile-fail/disallowed-deconstructing-destructing-struct-let.rs +++ b/src/test/compile-fail/disallowed-deconstructing-destructing-struct-let.rs @@ -9,7 +9,7 @@ // except according to those terms. struct X { - x: ~str, + x: StrBuf, } impl Drop for X { @@ -18,13 +18,13 @@ impl Drop for X { } } -fn unwrap(x: X) -> ~str { +fn unwrap(x: X) -> StrBuf { let X { x: y } = x; //~ ERROR cannot move out of type y } fn main() { - let x = X { x: "hello".to_owned() }; + let x = X { x: "hello".to_strbuf() }; let y = unwrap(x); println!("contents: {}", y); } diff --git a/src/test/compile-fail/disallowed-deconstructing-destructing-struct-match.rs b/src/test/compile-fail/disallowed-deconstructing-destructing-struct-match.rs index eec665b62f9d..80e624afdb87 100644 --- a/src/test/compile-fail/disallowed-deconstructing-destructing-struct-match.rs +++ b/src/test/compile-fail/disallowed-deconstructing-destructing-struct-match.rs @@ -9,7 +9,7 @@ // except according to those terms. struct X { - x: ~str, + x: StrBuf, } impl Drop for X { @@ -19,7 +19,7 @@ impl Drop for X { } fn main() { - let x = X { x: "hello".to_owned() }; + let x = X { x: "hello".to_strbuf() }; match x { X { x: y } => println!("contents: {}", y) diff --git a/src/test/compile-fail/estr-subtyping.rs b/src/test/compile-fail/estr-subtyping.rs index db86b5e092c5..b2ac06127847 100644 --- a/src/test/compile-fail/estr-subtyping.rs +++ b/src/test/compile-fail/estr-subtyping.rs @@ -8,16 +8,16 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn wants_uniq(x: ~str) { } +fn wants_uniq(x: StrBuf) { } fn wants_slice(x: &str) { } -fn has_uniq(x: ~str) { +fn has_uniq(x: StrBuf) { wants_uniq(x); - wants_slice(x); + wants_slice(x.as_slice()); } fn has_slice(x: &str) { - wants_uniq(x); //~ ERROR mismatched types: expected `~str` but found `&str` (expected box but f + wants_uniq(x); //~ ERROR mismatched types wants_slice(x); } diff --git a/src/test/compile-fail/generic-type-params-name-repr.rs b/src/test/compile-fail/generic-type-params-name-repr.rs index e3d624e9452b..39b6a276e707 100644 --- a/src/test/compile-fail/generic-type-params-name-repr.rs +++ b/src/test/compile-fail/generic-type-params-name-repr.rs @@ -28,10 +28,10 @@ fn main() { //~^ ERROR mismatched types: expected `Foo` but found `()` // Including cases where the default is using previous type params. - let _: HashMap<~str, int> = (); - //~^ ERROR mismatched types: expected `HashMap<~str,int>` but found `()` - let _: HashMap<~str, int, Hash<~str>> = (); - //~^ ERROR mismatched types: expected `HashMap<~str,int>` but found `()` + let _: HashMap = (); + //~^ ERROR mismatched types: expected `HashMap` but found `()` + let _: HashMap> = (); + //~^ ERROR mismatched types: expected `HashMap` but found `()` // But not when there's a different type in between. let _: Foo = (); diff --git a/src/test/compile-fail/import.rs b/src/test/compile-fail/import.rs index 350b07769041..654443bde24c 100644 --- a/src/test/compile-fail/import.rs +++ b/src/test/compile-fail/import.rs @@ -16,4 +16,4 @@ use zed::baz; mod zed { pub fn bar() { println!("bar"); } } -fn main(args: Vec<~str>) { bar(); } +fn main(args: Vec) { bar(); } diff --git a/src/test/compile-fail/import2.rs b/src/test/compile-fail/import2.rs index 8b282ba88418..11e757803065 100644 --- a/src/test/compile-fail/import2.rs +++ b/src/test/compile-fail/import2.rs @@ -16,4 +16,4 @@ mod baz {} mod zed { pub fn bar() { println!("bar3"); } } -fn main(args: Vec<~str>) { bar(); } +fn main(args: Vec) { bar(); } diff --git a/src/test/compile-fail/integral-indexing.rs b/src/test/compile-fail/integral-indexing.rs index ee839893e8eb..d41573b85575 100644 --- a/src/test/compile-fail/integral-indexing.rs +++ b/src/test/compile-fail/integral-indexing.rs @@ -10,17 +10,17 @@ pub fn main() { let v: Vec = vec!(0, 1, 2, 3, 4, 5); - let s: ~str = "abcdef".to_owned(); + let s: StrBuf = "abcdef".to_strbuf(); assert_eq!(v.as_slice()[3u], 3); assert_eq!(v.as_slice()[3u8], 3); //~ ERROR: mismatched types assert_eq!(v.as_slice()[3i8], 3); //~ ERROR: mismatched types assert_eq!(v.as_slice()[3u32], 3); //~ ERROR: mismatched types assert_eq!(v.as_slice()[3i32], 3); //~ ERROR: mismatched types println!("{}", v.as_slice()[3u8]); //~ ERROR: mismatched types - assert_eq!(s[3u], 'd' as u8); - assert_eq!(s[3u8], 'd' as u8); //~ ERROR: mismatched types - assert_eq!(s[3i8], 'd' as u8); //~ ERROR: mismatched types - assert_eq!(s[3u32], 'd' as u8); //~ ERROR: mismatched types - assert_eq!(s[3i32], 'd' as u8); //~ ERROR: mismatched types - println!("{}", s[3u8]); //~ ERROR: mismatched types + assert_eq!(s.as_slice()[3u], 'd' as u8); + assert_eq!(s.as_slice()[3u8], 'd' as u8); //~ ERROR: mismatched types + assert_eq!(s.as_slice()[3i8], 'd' as u8); //~ ERROR: mismatched types + assert_eq!(s.as_slice()[3u32], 'd' as u8); //~ ERROR: mismatched types + assert_eq!(s.as_slice()[3i32], 'd' as u8); //~ ERROR: mismatched types + println!("{}", s.as_slice()[3u8]); //~ ERROR: mismatched types } diff --git a/src/test/compile-fail/issue-13428.rs b/src/test/compile-fail/issue-13428.rs index 7e24d909237b..ab763a2b583c 100644 --- a/src/test/compile-fail/issue-13428.rs +++ b/src/test/compile-fail/issue-13428.rs @@ -10,16 +10,16 @@ // Regression test for #13428 -fn foo() -> ~str { //~ ERROR not all control paths return a value - format!("Hello {}", - "world") +fn foo() -> StrBuf { //~ ERROR not all control paths return a value + format_strbuf!("Hello {}", + "world") // Put the trailing semicolon on its own line to test that the // note message gets the offending semicolon exactly ; //~ NOTE consider removing this semicolon } -fn bar() -> ~str { //~ ERROR not all control paths return a value - "foobar".to_owned() +fn bar() -> StrBuf { //~ ERROR not all control paths return a value + "foobar".to_strbuf() ; //~ NOTE consider removing this semicolon } diff --git a/src/test/compile-fail/issue-2063.rs b/src/test/compile-fail/issue-2063.rs index 4a6219aafd08..fcbe8f7b5636 100644 --- a/src/test/compile-fail/issue-2063.rs +++ b/src/test/compile-fail/issue-2063.rs @@ -16,14 +16,14 @@ struct t(Box); //~ ERROR this type cannot be instantiated trait to_str_2 { - fn my_to_str() -> ~str; + fn my_to_str() -> StrBuf; } // I use an impl here because it will cause // the compiler to attempt autoderef and then // try to resolve the method. impl to_str_2 for t { - fn my_to_str() -> ~str { "t".to_owned() } + fn my_to_str() -> StrBuf { "t".to_strbuf() } } fn new_t(x: t) { diff --git a/src/test/compile-fail/issue-3099.rs b/src/test/compile-fail/issue-3099.rs index 85989c4a40a6..365ee54645f2 100644 --- a/src/test/compile-fail/issue-3099.rs +++ b/src/test/compile-fail/issue-3099.rs @@ -8,11 +8,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn a(x: ~str) -> ~str { +fn a(x: StrBuf) -> StrBuf { format!("First function with {}", x) } -fn a(x: ~str, y: ~str) -> ~str { //~ ERROR duplicate definition of value `a` +fn a(x: StrBuf, y: StrBuf) -> StrBuf { //~ ERROR duplicate definition of value `a` format!("Second function with {} and {}", x, y) } diff --git a/src/test/compile-fail/issue-3601.rs b/src/test/compile-fail/issue-3601.rs index 6ca4e22576ec..15bcc53b8cec 100644 --- a/src/test/compile-fail/issue-3601.rs +++ b/src/test/compile-fail/issue-3601.rs @@ -10,7 +10,7 @@ struct HTMLImageData { - image: Option<~str> + image: Option } struct ElementData { diff --git a/src/test/compile-fail/issue-3973.rs b/src/test/compile-fail/issue-3973.rs index c44336aeaf52..fdf9a3969635 100644 --- a/src/test/compile-fail/issue-3973.rs +++ b/src/test/compile-fail/issue-3973.rs @@ -22,7 +22,7 @@ impl ToStr for Point { //~ ERROR implements a method not defined in the trait Point { x: x, y: y } } - fn to_str(&self) -> ~str { + fn to_str(&self) -> StrBuf { format!("({}, {})", self.x, self.y) } } diff --git a/src/test/compile-fail/issue-5543.rs b/src/test/compile-fail/issue-5543.rs index f143d74d8c23..ebc82ab361d5 100644 --- a/src/test/compile-fail/issue-5543.rs +++ b/src/test/compile-fail/issue-5543.rs @@ -13,7 +13,7 @@ use std::io::ReaderUtil; use std::io::Reader; -fn bar(r:@ReaderUtil) -> ~str { r.read_line() } +fn bar(r:@ReaderUtil) -> StrBuf { r.read_line() } fn main() { let r : @Reader = io::stdin(); diff --git a/src/test/compile-fail/issue-6458-4.rs b/src/test/compile-fail/issue-6458-4.rs index 1d792dba0d87..b12d2be612ec 100644 --- a/src/test/compile-fail/issue-6458-4.rs +++ b/src/test/compile-fail/issue-6458-4.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn foo(b: bool) -> Result { +fn foo(b: bool) -> Result { Err("bar".to_owned()); //~^ ERROR: cannot determine a type for this expression: unconstrained type } diff --git a/src/test/compile-fail/issue-7573.rs b/src/test/compile-fail/issue-7573.rs index e39b2d9309be..d79bc942118d 100644 --- a/src/test/compile-fail/issue-7573.rs +++ b/src/test/compile-fail/issue-7573.rs @@ -10,15 +10,15 @@ pub struct CrateId { - local_path: ~str, - junk: ~str + local_path: StrBuf, + junk: StrBuf } impl CrateId { fn new(s: &str) -> CrateId { CrateId { - local_path: s.to_owned(), - junk: "wutevs".to_owned() + local_path: s.to_strbuf(), + junk: "wutevs".to_strbuf() } } } diff --git a/src/test/compile-fail/issue-7575.rs b/src/test/compile-fail/issue-7575.rs index 5b03e6fc2265..f23e398596f0 100644 --- a/src/test/compile-fail/issue-7575.rs +++ b/src/test/compile-fail/issue-7575.rs @@ -51,7 +51,7 @@ trait ManyImplTrait { } } -impl ManyImplTrait for ~str { +impl ManyImplTrait for StrBuf { fn is_str() -> bool { true } diff --git a/src/test/compile-fail/kindck-copy.rs b/src/test/compile-fail/kindck-copy.rs index 694b0f1dbe27..c5c14005c70a 100644 --- a/src/test/compile-fail/kindck-copy.rs +++ b/src/test/compile-fail/kindck-copy.rs @@ -39,7 +39,7 @@ fn test<'a,T,U:Copy>(_: &'a int) { // ~ pointers are not ok assert_copy::>(); //~ ERROR does not fulfill - assert_copy::<~str>(); //~ ERROR does not fulfill + assert_copy::(); //~ ERROR does not fulfill assert_copy:: >(); //~ ERROR does not fulfill assert_copy::>(); //~ ERROR does not fulfill diff --git a/src/test/compile-fail/kindck-send.rs b/src/test/compile-fail/kindck-send.rs index 518e97515e79..c2c35e05edea 100644 --- a/src/test/compile-fail/kindck-send.rs +++ b/src/test/compile-fail/kindck-send.rs @@ -30,7 +30,7 @@ fn test<'a,T,U:Send>(_: &'a int) { // boxes are ok assert_send::>(); - assert_send::<~str>(); + assert_send::(); assert_send:: >(); // but not if they own a bad thing diff --git a/src/test/compile-fail/lint-unused-unsafe.rs b/src/test/compile-fail/lint-unused-unsafe.rs index ecea33cbe8ef..c33719a2fc19 100644 --- a/src/test/compile-fail/lint-unused-unsafe.rs +++ b/src/test/compile-fail/lint-unused-unsafe.rs @@ -51,7 +51,7 @@ fn good2() { sure that when purity is inherited that the source of the unsafe-ness is tracked correctly */ unsafe { - unsafe fn what() -> Vec<~str> { fail!() } + unsafe fn what() -> Vec { fail!() } callback(|| { what(); diff --git a/src/test/compile-fail/lub-if.rs b/src/test/compile-fail/lub-if.rs index 6b5055cb1a2c..fe64551a4b53 100644 --- a/src/test/compile-fail/lub-if.rs +++ b/src/test/compile-fail/lub-if.rs @@ -12,36 +12,36 @@ // of the various arms, particularly in the case where regions are // involved. -pub fn opt_str0<'a>(maybestr: &'a Option<~str>) -> &'a str { +pub fn opt_str0<'a>(maybestr: &'a Option) -> &'a str { if maybestr.is_none() { "(none)" } else { - let s: &'a str = *maybestr.get_ref(); + let s: &'a str = maybestr.get_ref().as_slice(); s } } -pub fn opt_str1<'a>(maybestr: &'a Option<~str>) -> &'a str { +pub fn opt_str1<'a>(maybestr: &'a Option) -> &'a str { if maybestr.is_some() { - let s: &'a str = *maybestr.get_ref(); + let s: &'a str = maybestr.get_ref().as_slice(); s } else { "(none)" } } -pub fn opt_str2<'a>(maybestr: &'a Option<~str>) -> &'static str { +pub fn opt_str2<'a>(maybestr: &'a Option) -> &'static str { if maybestr.is_none() { //~ ERROR mismatched types "(none)" } else { - let s: &'a str = *maybestr.get_ref(); + let s: &'a str = maybestr.get_ref().as_slice(); s } } -pub fn opt_str3<'a>(maybestr: &'a Option<~str>) -> &'static str { +pub fn opt_str3<'a>(maybestr: &'a Option) -> &'static str { if maybestr.is_some() { //~ ERROR mismatched types - let s: &'a str = *maybestr.get_ref(); + let s: &'a str = maybestr.get_ref().as_slice(); s } else { "(none)" diff --git a/src/test/compile-fail/lub-match.rs b/src/test/compile-fail/lub-match.rs index 37b9cc55dc82..932107b78781 100644 --- a/src/test/compile-fail/lub-match.rs +++ b/src/test/compile-fail/lub-match.rs @@ -12,40 +12,40 @@ // of the various arms, particularly in the case where regions are // involved. -pub fn opt_str0<'a>(maybestr: &'a Option<~str>) -> &'a str { +pub fn opt_str0<'a>(maybestr: &'a Option) -> &'a str { match *maybestr { Some(ref s) => { - let s: &'a str = *s; + let s: &'a str = s.as_slice(); s } None => "(none)", } } -pub fn opt_str1<'a>(maybestr: &'a Option<~str>) -> &'a str { +pub fn opt_str1<'a>(maybestr: &'a Option) -> &'a str { match *maybestr { None => "(none)", Some(ref s) => { - let s: &'a str = *s; + let s: &'a str = s.as_slice(); s } } } -pub fn opt_str2<'a>(maybestr: &'a Option<~str>) -> &'static str { +pub fn opt_str2<'a>(maybestr: &'a Option) -> &'static str { match *maybestr { //~ ERROR mismatched types None => "(none)", Some(ref s) => { - let s: &'a str = *s; + let s: &'a str = s.as_slice(); s } } } -pub fn opt_str3<'a>(maybestr: &'a Option<~str>) -> &'static str { +pub fn opt_str3<'a>(maybestr: &'a Option) -> &'static str { match *maybestr { //~ ERROR mismatched types Some(ref s) => { - let s: &'a str = *s; + let s: &'a str = s.as_slice(); s } None => "(none)", diff --git a/src/test/compile-fail/map-types.rs b/src/test/compile-fail/map-types.rs index b59011b58802..aa8cb84481f1 100644 --- a/src/test/compile-fail/map-types.rs +++ b/src/test/compile-fail/map-types.rs @@ -15,9 +15,9 @@ use collections::HashMap; // Test that trait types printed in error msgs include the type arguments. fn main() { - let x: Box> = box HashMap::new(); - let x: Box> = x; - let y: Box> = box x; - //~^ ERROR failed to find an implementation of trait core::container::Map - // for ~core::container::Map<~str,~str>:Send + let x: Box> = box HashMap::new(); + let x: Box> = x; + let y: Box> = box x; + //~^ ERROR failed to find an implementation of trait core::container::Map + // for ~core::container::Map:Send } diff --git a/src/test/compile-fail/match-vec-mismatch.rs b/src/test/compile-fail/match-vec-mismatch.rs index 17c93f596e9c..56d3d76bf7c1 100644 --- a/src/test/compile-fail/match-vec-mismatch.rs +++ b/src/test/compile-fail/match-vec-mismatch.rs @@ -9,8 +9,8 @@ // except according to those terms. fn main() { - match "foo".to_owned() { - ['f', 'o', ..] => { } //~ ERROR mismatched types: expected `~str` but found a vector pattern + match "foo".to_strbuf() { + ['f', 'o', ..] => {} //~ ERROR mismatched types _ => { } } } diff --git a/src/test/compile-fail/match-vec-unreachable.rs b/src/test/compile-fail/match-vec-unreachable.rs index 2e3b5e399f19..128c25889d87 100644 --- a/src/test/compile-fail/match-vec-unreachable.rs +++ b/src/test/compile-fail/match-vec-unreachable.rs @@ -18,8 +18,10 @@ fn main() { _ => () } - let x: Vec<~str> = vec!("foo".to_owned(), "bar".to_owned(), "baz".to_owned()); - let x: &[~str] = x.as_slice(); + let x: Vec = vec!["foo".to_strbuf(), + "bar".to_strbuf(), + "baz".to_strbuf()]; + let x: &[StrBuf] = x.as_slice(); match x { [a, _, _, ..] => { println!("{}", a); } [_, _, _, _, _] => { } //~ ERROR unreachable pattern diff --git a/src/test/compile-fail/minus-string.rs b/src/test/compile-fail/minus-string.rs index 636debc77e01..b194b2d83316 100644 --- a/src/test/compile-fail/minus-string.rs +++ b/src/test/compile-fail/minus-string.rs @@ -8,6 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// error-pattern:cannot apply unary operator `-` to type `~str` +// error-pattern:cannot apply unary operator `-` to type `std::strbuf::StrBuf` -fn main() { -"foo".to_owned(); } +fn main() { -"foo".to_strbuf(); } diff --git a/src/test/compile-fail/moves-based-on-type-access-to-field.rs b/src/test/compile-fail/moves-based-on-type-access-to-field.rs index dc2cd22e632e..fcad6469bccf 100644 --- a/src/test/compile-fail/moves-based-on-type-access-to-field.rs +++ b/src/test/compile-fail/moves-based-on-type-access-to-field.rs @@ -11,18 +11,18 @@ // Tests that if you move from `x.f` or `x[0]`, `x` is inaccessible. // Also tests that we give a more specific error message. -struct Foo { f: ~str, y: int } -fn consume(_s: ~str) {} +struct Foo { f: StrBuf, y: int } +fn consume(_s: StrBuf) {} fn touch(_a: &A) {} fn f10() { - let x = Foo { f: "hi".to_owned(), y: 3 }; + let x = Foo { f: "hi".to_strbuf(), y: 3 }; consume(x.f); touch(&x.y); //~ ERROR use of partially moved value: `x` } fn f20() { - let x = vec!("hi".to_owned()); + let x = vec!("hi".to_strbuf()); consume(x.move_iter().next().unwrap()); touch(x.get(0)); //~ ERROR use of moved value: `x` } diff --git a/src/test/compile-fail/moves-based-on-type-exprs.rs b/src/test/compile-fail/moves-based-on-type-exprs.rs index ea96d87855e7..29b4dc573e3a 100644 --- a/src/test/compile-fail/moves-based-on-type-exprs.rs +++ b/src/test/compile-fail/moves-based-on-type-exprs.rs @@ -14,17 +14,17 @@ #![feature(managed_boxes)] struct Foo { f: A } -fn guard(_s: ~str) -> bool {fail!()} +fn guard(_s: StrBuf) -> bool {fail!()} fn touch(_a: &A) {} fn f10() { - let x = "hi".to_owned(); + let x = "hi".to_strbuf(); let _y = Foo { f:x }; touch(&x); //~ ERROR use of moved value: `x` } fn f20() { - let x = "hi".to_owned(); + let x = "hi".to_strbuf(); let _y = (x, 3); touch(&x); //~ ERROR use of moved value: `x` } @@ -36,8 +36,8 @@ fn f21() { } fn f30(cond: bool) { - let x = "hi".to_owned(); - let y = "ho".to_owned(); + let x = "hi".to_strbuf(); + let y = "ho".to_strbuf(); let _y = if cond { x } else { @@ -48,8 +48,8 @@ fn f30(cond: bool) { } fn f40(cond: bool) { - let x = "hi".to_owned(); - let y = "ho".to_owned(); + let x = "hi".to_strbuf(); + let y = "ho".to_strbuf(); let _y = match cond { true => x, false => y @@ -59,8 +59,8 @@ fn f40(cond: bool) { } fn f50(cond: bool) { - let x = "hi".to_owned(); - let y = "ho".to_owned(); + let x = "hi".to_strbuf(); + let y = "ho".to_strbuf(); let _y = match cond { _ if guard(x) => 10, true => 10, @@ -71,31 +71,31 @@ fn f50(cond: bool) { } fn f70() { - let x = "hi".to_owned(); + let x = "hi".to_strbuf(); let _y = [x]; touch(&x); //~ ERROR use of moved value: `x` } fn f80() { - let x = "hi".to_owned(); + let x = "hi".to_strbuf(); let _y = vec!(x); touch(&x); //~ ERROR use of moved value: `x` } fn f100() { - let x = vec!("hi".to_owned()); + let x = vec!("hi".to_strbuf()); let _y = x.move_iter().next().unwrap(); touch(&x); //~ ERROR use of moved value: `x` } fn f110() { - let x = vec!("hi".to_owned()); + let x = vec!("hi".to_strbuf()); let _y = [x.move_iter().next().unwrap(), ..1]; touch(&x); //~ ERROR use of moved value: `x` } fn f120() { - let mut x = vec!("hi".to_owned(), "ho".to_owned()); + let mut x = vec!("hi".to_strbuf(), "ho".to_strbuf()); x.as_mut_slice().swap(0, 1); touch(x.get(0)); touch(x.get(1)); diff --git a/src/test/compile-fail/moves-based-on-type-match-bindings.rs b/src/test/compile-fail/moves-based-on-type-match-bindings.rs index 59918b51e4c9..83b7658a4738 100644 --- a/src/test/compile-fail/moves-based-on-type-match-bindings.rs +++ b/src/test/compile-fail/moves-based-on-type-match-bindings.rs @@ -13,7 +13,7 @@ // terms of the binding, not the discriminant. struct Foo { f: A } -fn guard(_s: ~str) -> bool {fail!()} +fn guard(_s: StrBuf) -> bool {fail!()} fn touch(_a: &A) {} fn f10() { diff --git a/src/test/compile-fail/multitrait.rs b/src/test/compile-fail/multitrait.rs index a57e7ebe6a04..a0c007a2627e 100644 --- a/src/test/compile-fail/multitrait.rs +++ b/src/test/compile-fail/multitrait.rs @@ -14,5 +14,5 @@ struct S { impl Cmp, ToStr for S { //~ ERROR: expected `{` but found `,` fn eq(&&other: S) { false } - fn to_str(&self) -> ~str { "hi".to_owned() } + fn to_str(&self) -> StrBuf { "hi".to_owned() } } diff --git a/src/test/compile-fail/unsendable-class.rs b/src/test/compile-fail/unsendable-class.rs index a30337aba68c..a0e3a15dfa52 100644 --- a/src/test/compile-fail/unsendable-class.rs +++ b/src/test/compile-fail/unsendable-class.rs @@ -15,10 +15,10 @@ struct foo { i: int, - j: @~str, + j: @StrBuf, } -fn foo(i:int, j: @~str) -> foo { +fn foo(i:int, j: @StrBuf) -> foo { foo { i: i, j: j @@ -26,7 +26,7 @@ fn foo(i:int, j: @~str) -> foo { } fn main() { - let cat = "kitty".to_owned(); + let cat = "kitty".to_strbuf(); let (tx, _) = channel(); //~ ERROR does not fulfill `Send` tx.send(foo(42, @(cat))); //~ ERROR does not fulfill `Send` } diff --git a/src/test/debuginfo/issue11600.rs b/src/test/debuginfo/issue11600.rs index 426a40bf8bda..915ccab77005 100644 --- a/src/test/debuginfo/issue11600.rs +++ b/src/test/debuginfo/issue11600.rs @@ -13,7 +13,7 @@ // ignore-test fn main() { - let args : ~[~str] = ::std::os::args(); + let args : ~[StrBuf] = ::std::os::args(); ::std::io::println(args[0]); } @@ -25,6 +25,6 @@ fn main() { // compile-flags:-g // gdb-command:list // gdb-check:1[...]fn main() { -// gdb-check:2[...]let args : ~[~str] = ::std::os::args(); +// gdb-check:2[...]let args : ~[StrBuf] = ::std::os::args(); // gdb-check:3[...]::std::io::println(args[0]); // gdb-check:4[...]} diff --git a/src/test/pretty/closure-reform-pretty.rs b/src/test/pretty/closure-reform-pretty.rs index a9d0d1f67d5f..d18627c1ba18 100644 --- a/src/test/pretty/closure-reform-pretty.rs +++ b/src/test/pretty/closure-reform-pretty.rs @@ -13,7 +13,7 @@ // pp-exact -fn call_it(f: proc(~str) -> ~str) { } +fn call_it(f: proc(StrBuf) -> StrBuf) { } fn call_this(f: |&str|: Send) { } diff --git a/src/test/run-fail/binop-fail-2.rs b/src/test/run-fail/binop-fail-2.rs index 1186c5008f73..680481ad491b 100644 --- a/src/test/run-fail/binop-fail-2.rs +++ b/src/test/run-fail/binop-fail-2.rs @@ -9,5 +9,5 @@ // except according to those terms. // error-pattern:quux -fn my_err(s: ~str) -> ! { println!("{}", s); fail!("quux"); } -fn main() { 3u == my_err("bye".to_owned()); } +fn my_err(s: StrBuf) -> ! { println!("{}", s); fail!("quux"); } +fn main() { 3u == my_err("bye".to_strbuf()); } diff --git a/src/test/run-fail/binop-fail.rs b/src/test/run-fail/binop-fail.rs index 1186c5008f73..680481ad491b 100644 --- a/src/test/run-fail/binop-fail.rs +++ b/src/test/run-fail/binop-fail.rs @@ -9,5 +9,5 @@ // except according to those terms. // error-pattern:quux -fn my_err(s: ~str) -> ! { println!("{}", s); fail!("quux"); } -fn main() { 3u == my_err("bye".to_owned()); } +fn my_err(s: StrBuf) -> ! { println!("{}", s); fail!("quux"); } +fn main() { 3u == my_err("bye".to_strbuf()); } diff --git a/src/test/run-fail/fmt-fail.rs b/src/test/run-fail/fmt-fail.rs index 9c7979efb6c0..37955561c08b 100644 --- a/src/test/run-fail/fmt-fail.rs +++ b/src/test/run-fail/fmt-fail.rs @@ -10,4 +10,7 @@ // error-pattern:meh -fn main() { let str_var: ~str = "meh".to_owned(); fail!("{}", str_var); } +fn main() { + let str_var: StrBuf = "meh".to_strbuf(); + fail!("{}", str_var); +} diff --git a/src/test/run-fail/if-cond-bot.rs b/src/test/run-fail/if-cond-bot.rs index f300a1fa7158..ef8a38df1781 100644 --- a/src/test/run-fail/if-cond-bot.rs +++ b/src/test/run-fail/if-cond-bot.rs @@ -9,5 +9,5 @@ // except according to those terms. // error-pattern:quux -fn my_err(s: ~str) -> ! { println!("{}", s); fail!("quux"); } -fn main() { if my_err("bye".to_owned()) { } } +fn my_err(s: StrBuf) -> ! { println!("{}", s); fail!("quux"); } +fn main() { if my_err("bye".to_strbuf()) { } } diff --git a/src/test/run-fail/match-bot-fail.rs b/src/test/run-fail/match-bot-fail.rs index 9728c84b9005..d75466a1738b 100644 --- a/src/test/run-fail/match-bot-fail.rs +++ b/src/test/run-fail/match-bot-fail.rs @@ -13,7 +13,7 @@ #![allow(unreachable_code)] #![allow(unused_variable)] -fn foo(s: ~str) { } +fn foo(s: StrBuf) { } fn main() { let i = diff --git a/src/test/run-fail/result-get-fail.rs b/src/test/run-fail/result-get-fail.rs index 0a3746e44651..613957980de4 100644 --- a/src/test/run-fail/result-get-fail.rs +++ b/src/test/run-fail/result-get-fail.rs @@ -13,5 +13,5 @@ use std::result; fn main() { - println!("{:?}", result::Err::("kitty".to_owned()).unwrap()); + println!("{:?}", result::Err::("kitty".to_strbuf()).unwrap()); } diff --git a/src/test/run-fail/rhs-type.rs b/src/test/run-fail/rhs-type.rs index 584be2d89b75..d224393b2eae 100644 --- a/src/test/run-fail/rhs-type.rs +++ b/src/test/run-fail/rhs-type.rs @@ -15,7 +15,7 @@ #![allow(unreachable_code)] #![allow(unused_variable)] -struct T { t: ~str } +struct T { t: StrBuf } fn main() { let pth = fail!("bye"); diff --git a/src/test/run-fail/str-overrun.rs b/src/test/run-fail/str-overrun.rs index 9f7b03ac2ea3..879a14896d62 100644 --- a/src/test/run-fail/str-overrun.rs +++ b/src/test/run-fail/str-overrun.rs @@ -11,8 +11,8 @@ // error-pattern:index out of bounds: the len is 5 but the index is 5 fn main() { - let s: ~str = "hello".to_owned(); + let s: StrBuf = "hello".to_strbuf(); // Bounds-check failure. - assert_eq!(s[5], 0x0 as u8); + assert_eq!(s.as_slice()[5], 0x0 as u8); } diff --git a/src/test/run-fail/unwind-lambda.rs b/src/test/run-fail/unwind-lambda.rs index ddaddcec3900..d3be456f3428 100644 --- a/src/test/run-fail/unwind-lambda.rs +++ b/src/test/run-fail/unwind-lambda.rs @@ -13,17 +13,17 @@ // error-pattern:fail fn main() { - let cheese = "roquefort".to_owned(); - let carrots = @"crunchy".to_owned(); + let cheese = "roquefort".to_strbuf(); + let carrots = @"crunchy".to_strbuf(); - let result: |@~str, |~str||: 'static = (|tasties, macerate| { + let result: |@StrBuf, |StrBuf||: 'static = (|tasties, macerate| { macerate((*tasties).clone()); }); result(carrots, |food| { - let mush = food + cheese; + let mush = format_strbuf!("{}{}", food, cheese); let cheese = cheese.clone(); let f: || = || { - let _chew = mush + cheese; + let _chew = format_strbuf!("{}{}", mush, cheese); fail!("so yummy") }; f(); diff --git a/src/test/run-make/unicode-input/span_length.rs b/src/test/run-make/unicode-input/span_length.rs index 13f141008b79..d56149752155 100644 --- a/src/test/run-make/unicode-input/span_length.rs +++ b/src/test/run-make/unicode-input/span_length.rs @@ -48,7 +48,7 @@ fn main() { let _ = write!(&mut File::create(&main_file).unwrap(), r"\#![feature(non_ascii_idents)] fn main() \{ {} \}", // random string of length n - range(0, n).map(|_| random_char()).collect::<~str>()); + range(0, n).map(|_| random_char()).collect::()); } // rustc is passed to us with --out-dir and -L etc., so we diff --git a/src/test/run-pass-fulldeps/qquote.rs b/src/test/run-pass-fulldeps/qquote.rs index 3b3e4066e0cc..4b8aed0a1873 100644 --- a/src/test/run-pass-fulldeps/qquote.rs +++ b/src/test/run-pass-fulldeps/qquote.rs @@ -75,7 +75,7 @@ fn main() { } fn check_pp(cx: fake_ext_ctxt, - expr: T, f: |pprust::ps, T|, expect: ~str) { + expr: T, f: |pprust::ps, T|, expect: StrBuf) { let s = io::with_str_writer(|wr| { let pp = pprust::rust_printer(wr, cx.parse_sess().interner); f(pp, expr); diff --git a/src/test/run-pass/alias-uninit-value.rs b/src/test/run-pass/alias-uninit-value.rs index ab395466afcf..a78622a37a2f 100644 --- a/src/test/run-pass/alias-uninit-value.rs +++ b/src/test/run-pass/alias-uninit-value.rs @@ -14,10 +14,10 @@ enum sty { ty_nil, } -struct RawT {struct_: sty, cname: Option<~str>, hash: uint} +struct RawT {struct_: sty, cname: Option, hash: uint} -fn mk_raw_ty(st: sty, cname: Option<~str>) -> RawT { +fn mk_raw_ty(st: sty, cname: Option) -> RawT { return RawT {struct_: st, cname: cname, hash: 0u}; } -pub fn main() { mk_raw_ty(ty_nil, None::<~str>); } +pub fn main() { mk_raw_ty(ty_nil, None::); } diff --git a/src/test/run-pass/autobind.rs b/src/test/run-pass/autobind.rs index 5dad14c7d99b..445abf4ca495 100644 --- a/src/test/run-pass/autobind.rs +++ b/src/test/run-pass/autobind.rs @@ -15,6 +15,7 @@ fn g(act: |Vec | -> int) -> int { return act(vec!(1, 2, 3)); } pub fn main() { assert_eq!(g(f), 1); - let f1: |Vec<~str> | -> ~str = f; - assert_eq!(f1(vec!("x".to_owned(), "y".to_owned(), "z".to_owned())), "x".to_owned()); + let f1: |Vec| -> StrBuf = f; + assert_eq!(f1(vec!["x".to_strbuf(), "y".to_strbuf(), "z".to_strbuf()]), + "x".to_strbuf()); } diff --git a/src/test/run-pass/autoref-intermediate-types-issue-3585.rs b/src/test/run-pass/autoref-intermediate-types-issue-3585.rs index ca11fb355c00..778704a4b96e 100644 --- a/src/test/run-pass/autoref-intermediate-types-issue-3585.rs +++ b/src/test/run-pass/autoref-intermediate-types-issue-3585.rs @@ -11,22 +11,22 @@ #![feature(managed_boxes)] trait Foo { - fn foo(&self) -> ~str; + fn foo(&self) -> StrBuf; } impl Foo for @T { - fn foo(&self) -> ~str { - format!("@{}", (**self).foo()) + fn foo(&self) -> StrBuf { + format_strbuf!("@{}", (**self).foo()) } } impl Foo for uint { - fn foo(&self) -> ~str { - format!("{}", *self) + fn foo(&self) -> StrBuf { + format_strbuf!("{}", *self) } } pub fn main() { let x = @3u; - assert_eq!(x.foo(), "@3".to_owned()); + assert_eq!(x.foo(), "@3".to_strbuf()); } diff --git a/src/test/run-pass/backtrace.rs b/src/test/run-pass/backtrace.rs index 989453d8570d..1a1814414c63 100644 --- a/src/test/run-pass/backtrace.rs +++ b/src/test/run-pass/backtrace.rs @@ -36,14 +36,21 @@ fn double() { } fn runtest(me: &str) { - let mut env = os::env().move_iter().collect::>(); - match env.iter().position(|&(ref s, _)| "RUST_BACKTRACE" == *s) { + let mut env = os::env().move_iter() + .map(|(ref k, ref v)| { + (k.to_strbuf(), v.to_strbuf()) + }).collect::>(); + match env.iter() + .position(|&(ref s, _)| "RUST_BACKTRACE" == s.as_slice()) { Some(i) => { env.remove(i); } None => {} } - env.push(("RUST_BACKTRACE".to_owned(), "1".to_owned())); + env.push(("RUST_BACKTRACE".to_strbuf(), "1".to_strbuf())); // Make sure that the stack trace is printed + let env = env.iter() + .map(|&(ref k, ref v)| (k.to_owned(), v.to_owned())) + .collect::>(); let mut p = Process::configure(ProcessConfig { program: me, args: ["fail".to_owned()], diff --git a/src/test/run-pass/block-explicit-types.rs b/src/test/run-pass/block-explicit-types.rs index 8df2679aa53d..f60510dc802f 100644 --- a/src/test/run-pass/block-explicit-types.rs +++ b/src/test/run-pass/block-explicit-types.rs @@ -9,6 +9,6 @@ // except according to those terms. pub fn main() { - fn as_buf(s: ~str, f: |~str| -> T) -> T { f(s) } - as_buf("foo".to_owned(), |foo: ~str| -> () println!("{}", foo) ); + fn as_buf(s: StrBuf, f: |StrBuf| -> T) -> T { f(s) } + as_buf("foo".to_strbuf(), |foo: StrBuf| -> () println!("{}", foo) ); } diff --git a/src/test/run-pass/borrowed-ptr-pattern-2.rs b/src/test/run-pass/borrowed-ptr-pattern-2.rs index c961f59f9814..c80246d27e68 100644 --- a/src/test/run-pass/borrowed-ptr-pattern-2.rs +++ b/src/test/run-pass/borrowed-ptr-pattern-2.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn foo(s: &~str) -> bool { +fn foo(s: &StrBuf) -> bool { match s.as_slice() { "kitty" => true, _ => false @@ -16,6 +16,6 @@ fn foo(s: &~str) -> bool { } pub fn main() { - assert!(foo(&"kitty".to_owned())); - assert!(!foo(&"gata".to_owned())); + assert!(foo(&"kitty".to_strbuf())); + assert!(!foo(&"gata".to_strbuf())); } diff --git a/src/test/run-pass/bug-7183-generics.rs b/src/test/run-pass/bug-7183-generics.rs index 86fde76fb75f..5f536026ea62 100644 --- a/src/test/run-pass/bug-7183-generics.rs +++ b/src/test/run-pass/bug-7183-generics.rs @@ -9,35 +9,36 @@ // except according to those terms. trait Speak { - fn say(&self, s:&str) -> ~str; - fn hi(&self) -> ~str { hello(self) } + fn say(&self, s:&str) -> StrBuf; + fn hi(&self) -> StrBuf { hello(self) } } -fn hello(s:&S) -> ~str{ +fn hello(s:&S) -> StrBuf{ s.say("hello") } impl Speak for int { - fn say(&self, s:&str) -> ~str { - format!("{}: {}", s, *self) + fn say(&self, s:&str) -> StrBuf { + format_strbuf!("{}: {}", s, *self) } } impl Speak for Option { - fn say(&self, s:&str) -> ~str { + fn say(&self, s:&str) -> StrBuf { match *self { - None => format!("{} - none", s), - Some(ref x) => { "something!".to_owned() + x.say(s) } + None => format_strbuf!("{} - none", s), + Some(ref x) => { format_strbuf!("something!{}", x.say(s)) } } } } pub fn main() { - assert_eq!(3.hi(), "hello: 3".to_owned()); - assert_eq!(Some(Some(3)).hi(), "something!something!hello: 3".to_owned()); - assert_eq!(None::.hi(), "hello - none".to_owned()); + assert_eq!(3.hi(), "hello: 3".to_strbuf()); + assert_eq!(Some(Some(3)).hi(), + "something!something!hello: 3".to_strbuf()); + assert_eq!(None::.hi(), "hello - none".to_strbuf()); - assert_eq!(Some(None::).hi(), "something!hello - none".to_owned()); - assert_eq!(Some(3).hi(), "something!hello: 3".to_owned()); + assert_eq!(Some(None::).hi(), "something!hello - none".to_strbuf()); + assert_eq!(Some(3).hi(), "something!hello: 3".to_strbuf()); } diff --git a/src/test/run-pass/c-stack-returning-int64.rs b/src/test/run-pass/c-stack-returning-int64.rs index 0b38c7fa1ddf..501d36886a48 100644 --- a/src/test/run-pass/c-stack-returning-int64.rs +++ b/src/test/run-pass/c-stack-returning-int64.rs @@ -21,15 +21,16 @@ mod mlibc { } } -fn atol(s: ~str) -> int { - s.with_c_str(|x| unsafe { mlibc::atol(x) as int }) +fn atol(s: StrBuf) -> int { + s.as_slice().with_c_str(|x| unsafe { mlibc::atol(x) as int }) } -fn atoll(s: ~str) -> i64 { - s.with_c_str(|x| unsafe { mlibc::atoll(x) as i64 }) +fn atoll(s: StrBuf) -> i64 { + s.as_slice().with_c_str(|x| unsafe { mlibc::atoll(x) as i64 }) } pub fn main() { - assert_eq!(atol("1024".to_owned()) * 10, atol("10240".to_owned())); - assert!((atoll("11111111111111111".to_owned()) * 10) == atoll("111111111111111110".to_owned())); + assert_eq!(atol("1024".to_strbuf()) * 10, atol("10240".to_strbuf())); + assert!((atoll("11111111111111111".to_strbuf()) * 10) == + atoll("111111111111111110".to_strbuf())); } diff --git a/src/test/run-pass/child-outlives-parent.rs b/src/test/run-pass/child-outlives-parent.rs index d32eb03e1010..c85b4b06387b 100644 --- a/src/test/run-pass/child-outlives-parent.rs +++ b/src/test/run-pass/child-outlives-parent.rs @@ -12,8 +12,8 @@ use std::task; -fn child2(_s: ~str) { } +fn child2(_s: StrBuf) { } pub fn main() { - let _x = task::spawn(proc() child2("hi".to_owned())); + let _x = task::spawn(proc() child2("hi".to_strbuf())); } diff --git a/src/test/run-pass/class-attributes-1.rs b/src/test/run-pass/class-attributes-1.rs index 75c3f1a06e22..55cf41d73d59 100644 --- a/src/test/run-pass/class-attributes-1.rs +++ b/src/test/run-pass/class-attributes-1.rs @@ -11,7 +11,7 @@ // pp-exact - Make sure we actually print the attributes struct cat { - name: ~str, + name: StrBuf, } impl Drop for cat { @@ -21,6 +21,6 @@ impl Drop for cat { #[cat_maker] -fn cat(name: ~str) -> cat { cat{name: name,} } +fn cat(name: StrBuf) -> cat { cat{name: name,} } -pub fn main() { let _kitty = cat("Spotty".to_owned()); } +pub fn main() { let _kitty = cat("Spotty".to_strbuf()); } diff --git a/src/test/run-pass/class-attributes-2.rs b/src/test/run-pass/class-attributes-2.rs index d506fa6eb331..b1ed70278ef3 100644 --- a/src/test/run-pass/class-attributes-2.rs +++ b/src/test/run-pass/class-attributes-2.rs @@ -9,7 +9,7 @@ // except according to those terms. struct cat { - name: ~str, + name: StrBuf, } impl Drop for cat { @@ -26,12 +26,12 @@ impl Drop for cat { /** Maybe it should technically be a kitten_maker. */ -fn cat(name: ~str) -> cat { +fn cat(name: StrBuf) -> cat { cat { name: name } } pub fn main() { - let _kitty = cat("Spotty".to_owned()); + let _kitty = cat("Spotty".to_strbuf()); } diff --git a/src/test/run-pass/class-cast-to-trait-cross-crate-2.rs b/src/test/run-pass/class-cast-to-trait-cross-crate-2.rs index c6c78283e19f..df9b30697d94 100644 --- a/src/test/run-pass/class-cast-to-trait-cross-crate-2.rs +++ b/src/test/run-pass/class-cast-to-trait-cross-crate-2.rs @@ -14,13 +14,13 @@ extern crate cci_class_cast; use std::to_str::ToStr; use cci_class_cast::kitty::cat; -fn print_out(thing: Box, expected: ~str) { +fn print_out(thing: Box, expected: StrBuf) { let actual = thing.to_str(); println!("{}", actual); - assert_eq!(actual, expected); + assert_eq!(actual.to_strbuf(), expected); } pub fn main() { - let nyan: Box = box cat(0u, 2, "nyan".to_owned()) as Box; - print_out(nyan, "nyan".to_owned()); + let nyan: Box = box cat(0u, 2, "nyan".to_strbuf()) as Box; + print_out(nyan, "nyan".to_strbuf()); } diff --git a/src/test/run-pass/class-cast-to-trait-multiple-types.rs b/src/test/run-pass/class-cast-to-trait-multiple-types.rs index 701a6d44bf5f..486a505350b8 100644 --- a/src/test/run-pass/class-cast-to-trait-multiple-types.rs +++ b/src/test/run-pass/class-cast-to-trait-multiple-types.rs @@ -53,7 +53,7 @@ struct cat { meows: uint, how_hungry: int, - name: ~str, + name: StrBuf, } impl noisy for cat { @@ -79,7 +79,7 @@ impl cat { } } -fn cat(in_x: uint, in_y: int, in_name: ~str) -> cat { +fn cat(in_x: uint, in_y: int, in_name: StrBuf) -> cat { cat { meows: in_x, how_hungry: in_y, @@ -93,7 +93,7 @@ fn annoy_neighbors(critter: &mut noisy) { } pub fn main() { - let mut nyan: cat = cat(0u, 2, "nyan".to_owned()); + let mut nyan: cat = cat(0u, 2, "nyan".to_strbuf()); let mut whitefang: dog = dog(); annoy_neighbors(&mut nyan); annoy_neighbors(&mut whitefang); diff --git a/src/test/run-pass/class-cast-to-trait.rs b/src/test/run-pass/class-cast-to-trait.rs index fb479b5937ae..99070b973725 100644 --- a/src/test/run-pass/class-cast-to-trait.rs +++ b/src/test/run-pass/class-cast-to-trait.rs @@ -19,7 +19,7 @@ trait noisy { struct cat { meows: uint, how_hungry: int, - name: ~str, + name: StrBuf, } impl noisy for cat { @@ -50,7 +50,7 @@ impl cat { } } -fn cat(in_x : uint, in_y : int, in_name: ~str) -> cat { +fn cat(in_x : uint, in_y : int, in_name: StrBuf) -> cat { cat { meows: in_x, how_hungry: in_y, @@ -60,7 +60,7 @@ fn cat(in_x : uint, in_y : int, in_name: ~str) -> cat { pub fn main() { - let mut nyan = cat(0u, 2, "nyan".to_owned()); + let mut nyan = cat(0u, 2, "nyan".to_strbuf()); let mut nyan: &mut noisy = &mut nyan; nyan.speak(); } diff --git a/src/test/run-pass/class-exports.rs b/src/test/run-pass/class-exports.rs index 96270577ce2b..a7039ca708d9 100644 --- a/src/test/run-pass/class-exports.rs +++ b/src/test/run-pass/class-exports.rs @@ -17,14 +17,14 @@ use kitty::cat; mod kitty { pub struct cat { meows: uint, - name: ~str, + name: StrBuf, } impl cat { - pub fn get_name(&self) -> ~str { self.name.clone() } + pub fn get_name(&self) -> StrBuf { self.name.clone() } } - pub fn cat(in_name: ~str) -> cat { + pub fn cat(in_name: StrBuf) -> cat { cat { name: in_name, meows: 0u @@ -33,5 +33,6 @@ mod kitty { } pub fn main() { - assert_eq!(cat("Spreckles".to_owned()).get_name(), "Spreckles".to_owned()); + assert_eq!(cat("Spreckles".to_strbuf()).get_name(), + "Spreckles".to_strbuf()); } diff --git a/src/test/run-pass/class-impl-very-parameterized-trait.rs b/src/test/run-pass/class-impl-very-parameterized-trait.rs index 360e82cf8fda..f02d41df21e4 100644 --- a/src/test/run-pass/class-impl-very-parameterized-trait.rs +++ b/src/test/run-pass/class-impl-very-parameterized-trait.rs @@ -114,9 +114,9 @@ impl cat { } pub fn main() { - let mut nyan: cat<~str> = cat::new(0, 2, "nyan".to_owned()); + let mut nyan: cat = cat::new(0, 2, "nyan".to_strbuf()); for _ in range(1u, 5) { nyan.speak(); } - assert!(*nyan.find(&1).unwrap() == "nyan".to_owned()); + assert!(*nyan.find(&1).unwrap() == "nyan".to_strbuf()); assert_eq!(nyan.find(&10), None); let mut spotty: cat = cat::new(2, 57, tuxedo); for _ in range(0u, 6) { spotty.speak(); } diff --git a/src/test/run-pass/class-implement-trait-cross-crate.rs b/src/test/run-pass/class-implement-trait-cross-crate.rs index c068c226f4d3..e3a1829597ea 100644 --- a/src/test/run-pass/class-implement-trait-cross-crate.rs +++ b/src/test/run-pass/class-implement-trait-cross-crate.rs @@ -16,7 +16,7 @@ struct cat { meows: uint, how_hungry : int, - name : ~str, + name : StrBuf, } impl cat { @@ -47,7 +47,7 @@ impl cat { } } -fn cat(in_x : uint, in_y : int, in_name: ~str) -> cat { +fn cat(in_x : uint, in_y : int, in_name: StrBuf) -> cat { cat { meows: in_x, how_hungry: in_y, @@ -57,7 +57,7 @@ fn cat(in_x : uint, in_y : int, in_name: ~str) -> cat { pub fn main() { - let mut nyan = cat(0u, 2, "nyan".to_owned()); + let mut nyan = cat(0u, 2, "nyan".to_strbuf()); nyan.eat(); assert!((!nyan.eat())); for _ in range(1u, 10u) { nyan.speak(); }; diff --git a/src/test/run-pass/class-implement-traits.rs b/src/test/run-pass/class-implement-traits.rs index 3739e350d798..92dc231bf7a5 100644 --- a/src/test/run-pass/class-implement-traits.rs +++ b/src/test/run-pass/class-implement-traits.rs @@ -18,7 +18,7 @@ struct cat { meows : uint, how_hungry : int, - name : ~str, + name : StrBuf, } impl cat { @@ -48,7 +48,7 @@ impl noisy for cat { fn speak(&mut self) { self.meow(); } } -fn cat(in_x : uint, in_y : int, in_name: ~str) -> cat { +fn cat(in_x : uint, in_y : int, in_name: StrBuf) -> cat { cat { meows: in_x, how_hungry: in_y, @@ -62,7 +62,7 @@ fn make_speak(mut c: C) { } pub fn main() { - let mut nyan = cat(0u, 2, "nyan".to_owned()); + let mut nyan = cat(0u, 2, "nyan".to_strbuf()); nyan.eat(); assert!((!nyan.eat())); for _ in range(1u, 10u) { diff --git a/src/test/run-pass/class-separate-impl.rs b/src/test/run-pass/class-separate-impl.rs index 417c927701d3..874cf1233b8b 100644 --- a/src/test/run-pass/class-separate-impl.rs +++ b/src/test/run-pass/class-separate-impl.rs @@ -14,7 +14,7 @@ struct cat { meows : uint, how_hungry : int, - name : ~str, + name : StrBuf, } impl cat { @@ -43,7 +43,7 @@ impl cat { } } -fn cat(in_x : uint, in_y : int, in_name: ~str) -> cat { +fn cat(in_x : uint, in_y : int, in_name: StrBuf) -> cat { cat { meows: in_x, how_hungry: in_y, @@ -57,13 +57,13 @@ impl fmt::Show for cat { } } -fn print_out(thing: Box, expected: ~str) { +fn print_out(thing: Box, expected: StrBuf) { let actual = thing.to_str(); println!("{}", actual); - assert_eq!(actual, expected); + assert_eq!(actual.to_strbuf(), expected); } pub fn main() { - let nyan: Box = box cat(0u, 2, "nyan".to_owned()) as Box; - print_out(nyan, "nyan".to_owned()); + let nyan: Box = box cat(0u, 2, "nyan".to_strbuf()) as Box; + print_out(nyan, "nyan".to_strbuf()); } diff --git a/src/test/run-pass/class-str-field.rs b/src/test/run-pass/class-str-field.rs index c1ecbd9b1d2b..438020bab297 100644 --- a/src/test/run-pass/class-str-field.rs +++ b/src/test/run-pass/class-str-field.rs @@ -10,16 +10,16 @@ struct cat { - name : ~str, + name : StrBuf, } -fn cat(in_name: ~str) -> cat { +fn cat(in_name: StrBuf) -> cat { cat { name: in_name } } pub fn main() { - let _nyan = cat("nyan".to_owned()); + let _nyan = cat("nyan".to_strbuf()); } diff --git a/src/test/run-pass/classes-cross-crate.rs b/src/test/run-pass/classes-cross-crate.rs index d1b47e45ccfe..554fb607b15f 100644 --- a/src/test/run-pass/classes-cross-crate.rs +++ b/src/test/run-pass/classes-cross-crate.rs @@ -13,7 +13,7 @@ extern crate cci_class_4; use cci_class_4::kitties::cat; pub fn main() { - let mut nyan = cat(0u, 2, "nyan".to_owned()); + let mut nyan = cat(0u, 2, "nyan".to_strbuf()); nyan.eat(); assert!((!nyan.eat())); for _ in range(1u, 10u) { nyan.speak(); }; diff --git a/src/test/run-pass/classes.rs b/src/test/run-pass/classes.rs index d54a29cde064..33360df56e94 100644 --- a/src/test/run-pass/classes.rs +++ b/src/test/run-pass/classes.rs @@ -12,7 +12,7 @@ struct cat { meows : uint, how_hungry : int, - name : ~str, + name : StrBuf, } impl cat { @@ -40,7 +40,7 @@ impl cat { } } -fn cat(in_x : uint, in_y : int, in_name: ~str) -> cat { +fn cat(in_x : uint, in_y : int, in_name: StrBuf) -> cat { cat { meows: in_x, how_hungry: in_y, @@ -49,7 +49,7 @@ fn cat(in_x : uint, in_y : int, in_name: ~str) -> cat { } pub fn main() { - let mut nyan = cat(0u, 2, "nyan".to_owned()); + let mut nyan = cat(0u, 2, "nyan".to_strbuf()); nyan.eat(); assert!((!nyan.eat())); for _ in range(1u, 10u) { nyan.speak(); }; diff --git a/src/test/run-pass/closure-reform.rs b/src/test/run-pass/closure-reform.rs index 202ec7edb193..47ca20b6ee82 100644 --- a/src/test/run-pass/closure-reform.rs +++ b/src/test/run-pass/closure-reform.rs @@ -14,8 +14,8 @@ use std::mem; use std::io::stdio::println; -fn call_it(f: proc(~str) -> ~str) { - println!("{}", f("Fred".to_owned())) +fn call_it(f: proc(StrBuf) -> StrBuf) { + println!("{}", f("Fred".to_strbuf())) } fn call_a_thunk(f: ||) { @@ -48,17 +48,17 @@ fn call_bare_again(f: extern "Rust" fn(&str)) { pub fn main() { // Procs - let greeting = "Hello ".to_owned(); + let greeting = "Hello ".to_strbuf(); call_it(proc(s) { - greeting + s + format_strbuf!("{}{}", greeting, s) }); - let greeting = "Goodbye ".to_owned(); - call_it(proc(s) greeting + s); + let greeting = "Goodbye ".to_strbuf(); + call_it(proc(s) format_strbuf!("{}{}", greeting, s)); - let greeting = "How's life, ".to_owned(); - call_it(proc(s: ~str) -> ~str { - greeting + s + let greeting = "How's life, ".to_strbuf(); + call_it(proc(s: StrBuf) -> StrBuf { + format_strbuf!("{}{}", greeting, s) }); // Closures diff --git a/src/test/run-pass/complex.rs b/src/test/run-pass/complex.rs index 3ade33b43750..0d06ff9610c9 100644 --- a/src/test/run-pass/complex.rs +++ b/src/test/run-pass/complex.rs @@ -15,18 +15,18 @@ type t = int; fn nothing() { } -fn putstr(_s: ~str) { } +fn putstr(_s: StrBuf) { } fn putint(_i: int) { let mut i: int = 33; - while i < 36 { putstr("hi".to_owned()); i = i + 1; } + while i < 36 { putstr("hi".to_strbuf()); i = i + 1; } } fn zerg(i: int) -> int { return i; } fn foo(x: int) -> int { let mut y: t = x + 2; - putstr("hello".to_owned()); + putstr("hello".to_strbuf()); while y < 10 { putint(y); if y * 3 == 4 { y = y + 2; nothing(); } } let mut z: t; z = 0x55; diff --git a/src/test/run-pass/conditional-compile.rs b/src/test/run-pass/conditional-compile.rs index ebb495de88b8..19ed116cc5c2 100644 --- a/src/test/run-pass/conditional-compile.rs +++ b/src/test/run-pass/conditional-compile.rs @@ -108,8 +108,8 @@ mod test_foreign_items { pub mod rustrt { extern { #[cfg(bogus)] - pub fn write() -> ~str; - pub fn write() -> ~str; + pub fn write() -> StrBuf; + pub fn write() -> StrBuf; } } } diff --git a/src/test/run-pass/const-enum-structlike.rs b/src/test/run-pass/const-enum-structlike.rs index 56cfcfae7a6f..712b3344210c 100644 --- a/src/test/run-pass/const-enum-structlike.rs +++ b/src/test/run-pass/const-enum-structlike.rs @@ -11,7 +11,7 @@ #![feature(struct_variant)] enum E { - S0 { s: ~str }, + S0 { s: StrBuf }, S1 { u: uint } } diff --git a/src/test/run-pass/crate-method-reexport-grrrrrrr.rs b/src/test/run-pass/crate-method-reexport-grrrrrrr.rs index 82b33d02214a..56f6871ed54c 100644 --- a/src/test/run-pass/crate-method-reexport-grrrrrrr.rs +++ b/src/test/run-pass/crate-method-reexport-grrrrrrr.rs @@ -24,5 +24,5 @@ pub fn main() { let x = @(); x.cx(); let y = (); - y.add("hi".to_owned()); + y.add("hi".to_strbuf()); } diff --git a/src/test/run-pass/deriving-hash.rs b/src/test/run-pass/deriving-hash.rs index ce24fa716070..5b61b095fb67 100644 --- a/src/test/run-pass/deriving-hash.rs +++ b/src/test/run-pass/deriving-hash.rs @@ -15,13 +15,21 @@ use std::hash::Hash; #[deriving(Hash)] struct Person { id: uint, - name: ~str, + name: StrBuf, phone: uint, } fn main() { - let person1 = Person { id: 5, name: "Janet".to_owned(), phone: 555_666_7777 }; - let person2 = Person { id: 5, name: "Bob".to_owned(), phone: 555_666_7777 }; + let person1 = Person { + id: 5, + name: "Janet".to_strbuf(), + phone: 555_666_7777 + }; + let person2 = Person { + id: 5, + name: "Bob".to_strbuf(), + phone: 555_666_7777 + }; assert!(hash::hash(&person1) == hash::hash(&person1)); assert!(hash::hash(&person1) != hash::hash(&person2)); } diff --git a/src/test/run-pass/deriving-show-2.rs b/src/test/run-pass/deriving-show-2.rs index 9811caacda00..59ab75ddaaf1 100644 --- a/src/test/run-pass/deriving-show-2.rs +++ b/src/test/run-pass/deriving-show-2.rs @@ -17,7 +17,7 @@ enum A {} #[deriving(Show)] enum B { B1, B2, B3 } #[deriving(Show)] -enum C { C1(int), C2(B), C3(~str) } +enum C { C1(int), C2(B), C3(StrBuf) } #[deriving(Show)] enum D { D1{ a: int } } #[deriving(Show)] diff --git a/src/test/run-pass/deriving-via-extension-struct-tuple.rs b/src/test/run-pass/deriving-via-extension-struct-tuple.rs index fc425dd70762..835741ab7e31 100644 --- a/src/test/run-pass/deriving-via-extension-struct-tuple.rs +++ b/src/test/run-pass/deriving-via-extension-struct-tuple.rs @@ -9,12 +9,12 @@ // except according to those terms. #[deriving(Eq, Show)] -struct Foo(int, int, ~str); +struct Foo(int, int, StrBuf); pub fn main() { - let a1 = Foo(5, 6, "abc".to_owned()); - let a2 = Foo(5, 6, "abc".to_owned()); - let b = Foo(5, 7, "def".to_owned()); + let a1 = Foo(5, 6, "abc".to_strbuf()); + let a2 = Foo(5, 6, "abc".to_strbuf()); + let b = Foo(5, 7, "def".to_strbuf()); assert!(a1 == a1); assert!(a2 == a1); diff --git a/src/test/run-pass/drop-on-ret.rs b/src/test/run-pass/drop-on-ret.rs index 0ab0788fcf71..e2d14239598b 100644 --- a/src/test/run-pass/drop-on-ret.rs +++ b/src/test/run-pass/drop-on-ret.rs @@ -13,7 +13,7 @@ fn f() -> int { if true { - let _s: ~str = "should not leak".to_owned(); + let _s: StrBuf = "should not leak".to_strbuf(); return 1; } return 0; diff --git a/src/test/run-pass/enum-disr-val-pretty.rs b/src/test/run-pass/enum-disr-val-pretty.rs index 5397d5e65e4d..26d2fce3fa8c 100644 --- a/src/test/run-pass/enum-disr-val-pretty.rs +++ b/src/test/run-pass/enum-disr-val-pretty.rs @@ -13,13 +13,13 @@ enum color { red = 1, green, blue, imaginary = -1, } pub fn main() { - test_color(red, 1, "red".to_owned()); - test_color(green, 2, "green".to_owned()); - test_color(blue, 3, "blue".to_owned()); - test_color(imaginary, -1, "imaginary".to_owned()); + test_color(red, 1, "red".to_strbuf()); + test_color(green, 2, "green".to_strbuf()); + test_color(blue, 3, "blue".to_strbuf()); + test_color(imaginary, -1, "imaginary".to_strbuf()); } -fn test_color(color: color, val: int, _name: ~str) { +fn test_color(color: color, val: int, _name: StrBuf) { assert!(color as int == val); assert!(color as f64 == val as f64); } diff --git a/src/test/run-pass/enum-variants.rs b/src/test/run-pass/enum-variants.rs index 363b44384af0..5327a29733e8 100644 --- a/src/test/run-pass/enum-variants.rs +++ b/src/test/run-pass/enum-variants.rs @@ -13,13 +13,13 @@ #![feature(struct_variant)] enum Animal { - Dog (~str, f64), - Cat { name: ~str, weight: f64 } + Dog (StrBuf, f64), + Cat { name: StrBuf, weight: f64 } } pub fn main() { - let mut a: Animal = Dog("Cocoa".to_owned(), 37.2); - a = Cat{ name: "Spotty".to_owned(), weight: 2.7 }; + let mut a: Animal = Dog("Cocoa".to_strbuf(), 37.2); + a = Cat{ name: "Spotty".to_strbuf(), weight: 2.7 }; // permuting the fields should work too - let _c = Cat { weight: 3.1, name: "Spreckles".to_owned() }; + let _c = Cat { weight: 3.1, name: "Spreckles".to_strbuf() }; } diff --git a/src/test/run-pass/estr-uniq.rs b/src/test/run-pass/estr-uniq.rs index e879453f7c98..85a796a686b3 100644 --- a/src/test/run-pass/estr-uniq.rs +++ b/src/test/run-pass/estr-uniq.rs @@ -11,10 +11,10 @@ #![allow(dead_assignment)] pub fn main() { - let x : ~str = "hello".to_owned(); - let _y : ~str = "there".to_owned(); - let mut z = "thing".to_owned(); + let x : StrBuf = "hello".to_strbuf(); + let _y : StrBuf = "there".to_strbuf(); + let mut z = "thing".to_strbuf(); z = x; - assert_eq!(z[0], ('h' as u8)); - assert_eq!(z[4], ('o' as u8)); + assert_eq!(z.as_slice()[0], ('h' as u8)); + assert_eq!(z.as_slice()[4], ('o' as u8)); } diff --git a/src/test/run-pass/explicit_self_xcrate_exe.rs b/src/test/run-pass/explicit_self_xcrate_exe.rs index f536b055c6c5..4e6b038f8ed4 100644 --- a/src/test/run-pass/explicit_self_xcrate_exe.rs +++ b/src/test/run-pass/explicit_self_xcrate_exe.rs @@ -14,6 +14,6 @@ extern crate explicit_self_xcrate; use explicit_self_xcrate::{Foo, Bar}; pub fn main() { - let x = Bar { x: "hello".to_owned() }; + let x = Bar { x: "hello".to_strbuf() }; x.f(); } diff --git a/src/test/run-pass/foreign-fn-linkname.rs b/src/test/run-pass/foreign-fn-linkname.rs index 76902470c06e..d57031c81e78 100644 --- a/src/test/run-pass/foreign-fn-linkname.rs +++ b/src/test/run-pass/foreign-fn-linkname.rs @@ -22,9 +22,9 @@ mod mlibc { } } -fn strlen(str: ~str) -> uint { +fn strlen(str: StrBuf) -> uint { // C string is terminated with a zero - str.with_c_str(|buf| { + str.as_slice().with_c_str(|buf| { unsafe { mlibc::my_strlen(buf) as uint } @@ -32,6 +32,6 @@ fn strlen(str: ~str) -> uint { } pub fn main() { - let len = strlen("Rust".to_owned()); + let len = strlen("Rust".to_strbuf()); assert_eq!(len, 4u); } diff --git a/src/test/run-pass/hashmap-memory.rs b/src/test/run-pass/hashmap-memory.rs index 32ce8e6f5422..33a538098562 100644 --- a/src/test/run-pass/hashmap-memory.rs +++ b/src/test/run-pass/hashmap-memory.rs @@ -20,20 +20,22 @@ extern crate collections; This originally came from the word-count benchmark. */ -pub fn map(filename: ~str, emit: map_reduce::putter) { emit(filename, "1".to_owned()); } +pub fn map(filename: StrBuf, emit: map_reduce::putter) { + emit(filename, "1".to_strbuf()); +} mod map_reduce { use collections::HashMap; use std::str; use std::task; - pub type putter<'a> = |~str, ~str|: 'a; + pub type putter<'a> = |StrBuf, StrBuf|: 'a; - pub type mapper = extern fn(~str, putter); + pub type mapper = extern fn(StrBuf, putter); enum ctrl_proto { find_reducer(Vec, Sender), mapper_done, } - fn start_mappers(ctrl: Sender, inputs: Vec<~str>) { + fn start_mappers(ctrl: Sender, inputs: Vec) { for i in inputs.iter() { let ctrl = ctrl.clone(); let i = i.clone(); @@ -41,12 +43,12 @@ mod map_reduce { } } - fn map_task(ctrl: Sender, input: ~str) { + fn map_task(ctrl: Sender, input: StrBuf) { let mut intermediates = HashMap::new(); - fn emit(im: &mut HashMap<~str, int>, - ctrl: Sender, key: ~str, - _val: ~str) { + fn emit(im: &mut HashMap, + ctrl: Sender, key: StrBuf, + _val: StrBuf) { if im.contains_key(&key) { return; } @@ -64,13 +66,13 @@ mod map_reduce { ctrl_clone.send(mapper_done); } - pub fn map_reduce(inputs: Vec<~str>) { + pub fn map_reduce(inputs: Vec) { let (tx, rx) = channel(); // This task becomes the master control task. It spawns others // to do the rest. - let mut reducers: HashMap<~str, int>; + let mut reducers: HashMap; reducers = HashMap::new(); @@ -83,8 +85,8 @@ mod map_reduce { mapper_done => { num_mappers -= 1; } find_reducer(k, cc) => { let mut c; - match reducers.find(&str::from_utf8(k.as_slice()).unwrap() - .to_owned()) { + match reducers.find(&str::from_utf8( + k.as_slice()).unwrap().to_strbuf()) { Some(&_c) => { c = _c; } None => { c = 0; } } @@ -96,5 +98,6 @@ mod map_reduce { } pub fn main() { - map_reduce::map_reduce(vec!("../src/test/run-pass/hashmap-memory.rs".to_owned())); + map_reduce::map_reduce( + vec!("../src/test/run-pass/hashmap-memory.rs".to_strbuf())); } diff --git a/src/test/run-pass/html-literals.rs b/src/test/run-pass/html-literals.rs index ebecfb2c78ac..13211e0d3d13 100644 --- a/src/test/run-pass/html-literals.rs +++ b/src/test/run-pass/html-literals.rs @@ -41,7 +41,7 @@ macro_rules! parse_node ( ) => ( parse_node!( [$(: $tags ($(:$tag_nodes),*))*]; - [$(:$head_nodes,)* :tag(stringify!($head).to_owned(), + [$(:$head_nodes,)* :tag(stringify!($head).to_strbuf(), vec!($($nodes),*))]; $($rest)* ) @@ -66,7 +66,7 @@ macro_rules! parse_node ( ) => ( parse_node!( [$(: $tags ($(:$tag_nodes),*))*]; - [$(:$nodes,)* :text(".".to_owned())]; + [$(:$nodes,)* :text(".".to_strbuf())]; $($rest)* ) ); @@ -78,7 +78,7 @@ macro_rules! parse_node ( ) => ( parse_node!( [$(: $tags ($(:$tag_nodes),*))*]; - [$(:$nodes,)* :text(stringify!($word).to_owned())]; + [$(:$nodes,)* :text(stringify!($word).to_strbuf())]; $($rest)* ) ); @@ -98,6 +98,6 @@ pub fn main() { } enum HTMLFragment { - tag(~str, Vec ), - text(~str), + tag(StrBuf, Vec ), + text(StrBuf), } diff --git a/src/test/run-pass/issue-10228.rs b/src/test/run-pass/issue-10228.rs index 705908768563..ce02f16634f2 100644 --- a/src/test/run-pass/issue-10228.rs +++ b/src/test/run-pass/issue-10228.rs @@ -13,7 +13,7 @@ enum StdioContainer { } struct Test<'a> { - args: &'a [~str], + args: &'a [StrBuf], io: &'a [StdioContainer] } diff --git a/src/test/run-pass/issue-13304.rs b/src/test/run-pass/issue-13304.rs index f66b943d85f6..b7dbbc7db8a7 100644 --- a/src/test/run-pass/issue-13304.rs +++ b/src/test/run-pass/issue-13304.rs @@ -35,22 +35,25 @@ fn main() { rx.recv(); } } else { - parent("green".to_owned()); - parent("native".to_owned()); + parent("green".to_strbuf()); + parent("native".to_strbuf()); let (tx, rx) = channel(); native::task::spawn(proc() { - parent("green".to_owned()); - parent("native".to_owned()); + parent("green".to_strbuf()); + parent("native".to_strbuf()); tx.send(()); }); rx.recv(); } } -fn parent(flavor: ~str) { +fn parent(flavor: StrBuf) { let args = os::args(); let args = args.as_slice(); - let mut p = io::Process::new(args[0].as_slice(), ["child".to_owned(), flavor]).unwrap(); + let mut p = io::Process::new(args[0].as_slice(), [ + "child".to_owned(), + flavor.to_owned() + ]).unwrap(); p.stdin.get_mut_ref().write_str("test1\ntest2\ntest3").unwrap(); let out = p.wait_with_output(); assert!(out.status.success()); diff --git a/src/test/run-pass/issue-1701.rs b/src/test/run-pass/issue-1701.rs index 965b875a9e61..cef46d56b7dd 100644 --- a/src/test/run-pass/issue-1701.rs +++ b/src/test/run-pass/issue-1701.rs @@ -10,22 +10,22 @@ enum pattern { tabby, tortoiseshell, calico } enum breed { beagle, rottweiler, pug } -type name = ~str; +type name = StrBuf; enum ear_kind { lop, upright } enum animal { cat(pattern), dog(breed), rabbit(name, ear_kind), tiger } -fn noise(a: animal) -> Option<~str> { +fn noise(a: animal) -> Option { match a { - cat(..) => { Some("meow".to_owned()) } - dog(..) => { Some("woof".to_owned()) } + cat(..) => { Some("meow".to_strbuf()) } + dog(..) => { Some("woof".to_strbuf()) } rabbit(..) => { None } - tiger(..) => { Some("roar".to_owned()) } + tiger(..) => { Some("roar".to_strbuf()) } } } pub fn main() { - assert_eq!(noise(cat(tabby)), Some("meow".to_owned())); - assert_eq!(noise(dog(pug)), Some("woof".to_owned())); - assert_eq!(noise(rabbit("Hilbert".to_owned(), upright)), None); - assert_eq!(noise(tiger), Some("roar".to_owned())); + assert_eq!(noise(cat(tabby)), Some("meow".to_strbuf())); + assert_eq!(noise(dog(pug)), Some("woof".to_strbuf())); + assert_eq!(noise(rabbit("Hilbert".to_strbuf(), upright)), None); + assert_eq!(noise(tiger), Some("roar".to_strbuf())); } diff --git a/src/test/run-pass/issue-2631-b.rs b/src/test/run-pass/issue-2631-b.rs index ce67b4c3fda7..8216e3411359 100644 --- a/src/test/run-pass/issue-2631-b.rs +++ b/src/test/run-pass/issue-2631-b.rs @@ -20,8 +20,8 @@ use std::cell::RefCell; use collections::HashMap; pub fn main() { - let v = vec!(@"hi".to_owned()); + let v = vec!(@"hi".to_strbuf()); let mut m: req::header_map = HashMap::new(); - m.insert("METHOD".to_owned(), @RefCell::new(v)); + m.insert("METHOD".to_strbuf(), @RefCell::new(v)); request::(&m); } diff --git a/src/test/run-pass/issue-2804-2.rs b/src/test/run-pass/issue-2804-2.rs index 597a709201f1..57eb0df560f8 100644 --- a/src/test/run-pass/issue-2804-2.rs +++ b/src/test/run-pass/issue-2804-2.rs @@ -16,8 +16,8 @@ extern crate collections; use collections::HashMap; -fn add_interfaces(managed_ip: ~str, device: HashMap<~str, int>) { - println!("{}, {:?}", managed_ip, device.get(&"interfaces".to_owned())); +fn add_interfaces(managed_ip: StrBuf, device: HashMap) { + println!("{}, {:?}", managed_ip, device.get(&"interfaces".to_strbuf())); } pub fn main() {} diff --git a/src/test/run-pass/issue-2804.rs b/src/test/run-pass/issue-2804.rs index dfd34fcf5918..9405c62a184c 100644 --- a/src/test/run-pass/issue-2804.rs +++ b/src/test/run-pass/issue-2804.rs @@ -21,11 +21,11 @@ enum object { int_value(i64), } -fn lookup(table: Box, key: ~str, default: ~str) -> ~str +fn lookup(table: Box, key: StrBuf, default: StrBuf) -> StrBuf { - match table.find(&key) { + match table.find(&key.to_owned()) { option::Some(&json::String(ref s)) => { - (*s).clone() + (*s).to_strbuf() } option::Some(value) => { println!("{} was expected to be a string but is a {:?}", key, value); @@ -37,25 +37,27 @@ fn lookup(table: Box, key: ~str, default: ~str) -> ~str } } -fn add_interface(_store: int, managed_ip: ~str, data: json::Json) -> (~str, object) +fn add_interface(_store: int, managed_ip: StrBuf, data: json::Json) -> (StrBuf, object) { match &data { &json::Object(ref interface) => { - let name = lookup((*interface).clone(), "ifDescr".to_owned(), "".to_owned()); - let label = format!("{}-{}", managed_ip, name); + let name = lookup((*interface).clone(), + "ifDescr".to_strbuf(), + "".to_strbuf()); + let label = format_strbuf!("{}-{}", managed_ip, name); (label, bool_value(false)) } _ => { println!("Expected dict for {} interfaces but found {:?}", managed_ip, data); - ("gnos:missing-interface".to_owned(), bool_value(true)) + ("gnos:missing-interface".to_strbuf(), bool_value(true)) } } } -fn add_interfaces(store: int, managed_ip: ~str, device: HashMap<~str, json::Json>) --> Vec<(~str, object)> { - match device.get(&"interfaces".to_owned()) +fn add_interfaces(store: int, managed_ip: StrBuf, device: HashMap) +-> Vec<(StrBuf, object)> { + match device.get(&"interfaces".to_strbuf()) { &json::List(ref interfaces) => { @@ -66,7 +68,7 @@ fn add_interfaces(store: int, managed_ip: ~str, device: HashMap<~str, json::Json _ => { println!("Expected list for {} interfaces but found {:?}", managed_ip, - device.get(&"interfaces".to_owned())); + device.get(&"interfaces".to_strbuf())); Vec::new() } } diff --git a/src/test/run-pass/issue-3037.rs b/src/test/run-pass/issue-3037.rs index ef403a6c9cb2..0a6482c26b9f 100644 --- a/src/test/run-pass/issue-3037.rs +++ b/src/test/run-pass/issue-3037.rs @@ -10,7 +10,7 @@ enum what { } -fn what_to_str(x: what) -> ~str +fn what_to_str(x: what) -> StrBuf { match x { } diff --git a/src/test/run-pass/issue-3389.rs b/src/test/run-pass/issue-3389.rs index 404b066ac10b..5eefd5ef08ab 100644 --- a/src/test/run-pass/issue-3389.rs +++ b/src/test/run-pass/issue-3389.rs @@ -10,11 +10,11 @@ struct trie_node { - content: Vec<~str> , + content: Vec , children: Vec , } -fn print_str_vector(vector: Vec<~str> ) { +fn print_str_vector(vector: Vec ) { for string in vector.iter() { println!("{}", *string); } @@ -25,8 +25,8 @@ pub fn main() { content: Vec::new(), children: Vec::new() }; - let v = vec!("123".to_owned(), "abc".to_owned()); - node.content = vec!("123".to_owned(), "abc".to_owned()); + let v = vec!("123".to_strbuf(), "abc".to_strbuf()); + node.content = vec!("123".to_strbuf(), "abc".to_strbuf()); print_str_vector(v); print_str_vector(node.content.clone()); diff --git a/src/test/run-pass/issue-3424.rs b/src/test/run-pass/issue-3424.rs index 5a27009d0587..6423ab1cb640 100644 --- a/src/test/run-pass/issue-3424.rs +++ b/src/test/run-pass/issue-3424.rs @@ -15,11 +15,13 @@ use std::path::{Path}; use std::path; use std::result; -type rsrc_loader = proc(path: &Path) -> result::Result<~str, ~str>; +type rsrc_loader = proc(path: &Path) -> result::Result; fn tester() { - let loader: rsrc_loader = proc(_path) {result::Ok("more blah".to_owned())}; + let loader: rsrc_loader = proc(_path) { + result::Ok("more blah".to_strbuf()) + }; let path = path::Path::new("blah"); assert!(loader(&path).is_ok()); diff --git a/src/test/run-pass/issue-3556.rs b/src/test/run-pass/issue-3556.rs index abc21901a036..910f7c328a70 100644 --- a/src/test/run-pass/issue-3556.rs +++ b/src/test/run-pass/issue-3556.rs @@ -11,12 +11,12 @@ #![feature(managed_boxes)] enum Token { - Text(@~str), - ETag(@Vec<~str> , @~str), - UTag(@Vec<~str> , @~str), - Section(@Vec<~str> , bool, @Vec , @~str, @~str, @~str, @~str, @~str), - IncompleteSection(@Vec<~str> , bool, @~str, bool), - Partial(@~str, @~str, @~str), + Text(@StrBuf), + ETag(@Vec , @StrBuf), + UTag(@Vec , @StrBuf), + Section(@Vec , bool, @Vec , @StrBuf, @StrBuf, @StrBuf, @StrBuf, @StrBuf), + IncompleteSection(@Vec , bool, @StrBuf, bool), + Partial(@StrBuf, @StrBuf, @StrBuf), } fn check_strs(actual: &str, expected: &str) -> bool @@ -35,10 +35,13 @@ pub fn main() // assert!(check_strs(fmt!("%?", ETag(@~["foo".to_owned()], @"bar".to_owned())), // "ETag(@~[ ~\"foo\" ], @~\"bar\")")); - let t = Text(@"foo".to_owned()); - let u = Section(@vec!("alpha".to_owned()), true, @vec!(t), @"foo".to_owned(), - @"foo".to_owned(), @"foo".to_owned(), @"foo".to_owned(), - @"foo".to_owned()); + let t = Text(@"foo".to_strbuf()); + let u = Section(@vec!("alpha".to_strbuf()), + true, + @vec!(t), + @"foo".to_strbuf(), + @"foo".to_strbuf(), @"foo".to_strbuf(), @"foo".to_strbuf(), + @"foo".to_strbuf()); let v = format!("{:?}", u); // this is the line that causes the seg fault assert!(v.len() > 0); } diff --git a/src/test/run-pass/issue-3563-3.rs b/src/test/run-pass/issue-3563-3.rs index 852994724584..ac2ce615fee4 100644 --- a/src/test/run-pass/issue-3563-3.rs +++ b/src/test/run-pass/issue-3563-3.rs @@ -100,8 +100,10 @@ impl fmt::Show for AsciiArt { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { // Convert each line into a string. let lines = self.lines.iter() - .map(|line| str::from_chars(line.as_slice())) - .collect::>(); + .map(|line| { + str::from_chars(line.as_slice()).to_strbuf() + }) + .collect::>(); // Concatenate the lines together using a new-line. write!(f.buf, "{}", lines.connect("\n")) diff --git a/src/test/run-pass/issue-3609.rs b/src/test/run-pass/issue-3609.rs index 95bbf77024c8..f1fd83b179f4 100644 --- a/src/test/run-pass/issue-3609.rs +++ b/src/test/run-pass/issue-3609.rs @@ -15,10 +15,10 @@ type SamplesFn = proc(samples: &RingBuffer):Send; enum Msg { - GetSamples(~str, SamplesFn), // sample set name, callback which receives samples + GetSamples(StrBuf, SamplesFn), // sample set name, callback which receives samples } -fn foo(name: ~str, samples_chan: Sender) { +fn foo(name: StrBuf, samples_chan: Sender) { task::spawn(proc() { let mut samples_chan = samples_chan; let callback: SamplesFn = proc(buffer) { diff --git a/src/test/run-pass/issue-3702.rs b/src/test/run-pass/issue-3702.rs index 84414461e96c..9ee34d58c371 100644 --- a/src/test/run-pass/issue-3702.rs +++ b/src/test/run-pass/issue-3702.rs @@ -11,7 +11,7 @@ pub fn main() { trait Text { - fn to_str(&self) -> ~str; + fn to_str(&self) -> StrBuf; } fn to_string(t: Box) { diff --git a/src/test/run-pass/issue-3935.rs b/src/test/run-pass/issue-3935.rs index 36a5396e6cfa..ef24a8cd9d15 100644 --- a/src/test/run-pass/issue-3935.rs +++ b/src/test/run-pass/issue-3935.rs @@ -10,12 +10,12 @@ #[deriving(Eq)] struct Bike { - name: ~str, + name: StrBuf, } pub fn main() { - let town_bike = Bike { name: "schwinn".to_owned() }; - let my_bike = Bike { name: "surly".to_owned() }; + let town_bike = Bike { name: "schwinn".to_strbuf() }; + let my_bike = Bike { name: "surly".to_strbuf() }; assert!(town_bike != my_bike); } diff --git a/src/test/run-pass/issue-4241.rs b/src/test/run-pass/issue-4241.rs index f3e37921ba42..0f7219d7901f 100644 --- a/src/test/run-pass/issue-4241.rs +++ b/src/test/run-pass/issue-4241.rs @@ -24,8 +24,8 @@ enum Result { Int(int), Data(~[u8]), List(~[Result]), - Error(~str), - Status(~str) + Error(StrBuf), + Status(StrBuf) } priv fn parse_data(len: uint, io: @io::Reader) -> Result { @@ -55,7 +55,7 @@ priv fn parse_list(len: uint, io: @io::Reader) -> Result { return List(list); } -priv fn chop(s: ~str) -> ~str { +priv fn chop(s: StrBuf) -> StrBuf { s.slice(0, s.len() - 1).to_owned() } @@ -96,7 +96,7 @@ priv fn parse_response(io: @io::Reader) -> Result { } } -priv fn cmd_to_str(cmd: ~[~str]) -> ~str { +priv fn cmd_to_str(cmd: ~[StrBuf]) -> StrBuf { let mut res = "*".to_owned(); res.push_str(cmd.len().to_str()); res.push_str("\r\n"); @@ -107,7 +107,7 @@ priv fn cmd_to_str(cmd: ~[~str]) -> ~str { res } -fn query(cmd: ~[~str], sb: TcpSocketBuf) -> Result { +fn query(cmd: ~[StrBuf], sb: TcpSocketBuf) -> Result { let cmd = cmd_to_str(cmd); //println!("{}", cmd); sb.write_str(cmd); @@ -115,7 +115,7 @@ fn query(cmd: ~[~str], sb: TcpSocketBuf) -> Result { res } -fn query2(cmd: ~[~str]) -> Result { +fn query2(cmd: ~[StrBuf]) -> Result { let _cmd = cmd_to_str(cmd); io::with_str_reader("$3\r\nXXX\r\n".to_owned())(|sb| { let res = parse_response(@sb as @io::Reader); diff --git a/src/test/run-pass/issue-4541.rs b/src/test/run-pass/issue-4541.rs index f05b1932b738..73df5d206d36 100644 --- a/src/test/run-pass/issue-4541.rs +++ b/src/test/run-pass/issue-4541.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn parse_args() -> ~str { +fn parse_args() -> StrBuf { let args = ::std::os::args(); let args = args.as_slice(); let mut n = 0; @@ -17,13 +17,13 @@ fn parse_args() -> ~str { match args[n].as_slice() { "-v" => (), s => { - return s.into_owned(); + return s.to_strbuf(); } } n += 1; } - return "".to_owned() + return "".to_strbuf() } pub fn main() { diff --git a/src/test/run-pass/issue-5008-borrowed-traitobject-method-call.rs b/src/test/run-pass/issue-5008-borrowed-traitobject-method-call.rs index 08676495e318..57cae2fdf716 100644 --- a/src/test/run-pass/issue-5008-borrowed-traitobject-method-call.rs +++ b/src/test/run-pass/issue-5008-borrowed-traitobject-method-call.rs @@ -16,20 +16,20 @@ It fixes itself if the &Trait is changed to @Trait. */ trait Debuggable { - fn debug_name(&self) -> ~str; + fn debug_name(&self) -> StrBuf; } #[deriving(Clone)] struct Thing { -name: ~str, + name: StrBuf, } impl Thing { - fn new() -> Thing { Thing { name: "dummy".to_owned() } } + fn new() -> Thing { Thing { name: "dummy".to_strbuf() } } } impl Debuggable for Thing { - fn debug_name(&self) -> ~str { self.name.clone() } + fn debug_name(&self) -> StrBuf { self.name.clone() } } fn print_name(x: &Debuggable) diff --git a/src/test/run-pass/issue-5353.rs b/src/test/run-pass/issue-5353.rs index 845d1a18c2a2..ade2815fd2df 100644 --- a/src/test/run-pass/issue-5353.rs +++ b/src/test/run-pass/issue-5353.rs @@ -11,13 +11,13 @@ static INVALID_ENUM : u32 = 0; static INVALID_VALUE : u32 = 1; -fn gl_err_str(err: u32) -> ~str +fn gl_err_str(err: u32) -> StrBuf { match err { - INVALID_ENUM => { "Invalid enum".to_owned() }, - INVALID_VALUE => { "Invalid value".to_owned() }, - _ => { "Unknown error".to_owned() } + INVALID_ENUM => { "Invalid enum".to_strbuf() }, + INVALID_VALUE => { "Invalid value".to_strbuf() }, + _ => { "Unknown error".to_strbuf() } } } diff --git a/src/test/run-pass/issue-5550.rs b/src/test/run-pass/issue-5550.rs index b3d22ab1a376..d4962784b9ac 100644 --- a/src/test/run-pass/issue-5550.rs +++ b/src/test/run-pass/issue-5550.rs @@ -11,7 +11,7 @@ #![allow(dead_assignment)] pub fn main() { - let s: ~str = "foobar".to_owned(); - let mut t: &str = s; + let s: StrBuf = "foobar".to_strbuf(); + let mut t: &str = s.as_slice(); t = t.slice(0, 3); // for master: str::view(t, 0, 3) maybe } diff --git a/src/test/run-pass/issue-5666.rs b/src/test/run-pass/issue-5666.rs index a3dc1fae7f18..2238c30f6e8c 100644 --- a/src/test/run-pass/issue-5666.rs +++ b/src/test/run-pass/issue-5666.rs @@ -10,23 +10,23 @@ struct Dog { - name : ~str + name : StrBuf } trait Barks { - fn bark(&self) -> ~str; + fn bark(&self) -> StrBuf; } impl Barks for Dog { - fn bark(&self) -> ~str { - return format!("woof! (I'm {})", self.name); + fn bark(&self) -> StrBuf { + return format!("woof! (I'm {})", self.name).to_strbuf(); } } pub fn main() { - let snoopy = box Dog{name: "snoopy".to_owned()}; - let bubbles = box Dog{name: "bubbles".to_owned()}; + let snoopy = box Dog{name: "snoopy".to_strbuf()}; + let bubbles = box Dog{name: "bubbles".to_strbuf()}; let barker = [snoopy as Box, bubbles as Box]; for pup in barker.iter() { diff --git a/src/test/run-pass/issue-8506.rs b/src/test/run-pass/issue-8506.rs index 1c3e0f367078..ecf066d86bce 100644 --- a/src/test/run-pass/issue-8506.rs +++ b/src/test/run-pass/issue-8506.rs @@ -12,7 +12,7 @@ enum Either { One, - Other(~str,~str) + Other(StrBuf,StrBuf) } static one : Either = One; diff --git a/src/test/run-pass/issue-8578.rs b/src/test/run-pass/issue-8578.rs index fcc9278b4c5c..383eede5c14a 100644 --- a/src/test/run-pass/issue-8578.rs +++ b/src/test/run-pass/issue-8578.rs @@ -9,7 +9,7 @@ // except according to those terms. pub struct UninterpretedOption_NamePart { - name_part: Option<~str>, + name_part: Option, } impl<'a> UninterpretedOption_NamePart { diff --git a/src/test/run-pass/issue-8898.rs b/src/test/run-pass/issue-8898.rs index 54e0c30c1d21..77edc07ace0d 100644 --- a/src/test/run-pass/issue-8898.rs +++ b/src/test/run-pass/issue-8898.rs @@ -10,8 +10,8 @@ #![feature(managed_boxes)] -fn assert_repr_eq(obj : T, expected : ~str) { - assert_eq!(expected, format!("{:?}", obj)); +fn assert_repr_eq(obj : T, expected : StrBuf) { + assert_eq!(expected, format_strbuf!("{:?}", obj)); } pub fn main() { @@ -21,10 +21,10 @@ pub fn main() { let slice = x.slice(0,1); let z = @x; - assert_repr_eq(abc, "[1, 2, 3]".to_owned()); - assert_repr_eq(tf, "[true, false]".to_owned()); - assert_repr_eq(x, "[(), ()]".to_owned()); - assert_repr_eq(slice, "&[()]".to_owned()); - assert_repr_eq(&x, "&[(), ()]".to_owned()); - assert_repr_eq(z, "@[(), ()]".to_owned()); + assert_repr_eq(abc, "[1, 2, 3]".to_strbuf()); + assert_repr_eq(tf, "[true, false]".to_strbuf()); + assert_repr_eq(x, "[(), ()]".to_strbuf()); + assert_repr_eq(slice, "&[()]".to_strbuf()); + assert_repr_eq(&x, "&[(), ()]".to_strbuf()); + assert_repr_eq(z, "@[(), ()]".to_strbuf()); } diff --git a/src/test/run-pass/issue-9047.rs b/src/test/run-pass/issue-9047.rs index 70b6eec83afa..0cdceb235174 100644 --- a/src/test/run-pass/issue-9047.rs +++ b/src/test/run-pass/issue-9047.rs @@ -8,12 +8,12 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -fn decode() -> ~str { +fn decode() -> StrBuf { 'outer: loop { let mut ch_start: uint; break 'outer; } - "".to_owned() + "".to_strbuf() } pub fn main() { diff --git a/src/test/run-pass/issue-9259.rs b/src/test/run-pass/issue-9259.rs index b03213272cb1..8cdd5d31002a 100644 --- a/src/test/run-pass/issue-9259.rs +++ b/src/test/run-pass/issue-9259.rs @@ -9,14 +9,14 @@ // except according to those terms. struct A<'a> { - a: &'a [~str], - b: Option<&'a [~str]>, + a: &'a [StrBuf], + b: Option<&'a [StrBuf]>, } pub fn main() { - let b = &["foo".to_owned()]; + let b = &["foo".to_strbuf()]; let a = A { - a: &["test".to_owned()], + a: &["test".to_strbuf()], b: Some(b), }; assert_eq!(a.b.get_ref()[0].as_slice(), "foo"); diff --git a/src/test/run-pass/issue-9394-inherited-trait-calls.rs b/src/test/run-pass/issue-9394-inherited-trait-calls.rs index af8be3a7f11c..cd9154f27489 100644 --- a/src/test/run-pass/issue-9394-inherited-trait-calls.rs +++ b/src/test/run-pass/issue-9394-inherited-trait-calls.rs @@ -9,62 +9,62 @@ // except according to those terms. trait Base: Base2 + Base3{ - fn foo(&self) -> ~str; - fn foo1(&self) -> ~str; - fn foo2(&self) -> ~str{ - "base foo2".to_owned() + fn foo(&self) -> StrBuf; + fn foo1(&self) -> StrBuf; + fn foo2(&self) -> StrBuf{ + "base foo2".to_strbuf() } } trait Base2: Base3{ - fn baz(&self) -> ~str; + fn baz(&self) -> StrBuf; } trait Base3{ - fn root(&self) -> ~str; + fn root(&self) -> StrBuf; } trait Super: Base{ - fn bar(&self) -> ~str; + fn bar(&self) -> StrBuf; } struct X; impl Base for X { - fn foo(&self) -> ~str{ - "base foo".to_owned() + fn foo(&self) -> StrBuf{ + "base foo".to_strbuf() } - fn foo1(&self) -> ~str{ - "base foo1".to_owned() + fn foo1(&self) -> StrBuf{ + "base foo1".to_strbuf() } } impl Base2 for X { - fn baz(&self) -> ~str{ - "base2 baz".to_owned() + fn baz(&self) -> StrBuf{ + "base2 baz".to_strbuf() } } impl Base3 for X { - fn root(&self) -> ~str{ - "base3 root".to_owned() + fn root(&self) -> StrBuf{ + "base3 root".to_strbuf() } } impl Super for X { - fn bar(&self) -> ~str{ - "super bar".to_owned() + fn bar(&self) -> StrBuf{ + "super bar".to_strbuf() } } pub fn main() { let n = X; let s = &n as &Super; - assert_eq!(s.bar(),"super bar".to_owned()); - assert_eq!(s.foo(),"base foo".to_owned()); - assert_eq!(s.foo1(),"base foo1".to_owned()); - assert_eq!(s.foo2(),"base foo2".to_owned()); - assert_eq!(s.baz(),"base2 baz".to_owned()); - assert_eq!(s.root(),"base3 root".to_owned()); + assert_eq!(s.bar(),"super bar".to_strbuf()); + assert_eq!(s.foo(),"base foo".to_strbuf()); + assert_eq!(s.foo1(),"base foo1".to_strbuf()); + assert_eq!(s.foo2(),"base foo2".to_strbuf()); + assert_eq!(s.baz(),"base2 baz".to_strbuf()); + assert_eq!(s.root(),"base3 root".to_strbuf()); } diff --git a/src/test/run-pass/issue-9446.rs b/src/test/run-pass/issue-9446.rs index b4e814e6248f..319e67b67a15 100644 --- a/src/test/run-pass/issue-9446.rs +++ b/src/test/run-pass/issue-9446.rs @@ -8,10 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -struct Wrapper(~str); +struct Wrapper(StrBuf); impl Wrapper { - pub fn new(wrapped: ~str) -> Wrapper { + pub fn new(wrapped: StrBuf) -> Wrapper { Wrapper(wrapped) } @@ -28,12 +28,12 @@ impl Drop for Wrapper { pub fn main() { { // This runs without complaint. - let x = Wrapper::new("Bob".to_owned()); + let x = Wrapper::new("Bob".to_strbuf()); x.say_hi(); } { // This fails to compile, circa 0.8-89-gc635fba. // error: internal compiler error: drop_ty_immediate: non-box ty - Wrapper::new("Bob".to_owned()).say_hi(); + Wrapper::new("Bob".to_strbuf()).say_hi(); } } diff --git a/src/test/run-pass/istr.rs b/src/test/run-pass/istr.rs index 7201ce31bcd5..e4e7b052cf37 100644 --- a/src/test/run-pass/istr.rs +++ b/src/test/run-pass/istr.rs @@ -11,37 +11,27 @@ use std::strbuf::StrBuf; fn test_stack_assign() { - let s: ~str = "a".to_owned(); + let s: StrBuf = "a".to_strbuf(); println!("{}", s.clone()); - let t: ~str = "a".to_owned(); + let t: StrBuf = "a".to_strbuf(); assert!(s == t); - let u: ~str = "b".to_owned(); + let u: StrBuf = "b".to_strbuf(); assert!((s != u)); } -fn test_heap_lit() { "a big string".to_owned(); } +fn test_heap_lit() { "a big string".to_strbuf(); } fn test_heap_assign() { - let s: ~str = "a big ol' string".to_owned(); - let t: ~str = "a big ol' string".to_owned(); + let s: StrBuf = "a big ol' string".to_strbuf(); + let t: StrBuf = "a big ol' string".to_strbuf(); assert!(s == t); - let u: ~str = "a bad ol' string".to_owned(); + let u: StrBuf = "a bad ol' string".to_strbuf(); assert!((s != u)); } -fn test_heap_log() { let s = "a big ol' string".to_owned(); println!("{}", s); } - -fn test_stack_add() { - assert_eq!("a".to_owned() + "b", "ab".to_owned()); - let s: ~str = "a".to_owned(); - assert_eq!(s + s, "aa".to_owned()); - assert_eq!("".to_owned() + "", "".to_owned()); -} - -fn test_stack_heap_add() { assert!(("a".to_owned() + "bracadabra" == "abracadabra".to_owned())); } - -fn test_heap_add() { - assert_eq!("this should".to_owned() + " totally work", "this should totally work".to_owned()); +fn test_heap_log() { + let s = "a big ol' string".to_strbuf(); + println!("{}", s); } fn test_append() { @@ -67,8 +57,5 @@ pub fn main() { test_heap_lit(); test_heap_assign(); test_heap_log(); - test_stack_add(); - test_stack_heap_add(); - test_heap_add(); test_append(); } diff --git a/src/test/run-pass/last-use-in-block.rs b/src/test/run-pass/last-use-in-block.rs index 8117c5657e98..1eedaed98bc3 100644 --- a/src/test/run-pass/last-use-in-block.rs +++ b/src/test/run-pass/last-use-in-block.rs @@ -10,7 +10,7 @@ // Issue #1818 -fn lp(s: ~str, f: |~str| -> T) -> T { +fn lp(s: StrBuf, f: |StrBuf| -> T) -> T { while false { let r = f(s); return (r); @@ -18,8 +18,8 @@ fn lp(s: ~str, f: |~str| -> T) -> T { fail!(); } -fn apply(s: ~str, f: |~str| -> T) -> T { - fn g(s: ~str, f: |~str| -> T) -> T {f(s)} +fn apply(s: StrBuf, f: |StrBuf| -> T) -> T { + fn g(s: StrBuf, f: |StrBuf| -> T) -> T {f(s)} g(s, |v| { let r = f(v); r }) } diff --git a/src/test/run-pass/log-knows-the-names-of-variants-in-std.rs b/src/test/run-pass/log-knows-the-names-of-variants-in-std.rs index d51ce1538efc..e9e6ab02e9eb 100644 --- a/src/test/run-pass/log-knows-the-names-of-variants-in-std.rs +++ b/src/test/run-pass/log-knows-the-names-of-variants-in-std.rs @@ -12,29 +12,23 @@ #[deriving(Clone)] enum foo { a(uint), - b(~str), + b(StrBuf), } -fn check_log(exp: ~str, v: T) { - assert_eq!(exp, format!("{:?}", v)); +fn check_log(exp: StrBuf, v: T) { + assert_eq!(exp, format_strbuf!("{:?}", v)); } pub fn main() { let mut x = Some(a(22u)); - let exp = "Some(a(22u))".to_owned(); - let act = format!("{:?}", x); - assert_eq!(act, exp); - check_log(exp, x); - - x = Some(b("hi".to_owned())); - let exp = "Some(b(~\"hi\"))".to_owned(); - let act = format!("{:?}", x); + let exp = "Some(a(22u))".to_strbuf(); + let act = format_strbuf!("{:?}", x); assert_eq!(act, exp); check_log(exp, x); x = None; - let exp = "None".to_owned(); - let act = format!("{:?}", x); + let exp = "None".to_strbuf(); + let act = format_strbuf!("{:?}", x); assert_eq!(act, exp); check_log(exp, x); } diff --git a/src/test/run-pass/log-knows-the-names-of-variants.rs b/src/test/run-pass/log-knows-the-names-of-variants.rs index 404c227c2e2c..46bdb5eb7660 100644 --- a/src/test/run-pass/log-knows-the-names-of-variants.rs +++ b/src/test/run-pass/log-knows-the-names-of-variants.rs @@ -10,7 +10,7 @@ enum foo { a(uint), - b(~str), + b(StrBuf), c, } @@ -19,8 +19,7 @@ enum bar { } pub fn main() { - assert_eq!("a(22u)".to_owned(), format!("{:?}", a(22u))); - assert_eq!("b(~\"hi\")".to_owned(), format!("{:?}", b("hi".to_owned()))); - assert_eq!("c".to_owned(), format!("{:?}", c)); - assert_eq!("d".to_owned(), format!("{:?}", d)); + assert_eq!("a(22u)".to_strbuf(), format_strbuf!("{:?}", a(22u))); + assert_eq!("c".to_strbuf(), format_strbuf!("{:?}", c)); + assert_eq!("d".to_strbuf(), format_strbuf!("{:?}", d)); } diff --git a/src/test/run-pass/match-borrowed_str.rs b/src/test/run-pass/match-borrowed_str.rs index 3bbd33378d0c..db1db8067a86 100644 --- a/src/test/run-pass/match-borrowed_str.rs +++ b/src/test/run-pass/match-borrowed_str.rs @@ -10,49 +10,49 @@ #![allow(unnecessary_allocation)] -fn f1(ref_string: &str) -> ~str { +fn f1(ref_string: &str) -> StrBuf { match ref_string { - "a" => "found a".to_owned(), - "b" => "found b".to_owned(), - _ => "not found".to_owned() + "a" => "found a".to_strbuf(), + "b" => "found b".to_strbuf(), + _ => "not found".to_strbuf() } } -fn f2(ref_string: &str) -> ~str { +fn f2(ref_string: &str) -> StrBuf { match ref_string { - "a" => "found a".to_owned(), - "b" => "found b".to_owned(), - s => format!("not found ({})", s) + "a" => "found a".to_strbuf(), + "b" => "found b".to_strbuf(), + s => format_strbuf!("not found ({})", s) } } -fn g1(ref_1: &str, ref_2: &str) -> ~str { +fn g1(ref_1: &str, ref_2: &str) -> StrBuf { match (ref_1, ref_2) { - ("a", "b") => "found a,b".to_owned(), - ("b", "c") => "found b,c".to_owned(), - _ => "not found".to_owned() + ("a", "b") => "found a,b".to_strbuf(), + ("b", "c") => "found b,c".to_strbuf(), + _ => "not found".to_strbuf() } } -fn g2(ref_1: &str, ref_2: &str) -> ~str { +fn g2(ref_1: &str, ref_2: &str) -> StrBuf { match (ref_1, ref_2) { - ("a", "b") => "found a,b".to_owned(), - ("b", "c") => "found b,c".to_owned(), - (s1, s2) => format!("not found ({}, {})", s1, s2) + ("a", "b") => "found a,b".to_strbuf(), + ("b", "c") => "found b,c".to_strbuf(), + (s1, s2) => format_strbuf!("not found ({}, {})", s1, s2) } } pub fn main() { - assert_eq!(f1("b".to_owned()), "found b".to_owned()); - assert_eq!(f1("c"), "not found".to_owned()); - assert_eq!(f1("d"), "not found".to_owned()); - assert_eq!(f2("b".to_owned()), "found b".to_owned()); - assert_eq!(f2("c"), "not found (c)".to_owned()); - assert_eq!(f2("d"), "not found (d)".to_owned()); - assert_eq!(g1("b".to_owned(), "c".to_owned()), "found b,c".to_owned()); - assert_eq!(g1("c", "d"), "not found".to_owned()); - assert_eq!(g1("d", "e"), "not found".to_owned()); - assert_eq!(g2("b".to_owned(), "c".to_owned()), "found b,c".to_owned()); - assert_eq!(g2("c", "d"), "not found (c, d)".to_owned()); - assert_eq!(g2("d", "e"), "not found (d, e)".to_owned()); + assert_eq!(f1("b"), "found b".to_strbuf()); + assert_eq!(f1("c"), "not found".to_strbuf()); + assert_eq!(f1("d"), "not found".to_strbuf()); + assert_eq!(f2("b"), "found b".to_strbuf()); + assert_eq!(f2("c"), "not found (c)".to_strbuf()); + assert_eq!(f2("d"), "not found (d)".to_strbuf()); + assert_eq!(g1("b", "c"), "found b,c".to_strbuf()); + assert_eq!(g1("c", "d"), "not found".to_strbuf()); + assert_eq!(g1("d", "e"), "not found".to_strbuf()); + assert_eq!(g2("b", "c"), "found b,c".to_strbuf()); + assert_eq!(g2("c", "d"), "not found (c, d)".to_strbuf()); + assert_eq!(g2("d", "e"), "not found (d, e)".to_strbuf()); } diff --git a/src/test/run-pass/match-str.rs b/src/test/run-pass/match-str.rs index e1ae9a6a73a5..e3060a6b4be6 100644 --- a/src/test/run-pass/match-str.rs +++ b/src/test/run-pass/match-str.rs @@ -13,13 +13,13 @@ pub fn main() { match "test" { "not-test" => fail!(), "test" => (), _ => fail!() } - enum t { tag1(~str), tag2, } + enum t { tag1(StrBuf), tag2, } - match tag1("test".to_owned()) { + match tag1("test".to_strbuf()) { tag2 => fail!(), - tag1(ref s) if "test" != *s => fail!(), - tag1(ref s) if "test" == *s => (), + tag1(ref s) if "test" != s.as_slice() => fail!(), + tag1(ref s) if "test" == s.as_slice() => (), _ => fail!() } diff --git a/src/test/run-pass/monad.rs b/src/test/run-pass/monad.rs index 1011734a2adf..8b3cb76817ec 100644 --- a/src/test/run-pass/monad.rs +++ b/src/test/run-pass/monad.rs @@ -37,15 +37,18 @@ impl option_monad for Option { } } -fn transform(x: Option) -> Option<~str> { - x.bind(|n| Some(*n + 1) ).bind(|n| Some(n.to_str()) ) +fn transform(x: Option) -> Option { + x.bind(|n| Some(*n + 1) ).bind(|n| Some(n.to_str().to_strbuf()) ) } pub fn main() { - assert_eq!(transform(Some(10)), Some("11".to_owned())); + assert_eq!(transform(Some(10)), Some("11".to_strbuf())); assert_eq!(transform(None), None); - assert!((vec!("hi".to_owned())) - .bind(|x| vec!(x.clone(), *x + "!") ) - .bind(|x| vec!(x.clone(), *x + "?") ) == - vec!("hi".to_owned(), "hi?".to_owned(), "hi!".to_owned(), "hi!?".to_owned())); + assert!((vec!("hi".to_strbuf())) + .bind(|x| vec!(x.clone(), format_strbuf!("{}!", x)) ) + .bind(|x| vec!(x.clone(), format_strbuf!("{}?", x)) ) == + vec!("hi".to_strbuf(), + "hi?".to_strbuf(), + "hi!".to_strbuf(), + "hi!?".to_strbuf())); } diff --git a/src/test/run-pass/move-self.rs b/src/test/run-pass/move-self.rs index e31e312f4fb3..276aaa3b63f6 100644 --- a/src/test/run-pass/move-self.rs +++ b/src/test/run-pass/move-self.rs @@ -9,7 +9,7 @@ // except according to those terms. struct S { - x: ~str + x: StrBuf } impl S { @@ -23,6 +23,6 @@ impl S { } pub fn main() { - let x = S { x: "Hello!".to_owned() }; + let x = S { x: "Hello!".to_strbuf() }; x.foo(); } diff --git a/src/test/run-pass/nullable-pointer-iotareduction.rs b/src/test/run-pass/nullable-pointer-iotareduction.rs index fb61bea83da8..270642a7e580 100644 --- a/src/test/run-pass/nullable-pointer-iotareduction.rs +++ b/src/test/run-pass/nullable-pointer-iotareduction.rs @@ -76,7 +76,7 @@ pub fn main() { check_type!(&17: &int); check_type!(box 18: Box); check_type!(@19: @int); - check_type!("foo".to_owned(): ~str); + check_type!("foo".to_strbuf(): StrBuf); check_type!(vec!(20, 22): Vec ); let mint: uint = unsafe { mem::transmute(main) }; check_type!(main: fn(), |pthing| { diff --git a/src/test/run-pass/nullable-pointer-size.rs b/src/test/run-pass/nullable-pointer-size.rs index 00edcd6a0924..b824988ea795 100644 --- a/src/test/run-pass/nullable-pointer-size.rs +++ b/src/test/run-pass/nullable-pointer-size.rs @@ -40,6 +40,5 @@ pub fn main() { check_type!(&'static int); check_type!(Box); check_type!(@int); - check_type!(~str); check_type!(extern fn()); } diff --git a/src/test/run-pass/packed-struct-generic-size.rs b/src/test/run-pass/packed-struct-generic-size.rs index b297fc7e13f7..80f37a0fa3d0 100644 --- a/src/test/run-pass/packed-struct-generic-size.rs +++ b/src/test/run-pass/packed-struct-generic-size.rs @@ -21,7 +21,4 @@ pub fn main() { assert_eq!(mem::size_of::>(), 3); assert_eq!(mem::size_of::>(), 11); - - assert_eq!(mem::size_of:: >>(), - 1 + mem::size_of::<~str>() + mem::size_of:: >()); } diff --git a/src/test/run-pass/packed-struct-size.rs b/src/test/run-pass/packed-struct-size.rs index fc081408229d..1781f162bc49 100644 --- a/src/test/run-pass/packed-struct-size.rs +++ b/src/test/run-pass/packed-struct-size.rs @@ -25,11 +25,10 @@ struct S5 { } #[packed] -struct S13_str { +struct S13 { a: i64, b: f32, c: u8, - d: ~str } enum Foo { @@ -61,7 +60,7 @@ static TEST_S3_Foo: S3_Foo = S3_Foo { a: 1, b: 2, c: Baz }; pub fn main() { assert_eq!(mem::size_of::(), 4); assert_eq!(mem::size_of::(), 5); - assert_eq!(mem::size_of::(), 13 + mem::size_of::<~str>()); + assert_eq!(mem::size_of::(), 13); assert_eq!(mem::size_of::(), 3 + mem::size_of::()); assert_eq!(mem::size_of::(), 7 + mem::size_of::>()); } diff --git a/src/test/run-pass/packed-tuple-struct-size.rs b/src/test/run-pass/packed-tuple-struct-size.rs index 059d92b477ce..9036df0bbd1e 100644 --- a/src/test/run-pass/packed-tuple-struct-size.rs +++ b/src/test/run-pass/packed-tuple-struct-size.rs @@ -19,7 +19,7 @@ struct S4(u8,[u8, .. 3]); struct S5(u8, u32); #[packed] -struct S13_str(i64, f32, u8, ~str); +struct S13(i64, f32, u8); enum Foo { Bar = 1, @@ -37,8 +37,7 @@ pub fn main() { assert_eq!(mem::size_of::(), 5); - assert_eq!(mem::size_of::(), - 13 + mem::size_of::<~str>()); + assert_eq!(mem::size_of::(), 13); assert_eq!(mem::size_of::(), 3 + mem::size_of::()); diff --git a/src/test/run-pass/rec-auto.rs b/src/test/run-pass/rec-auto.rs index b0cd9e60ed70..19b5268001d1 100644 --- a/src/test/run-pass/rec-auto.rs +++ b/src/test/run-pass/rec-auto.rs @@ -14,10 +14,10 @@ // Issue #50. -struct X { foo: ~str, bar: ~str } +struct X { foo: StrBuf, bar: StrBuf } pub fn main() { - let x = X {foo: "hello".to_owned(), bar: "world".to_owned()}; + let x = X {foo: "hello".to_strbuf(), bar: "world".to_strbuf()}; println!("{}", x.foo.clone()); println!("{}", x.bar.clone()); } diff --git a/src/test/run-pass/reexported-static-methods-cross-crate.rs b/src/test/run-pass/reexported-static-methods-cross-crate.rs index 213665245a83..17ed80da03c9 100644 --- a/src/test/run-pass/reexported-static-methods-cross-crate.rs +++ b/src/test/run-pass/reexported-static-methods-cross-crate.rs @@ -20,5 +20,5 @@ pub fn main() { assert_eq!(42, Foo::foo()); assert_eq!(84, Baz::bar()); assert!(Boz::boz(1)); - assert_eq!("bort()".to_owned(), Bort::bort()); + assert_eq!("bort()".to_strbuf(), Bort::bort()); } diff --git a/src/test/run-pass/reflect-visit-type.rs b/src/test/run-pass/reflect-visit-type.rs index a131b21957de..d05bc5600889 100644 --- a/src/test/run-pass/reflect-visit-type.rs +++ b/src/test/run-pass/reflect-visit-type.rs @@ -13,37 +13,37 @@ use std::intrinsics::{TyDesc, get_tydesc, visit_tydesc, TyVisitor, Disr, Opaque}; struct MyVisitor { - types: Vec<~str> , + types: Vec , } impl TyVisitor for MyVisitor { fn visit_bot(&mut self) -> bool { - self.types.push("bot".to_owned()); + self.types.push("bot".to_strbuf()); println!("visited bot type"); true } fn visit_nil(&mut self) -> bool { - self.types.push("nil".to_owned()); + self.types.push("nil".to_strbuf()); println!("visited nil type"); true } fn visit_bool(&mut self) -> bool { - self.types.push("bool".to_owned()); + self.types.push("bool".to_strbuf()); println!("visited bool type"); true } fn visit_int(&mut self) -> bool { - self.types.push("int".to_owned()); + self.types.push("int".to_strbuf()); println!("visited int type"); true } fn visit_i8(&mut self) -> bool { - self.types.push("i8".to_owned()); + self.types.push("i8".to_strbuf()); println!("visited i8 type"); true } fn visit_i16(&mut self) -> bool { - self.types.push("i16".to_owned()); + self.types.push("i16".to_strbuf()); println!("visited i16 type"); true } @@ -76,9 +76,9 @@ impl TyVisitor for MyVisitor { fn visit_evec_box(&mut self, _mtbl: uint, _inner: *TyDesc) -> bool { true } fn visit_evec_uniq(&mut self, _mtbl: uint, inner: *TyDesc) -> bool { - self.types.push("[".to_owned()); + self.types.push("[".to_strbuf()); unsafe { visit_tydesc(inner, &mut *self as &mut TyVisitor); } - self.types.push("]".to_owned()); + self.types.push("]".to_strbuf()); true } fn visit_evec_slice(&mut self, _mtbl: uint, _inner: *TyDesc) -> bool { true } @@ -155,7 +155,7 @@ pub fn main() { println!("type: {}", (*s).clone()); } - let vec_types: Vec<~str> = v.types.clone().move_iter().collect(); - assert_eq!(vec_types, vec!("bool".to_owned(), "int".to_owned(), - "i8".to_owned(), "i16".to_owned())); + let vec_types: Vec = v.types.clone().move_iter().collect(); + assert_eq!(vec_types, vec!("bool".to_strbuf(), "int".to_strbuf(), + "i8".to_strbuf(), "i16".to_strbuf())); } diff --git a/src/test/run-pass/repeated-vector-syntax.rs b/src/test/run-pass/repeated-vector-syntax.rs index 9538a097ab4c..38f0f12267ba 100644 --- a/src/test/run-pass/repeated-vector-syntax.rs +++ b/src/test/run-pass/repeated-vector-syntax.rs @@ -10,11 +10,6 @@ #![feature(managed_boxes)] -#[deriving(Clone)] -struct Foo { - a: ~str, -} - pub fn main() { let x = [ [true], ..512 ]; let y = [ 0, ..1 ]; diff --git a/src/test/run-pass/ret-bang.rs b/src/test/run-pass/ret-bang.rs index 23b40972cde7..fab8998afbe7 100644 --- a/src/test/run-pass/ret-bang.rs +++ b/src/test/run-pass/ret-bang.rs @@ -11,10 +11,14 @@ -fn my_err(s: ~str) -> ! { println!("{:?}", s); fail!(); } +fn my_err(s: StrBuf) -> ! { println!("{}", s); fail!(); } fn okay(i: uint) -> int { - if i == 3u { my_err("I don't like three".to_owned()); } else { return 42; } + if i == 3u { + my_err("I don't like three".to_strbuf()); + } else { + return 42; + } } pub fn main() { okay(4u); } diff --git a/src/test/run-pass/send_str_treemap.rs b/src/test/run-pass/send_str_treemap.rs index e4a935eae7f4..b6dcf06cae04 100644 --- a/src/test/run-pass/send_str_treemap.rs +++ b/src/test/run-pass/send_str_treemap.rs @@ -61,8 +61,8 @@ pub fn main() { assert_eq!(map.find(&Owned("def".to_owned())), Some(&d)); assert!(map.pop(&Slice("foo")).is_some()); - assert_eq!(map.move_iter().map(|(k, v)| k.to_str() + v.to_str()) - .collect::>() + assert_eq!(map.move_iter().map(|(k, v)| format_strbuf!("{}{}", k, v)) + .collect::>() .concat(), "abc50bcd51cde52def53".to_owned()); } diff --git a/src/test/run-pass/shape_intrinsic_tag_then_rec.rs b/src/test/run-pass/shape_intrinsic_tag_then_rec.rs index e0a0a7357fcd..7f5e92e71f2f 100644 --- a/src/test/run-pass/shape_intrinsic_tag_then_rec.rs +++ b/src/test/run-pass/shape_intrinsic_tag_then_rec.rs @@ -41,7 +41,7 @@ type ty_ = uint; #[deriving(Clone)] struct Path_ { global: bool, - idents: Vec<~str> , + idents: Vec , types: Vec<@ty>, } @@ -59,7 +59,7 @@ pub fn main() { let t: @ty = @Spanned { data: 3u, span: sp }; let p_: Path_ = Path_ { global: true, - idents: vec!("hi".to_owned()), + idents: vec!("hi".to_strbuf()), types: vec!(t), }; let p: path = Spanned { data: p_, span: sp }; diff --git a/src/test/run-pass/spawn-fn.rs b/src/test/run-pass/spawn-fn.rs index 17427be0597d..dff99cbe366b 100644 --- a/src/test/run-pass/spawn-fn.rs +++ b/src/test/run-pass/spawn-fn.rs @@ -10,15 +10,19 @@ use std::task; -fn x(s: ~str, n: int) { +fn x(s: StrBuf, n: int) { println!("{:?}", s); println!("{:?}", n); } pub fn main() { - task::spawn(proc() x("hello from first spawned fn".to_owned(), 65) ); - task::spawn(proc() x("hello from second spawned fn".to_owned(), 66) ); - task::spawn(proc() x("hello from third spawned fn".to_owned(), 67) ); + task::spawn(proc() x("hello from first spawned fn".to_strbuf(), 65) ); + task::spawn(proc() x("hello from second spawned fn".to_strbuf(), 66) ); + task::spawn(proc() x("hello from third spawned fn".to_strbuf(), 67) ); let mut i: int = 30; - while i > 0 { i = i - 1; println!("parent sleeping"); task::deschedule(); } + while i > 0 { + i = i - 1; + println!("parent sleeping"); + task::deschedule(); + } } diff --git a/src/test/run-pass/spawn-types.rs b/src/test/run-pass/spawn-types.rs index 830dce1d3cb2..b2fc1d272e8c 100644 --- a/src/test/run-pass/spawn-types.rs +++ b/src/test/run-pass/spawn-types.rs @@ -18,11 +18,11 @@ use std::task; type ctx = Sender; -fn iotask(_tx: &ctx, ip: ~str) { - assert_eq!(ip, "localhost".to_owned()); +fn iotask(_tx: &ctx, ip: StrBuf) { + assert_eq!(ip, "localhost".to_strbuf()); } pub fn main() { let (tx, _rx) = channel::(); - task::spawn(proc() iotask(&tx, "localhost".to_owned()) ); + task::spawn(proc() iotask(&tx, "localhost".to_strbuf()) ); } diff --git a/src/test/run-pass/static-impl.rs b/src/test/run-pass/static-impl.rs index 9eb04d5dac12..2bf3510bce1b 100644 --- a/src/test/run-pass/static-impl.rs +++ b/src/test/run-pass/static-impl.rs @@ -21,16 +21,18 @@ mod a { mod b { use plus; - impl plus for ~str { fn plus(&self) -> int { 200 } } + impl plus for StrBuf { fn plus(&self) -> int { 200 } } } trait uint_utils { - fn str(&self) -> ~str; + fn str(&self) -> StrBuf; fn multi(&self, f: |uint|); } impl uint_utils for uint { - fn str(&self) -> ~str { self.to_str() } + fn str(&self) -> StrBuf { + self.to_str().to_strbuf() + } fn multi(&self, f: |uint|) { let mut c = 0u; while c < *self { f(c); c += 1u; } @@ -57,9 +59,9 @@ impl vec_utils for Vec { pub fn main() { assert_eq!(10u.plus(), 30); - assert_eq!(("hi".to_owned()).plus(), 200); + assert_eq!(("hi".to_strbuf()).plus(), 200); - assert_eq!((vec!(1)).length_().str(), "1".to_owned()); + assert_eq!((vec!(1)).length_().str(), "1".to_strbuf()); let vect = vec!(3, 4).map_(|a| *a + 4); assert_eq!(*vect.get(0), 7); let vect = (vec!(3, 4)).map_::(|a| *a as uint + 4u); diff --git a/src/test/run-pass/static-method-xcrate.rs b/src/test/run-pass/static-method-xcrate.rs index 3c482d2f91bf..7cf1a15ab3ec 100644 --- a/src/test/run-pass/static-method-xcrate.rs +++ b/src/test/run-pass/static-method-xcrate.rs @@ -15,8 +15,8 @@ extern crate static_methods_crate; use static_methods_crate::read; pub fn main() { - let result: int = read("5".to_owned()); + let result: int = read("5".to_strbuf()); assert_eq!(result, 5); - assert_eq!(read::readMaybe("false".to_owned()), Some(false)); - assert_eq!(read::readMaybe("foo".to_owned()), None::); + assert_eq!(read::readMaybe("false".to_strbuf()), Some(false)); + assert_eq!(read::readMaybe("foo".to_strbuf()), None::); } diff --git a/src/test/run-pass/str-concat.rs b/src/test/run-pass/str-concat.rs index 7fcf54bf26b1..cecde7f8838d 100644 --- a/src/test/run-pass/str-concat.rs +++ b/src/test/run-pass/str-concat.rs @@ -12,9 +12,9 @@ pub fn main() { - let a: ~str = "hello".to_owned(); - let b: ~str = "world".to_owned(); - let s: ~str = a + b; + let a: StrBuf = "hello".to_strbuf(); + let b: StrBuf = "world".to_strbuf(); + let s: StrBuf = format_strbuf!("{}{}", a, b); println!("{}", s.clone()); - assert_eq!(s[9], 'd' as u8); + assert_eq!(s.as_slice()[9], 'd' as u8); } diff --git a/src/test/run-pass/str-multiline.rs b/src/test/run-pass/str-multiline.rs index fd74237c50d4..e42c89e67f4e 100644 --- a/src/test/run-pass/str-multiline.rs +++ b/src/test/run-pass/str-multiline.rs @@ -9,13 +9,13 @@ // except according to those terms. pub fn main() { - let a: ~str = "this \ -is a test".to_owned(); - let b: ~str = + let a: StrBuf = "this \ +is a test".to_strbuf(); + let b: StrBuf = "this \ is \ another \ - test".to_owned(); - assert_eq!(a, "this is a test".to_owned()); - assert_eq!(b, "this is another test".to_owned()); + test".to_strbuf(); + assert_eq!(a, "this is a test".to_strbuf()); + assert_eq!(b, "this is another test".to_strbuf()); } diff --git a/src/test/run-pass/string-self-append.rs b/src/test/run-pass/string-self-append.rs index 8a5d2d83ac64..619ee761e9c6 100644 --- a/src/test/run-pass/string-self-append.rs +++ b/src/test/run-pass/string-self-append.rs @@ -10,13 +10,13 @@ pub fn main() { // Make sure we properly handle repeated self-appends. - let mut a: ~str = "A".to_owned(); + let mut a: StrBuf = "A".to_strbuf(); let mut i = 20; let mut expected_len = 1u; while i > 0 { println!("{}", a.len()); assert_eq!(a.len(), expected_len); - a = a + a; // FIXME(#3387)---can't write a += a + a = format_strbuf!("{}{}", a, a); i -= 1; expected_len *= 2u; } diff --git a/src/test/run-pass/struct-literal-dtor.rs b/src/test/run-pass/struct-literal-dtor.rs index d4c7f951b4e8..6f1eec8346a9 100644 --- a/src/test/run-pass/struct-literal-dtor.rs +++ b/src/test/run-pass/struct-literal-dtor.rs @@ -9,7 +9,7 @@ // except according to those terms. struct foo { - x: ~str, + x: StrBuf, } impl Drop for foo { @@ -19,5 +19,7 @@ impl Drop for foo { } pub fn main() { - let _z = foo { x: "Hello".to_owned() }; + let _z = foo { + x: "Hello".to_strbuf() + }; } diff --git a/src/test/run-pass/struct-order-of-eval-1.rs b/src/test/run-pass/struct-order-of-eval-1.rs index cba4d337f299..e48ad05ef582 100644 --- a/src/test/run-pass/struct-order-of-eval-1.rs +++ b/src/test/run-pass/struct-order-of-eval-1.rs @@ -8,9 +8,15 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -struct S { f0: ~str, f1: int } +struct S { f0: StrBuf, f1: int } pub fn main() { - let s = "Hello, world!".to_owned(); - let _s = S { f0: s.to_owned(), ..S { f0: s, f1: 23 } }; + let s = "Hello, world!".to_strbuf(); + let _s = S { + f0: s.to_strbuf(), + ..S { + f0: s, + f1: 23 + } + }; } diff --git a/src/test/run-pass/struct-order-of-eval-2.rs b/src/test/run-pass/struct-order-of-eval-2.rs index d93252381780..9b2414325a58 100644 --- a/src/test/run-pass/struct-order-of-eval-2.rs +++ b/src/test/run-pass/struct-order-of-eval-2.rs @@ -8,9 +8,15 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -struct S { f0: ~str, f1: ~str } +struct S { + f0: StrBuf, + f1: StrBuf, +} pub fn main() { - let s = "Hello, world!".to_owned(); - let _s = S { f1: s.to_owned(), f0: s }; + let s = "Hello, world!".to_strbuf(); + let _s = S { + f1: s.to_strbuf(), + f0: s + }; } diff --git a/src/test/run-pass/swap-overlapping.rs b/src/test/run-pass/swap-overlapping.rs index 2e10c9347784..706f5787c4e5 100644 --- a/src/test/run-pass/swap-overlapping.rs +++ b/src/test/run-pass/swap-overlapping.rs @@ -15,7 +15,7 @@ use std::ptr; pub fn main() { let mut test = TestDescAndFn { desc: TestDesc { - name: DynTestName("test".to_owned()), + name: DynTestName("test".to_strbuf()), should_fail: false }, testfn: DynTestFn(proc() ()), @@ -30,7 +30,7 @@ fn do_swap(test: &mut TestDescAndFn) { } pub enum TestName { - DynTestName(~str) + DynTestName(StrBuf) } pub enum TestFn { diff --git a/src/test/run-pass/syntax-extension-source-utils.rs b/src/test/run-pass/syntax-extension-source-utils.rs index a50c447f0ebb..017b17d0e9c2 100644 --- a/src/test/run-pass/syntax-extension-source-utils.rs +++ b/src/test/run-pass/syntax-extension-source-utils.rs @@ -15,7 +15,7 @@ pub mod m1 { pub mod m2 { - pub fn where_am_i() -> ~str { (module_path!()).to_owned() } + pub fn where_am_i() -> StrBuf { (module_path!()).to_strbuf() } } } @@ -26,16 +26,19 @@ pub fn main() { //assert!((col!() == 11)); assert_eq!(indirect_line!(), 27); assert!((file!().to_owned().ends_with("syntax-extension-source-utils.rs"))); - assert_eq!(stringify!((2*3) + 5).to_owned(), "( 2 * 3 ) + 5".to_owned()); - assert!(include!("syntax-extension-source-utils-files/includeme.fragment").to_owned() - == "victory robot 6".to_owned()); + assert_eq!(stringify!((2*3) + 5).to_strbuf(), "( 2 * 3 ) + 5".to_strbuf()); + assert!(include!("syntax-extension-source-utils-files/includeme.\ + fragment").to_strbuf() + == "victory robot 6".to_strbuf()); assert!( - include_str!("syntax-extension-source-utils-files/includeme.fragment").to_owned() + include_str!("syntax-extension-source-utils-files/includeme.\ + fragment").to_strbuf() + .as_slice() .starts_with("/* this is for ")); assert!( include_bin!("syntax-extension-source-utils-files/includeme.fragment") [1] == (42 as u8)); // '*' // The Windows tests are wrapped in an extra module for some reason - assert!((m1::m2::where_am_i().ends_with("m1::m2"))); + assert!((m1::m2::where_am_i().as_slice().ends_with("m1::m2"))); } diff --git a/src/test/run-pass/tag-variant-disr-val.rs b/src/test/run-pass/tag-variant-disr-val.rs index e31b289f541a..40c5f6239868 100644 --- a/src/test/run-pass/tag-variant-disr-val.rs +++ b/src/test/run-pass/tag-variant-disr-val.rs @@ -27,17 +27,17 @@ impl Eq for color { } pub fn main() { - test_color(red, 0xff0000, "red".to_owned()); - test_color(green, 0x00ff00, "green".to_owned()); - test_color(blue, 0x0000ff, "blue".to_owned()); - test_color(black, 0x000000, "black".to_owned()); - test_color(white, 0xFFFFFF, "white".to_owned()); - test_color(imaginary, -1, "imaginary".to_owned()); - test_color(purple, 2, "purple".to_owned()); - test_color(orange, 4, "orange".to_owned()); + test_color(red, 0xff0000, "red".to_strbuf()); + test_color(green, 0x00ff00, "green".to_strbuf()); + test_color(blue, 0x0000ff, "blue".to_strbuf()); + test_color(black, 0x000000, "black".to_strbuf()); + test_color(white, 0xFFFFFF, "white".to_strbuf()); + test_color(imaginary, -1, "imaginary".to_strbuf()); + test_color(purple, 2, "purple".to_strbuf()); + test_color(orange, 4, "orange".to_strbuf()); } -fn test_color(color: color, val: int, name: ~str) { +fn test_color(color: color, val: int, name: StrBuf) { //assert!(unsafe::transmute(color) == val); assert_eq!(color as int, val); assert_eq!(color as f64, val as f64); @@ -45,27 +45,27 @@ fn test_color(color: color, val: int, name: ~str) { assert!(get_color_if(color) == name); } -fn get_color_alt(color: color) -> ~str { +fn get_color_alt(color: color) -> StrBuf { match color { - red => {"red".to_owned()} - green => {"green".to_owned()} - blue => {"blue".to_owned()} - black => {"black".to_owned()} - white => {"white".to_owned()} - imaginary => {"imaginary".to_owned()} - purple => {"purple".to_owned()} - orange => {"orange".to_owned()} + red => {"red".to_strbuf()} + green => {"green".to_strbuf()} + blue => {"blue".to_strbuf()} + black => {"black".to_strbuf()} + white => {"white".to_strbuf()} + imaginary => {"imaginary".to_strbuf()} + purple => {"purple".to_strbuf()} + orange => {"orange".to_strbuf()} } } -fn get_color_if(color: color) -> ~str { - if color == red {"red".to_owned()} - else if color == green {"green".to_owned()} - else if color == blue {"blue".to_owned()} - else if color == black {"black".to_owned()} - else if color == white {"white".to_owned()} - else if color == imaginary {"imaginary".to_owned()} - else if color == purple {"purple".to_owned()} - else if color == orange {"orange".to_owned()} - else {"unknown".to_owned()} +fn get_color_if(color: color) -> StrBuf { + if color == red {"red".to_strbuf()} + else if color == green {"green".to_strbuf()} + else if color == blue {"blue".to_strbuf()} + else if color == black {"black".to_strbuf()} + else if color == white {"white".to_strbuf()} + else if color == imaginary {"imaginary".to_strbuf()} + else if color == purple {"purple".to_strbuf()} + else if color == orange {"orange".to_strbuf()} + else {"unknown".to_strbuf()} } diff --git a/src/test/run-pass/tail-call-arg-leak.rs b/src/test/run-pass/tail-call-arg-leak.rs index fab5bb02afad..e90fe27823b6 100644 --- a/src/test/run-pass/tail-call-arg-leak.rs +++ b/src/test/run-pass/tail-call-arg-leak.rs @@ -12,6 +12,8 @@ // use of tail calls causes arg slot leaks, issue #160. -fn inner(dummy: ~str, b: bool) { if b { return inner(dummy, false); } } +fn inner(dummy: StrBuf, b: bool) { if b { return inner(dummy, false); } } -pub fn main() { inner("hi".to_owned(), true); } +pub fn main() { + inner("hi".to_strbuf(), true); +} diff --git a/src/test/run-pass/task-comm-10.rs b/src/test/run-pass/task-comm-10.rs index 9bd5110cccf9..b298f2edf010 100644 --- a/src/test/run-pass/task-comm-10.rs +++ b/src/test/run-pass/task-comm-10.rs @@ -11,18 +11,18 @@ use std::task; -fn start(tx: &Sender>) { +fn start(tx: &Sender>) { let (tx2, rx) = channel(); tx.send(tx2); let mut a; let mut b; a = rx.recv(); - assert!(a == "A".to_owned()); - println!("{:?}", a); + assert!(a == "A".to_strbuf()); + println!("{}", a); b = rx.recv(); - assert!(b == "B".to_owned()); - println!("{:?}", b); + assert!(b == "B".to_strbuf()); + println!("{}", b); } pub fn main() { @@ -30,7 +30,7 @@ pub fn main() { let _child = task::spawn(proc() { start(&tx) }); let mut c = rx.recv(); - c.send("A".to_owned()); - c.send("B".to_owned()); + c.send("A".to_strbuf()); + c.send("B".to_strbuf()); task::deschedule(); } diff --git a/src/test/run-pass/task-life-0.rs b/src/test/run-pass/task-life-0.rs index b0974676d07e..378effa8a189 100644 --- a/src/test/run-pass/task-life-0.rs +++ b/src/test/run-pass/task-life-0.rs @@ -11,9 +11,9 @@ use std::task; pub fn main() { - task::spawn(proc() child("Hello".to_owned()) ); + task::spawn(proc() child("Hello".to_strbuf()) ); } -fn child(_s: ~str) { +fn child(_s: StrBuf) { } diff --git a/src/test/run-pass/trait-bounds-in-arc.rs b/src/test/run-pass/trait-bounds-in-arc.rs index 0a6e5ce0b679..7f561a85349f 100644 --- a/src/test/run-pass/trait-bounds-in-arc.rs +++ b/src/test/run-pass/trait-bounds-in-arc.rs @@ -27,43 +27,54 @@ trait Pet { struct Catte { num_whiskers: uint, - name: ~str, + name: StrBuf, } struct Dogge { bark_decibels: uint, tricks_known: uint, - name: ~str, + name: StrBuf, } struct Goldfyshe { swim_speed: uint, - name: ~str, + name: StrBuf, } impl Pet for Catte { - fn name(&self, blk: |&str|) { blk(self.name) } + fn name(&self, blk: |&str|) { blk(self.name.as_slice()) } fn num_legs(&self) -> uint { 4 } fn of_good_pedigree(&self) -> bool { self.num_whiskers >= 4 } } impl Pet for Dogge { - fn name(&self, blk: |&str|) { blk(self.name) } + fn name(&self, blk: |&str|) { blk(self.name.as_slice()) } fn num_legs(&self) -> uint { 4 } fn of_good_pedigree(&self) -> bool { self.bark_decibels < 70 || self.tricks_known > 20 } } impl Pet for Goldfyshe { - fn name(&self, blk: |&str|) { blk(self.name) } + fn name(&self, blk: |&str|) { blk(self.name.as_slice()) } fn num_legs(&self) -> uint { 0 } fn of_good_pedigree(&self) -> bool { self.swim_speed >= 500 } } pub fn main() { - let catte = Catte { num_whiskers: 7, name: "alonzo_church".to_owned() }; - let dogge1 = Dogge { bark_decibels: 100, tricks_known: 42, name: "alan_turing".to_owned() }; - let dogge2 = Dogge { bark_decibels: 55, tricks_known: 11, name: "albert_einstein".to_owned() }; - let fishe = Goldfyshe { swim_speed: 998, name: "alec_guinness".to_owned() }; + let catte = Catte { num_whiskers: 7, name: "alonzo_church".to_strbuf() }; + let dogge1 = Dogge { + bark_decibels: 100, + tricks_known: 42, + name: "alan_turing".to_strbuf(), + }; + let dogge2 = Dogge { + bark_decibels: 55, + tricks_known: 11, + name: "albert_einstein".to_strbuf(), + }; + let fishe = Goldfyshe { + swim_speed: 998, + name: "alec_guinness".to_strbuf(), + }; let arc = Arc::new(vec!(box catte as Box, box dogge1 as Box, box fishe as Box, diff --git a/src/test/run-pass/trait-cast.rs b/src/test/run-pass/trait-cast.rs index 3d303bf1e5b3..d6aaefe868f3 100644 --- a/src/test/run-pass/trait-cast.rs +++ b/src/test/run-pass/trait-cast.rs @@ -22,33 +22,38 @@ struct TreeR { } trait to_str { - fn to_str_(&self) -> ~str; + fn to_str_(&self) -> StrBuf; } impl to_str for Option { - fn to_str_(&self) -> ~str { + fn to_str_(&self) -> StrBuf { match *self { - None => { "none".to_owned() } - Some(ref t) => { "some(".to_owned() + t.to_str_() + ")".to_owned() } + None => { "none".to_strbuf() } + Some(ref t) => format_strbuf!("some({})", t.to_str_()), } } } impl to_str for int { - fn to_str_(&self) -> ~str { self.to_str() } + fn to_str_(&self) -> StrBuf { + self.to_str().to_strbuf() + } } impl to_str for Tree { - fn to_str_(&self) -> ~str { + fn to_str_(&self) -> StrBuf { let Tree(t) = *self; let this = t.borrow(); let (l, r) = (this.left, this.right); let val = &this.val; - format!("[{}, {}, {}]", val.to_str_(), l.to_str_(), r.to_str_()) + format_strbuf!("[{}, {}, {}]", + val.to_str_(), + l.to_str_(), + r.to_str_()) } } -fn foo(x: T) -> ~str { x.to_str_() } +fn foo(x: T) -> StrBuf { x.to_str_() } pub fn main() { let t1 = Tree(@RefCell::new(TreeR{left: None, @@ -57,7 +62,8 @@ pub fn main() { let t2 = Tree(@RefCell::new(TreeR{left: Some(t1), right: Some(t1), val: box 2 as Box})); - let expected = "[2, some([1, none, none]), some([1, none, none])]".to_owned(); + let expected = + "[2, some([1, none, none]), some([1, none, none])]".to_strbuf(); assert!(t2.to_str_() == expected); assert!(foo(t2) == expected); diff --git a/src/test/run-pass/trait-generic.rs b/src/test/run-pass/trait-generic.rs index 4b745ba5e3ee..269c1d4094eb 100644 --- a/src/test/run-pass/trait-generic.rs +++ b/src/test/run-pass/trait-generic.rs @@ -11,16 +11,16 @@ trait to_str { - fn to_string(&self) -> ~str; + fn to_string(&self) -> StrBuf; } impl to_str for int { - fn to_string(&self) -> ~str { self.to_str() } + fn to_string(&self) -> StrBuf { self.to_str().to_strbuf() } } -impl to_str for ~str { - fn to_string(&self) -> ~str { self.clone() } +impl to_str for StrBuf { + fn to_string(&self) -> StrBuf { self.clone() } } impl to_str for () { - fn to_string(&self) -> ~str { "()".to_owned() } + fn to_string(&self) -> StrBuf { "()".to_strbuf() } } trait map { @@ -37,17 +37,17 @@ impl map for Vec { } } -fn foo>(x: T) -> Vec<~str> { - x.map(|_e| "hi".to_owned() ) +fn foo>(x: T) -> Vec { + x.map(|_e| "hi".to_strbuf() ) } -fn bar>(x: T) -> Vec<~str> { +fn bar>(x: T) -> Vec { x.map(|_e| _e.to_string() ) } pub fn main() { - assert_eq!(foo(vec!(1)), vec!("hi".to_owned())); - assert_eq!(bar:: >(vec!(4, 5)), vec!("4".to_owned(), "5".to_owned())); - assert_eq!(bar::<~str, Vec<~str> >(vec!("x".to_owned(), "y".to_owned())), - vec!("x".to_owned(), "y".to_owned())); - assert_eq!(bar::<(), Vec<()>>(vec!(())), vec!("()".to_owned())); + assert_eq!(foo(vec!(1)), vec!("hi".to_strbuf())); + assert_eq!(bar:: >(vec!(4, 5)), vec!("4".to_strbuf(), "5".to_strbuf())); + assert_eq!(bar:: >(vec!("x".to_strbuf(), "y".to_strbuf())), + vec!("x".to_strbuf(), "y".to_strbuf())); + assert_eq!(bar::<(), Vec<()>>(vec!(())), vec!("()".to_strbuf())); } diff --git a/src/test/run-pass/trait-to-str.rs b/src/test/run-pass/trait-to-str.rs index 794f810165dc..5d22199e4a54 100644 --- a/src/test/run-pass/trait-to-str.rs +++ b/src/test/run-pass/trait-to-str.rs @@ -11,30 +11,34 @@ trait to_str { - fn to_string(&self) -> ~str; + fn to_string(&self) -> StrBuf; } impl to_str for int { - fn to_string(&self) -> ~str { self.to_str() } + fn to_string(&self) -> StrBuf { self.to_str().to_strbuf() } } impl to_str for Vec { - fn to_string(&self) -> ~str { - format!("[{}]", self.iter().map(|e| e.to_string()).collect::>().connect(", ")) + fn to_string(&self) -> StrBuf { + format_strbuf!("[{}]", + self.iter() + .map(|e| e.to_string()) + .collect::>() + .connect(", ")) } } pub fn main() { - assert!(1.to_string() == "1".to_owned()); - assert!((vec!(2, 3, 4)).to_string() == "[2, 3, 4]".to_owned()); + assert!(1.to_string() == "1".to_strbuf()); + assert!((vec!(2, 3, 4)).to_string() == "[2, 3, 4]".to_strbuf()); - fn indirect(x: T) -> ~str { - x.to_string() + "!" + fn indirect(x: T) -> StrBuf { + format_strbuf!("{}!", x.to_string()) } - assert!(indirect(vec!(10, 20)) == "[10, 20]!".to_owned()); + assert!(indirect(vec!(10, 20)) == "[10, 20]!".to_strbuf()); - fn indirect2(x: T) -> ~str { + fn indirect2(x: T) -> StrBuf { indirect(x) } - assert!(indirect2(vec!(1)) == "[1]!".to_owned()); + assert!(indirect2(vec!(1)) == "[1]!".to_strbuf()); } diff --git a/src/test/run-pass/traits-default-method-macro.rs b/src/test/run-pass/traits-default-method-macro.rs index 2a60e774645f..db5be5f938ae 100644 --- a/src/test/run-pass/traits-default-method-macro.rs +++ b/src/test/run-pass/traits-default-method-macro.rs @@ -10,8 +10,8 @@ trait Foo { - fn bar(&self) -> ~str { - format!("test") + fn bar(&self) -> StrBuf { + format_strbuf!("test") } } @@ -24,5 +24,5 @@ impl Foo for Baz { pub fn main() { let q = Quux; - assert_eq!(q.bar(), "test".to_owned()); + assert_eq!(q.bar(), "test".to_strbuf()); } diff --git a/src/test/run-pass/utf8.rs b/src/test/run-pass/utf8.rs index debb1c3812a8..a12483c1d781 100644 --- a/src/test/run-pass/utf8.rs +++ b/src/test/run-pass/utf8.rs @@ -24,27 +24,27 @@ pub fn main() { assert_eq!(pi as int, '\u03a0' as int); assert_eq!('\x0a' as int, '\n' as int); - let bhutan: ~str = "འབྲུག་ཡུལ།".to_owned(); - let japan: ~str = "日本".to_owned(); - let uzbekistan: ~str = "Ўзбекистон".to_owned(); - let austria: ~str = "Österreich".to_owned(); - - let bhutan_e: ~str = - "\u0f60\u0f56\u0fb2\u0f74\u0f42\u0f0b\u0f61\u0f74\u0f63\u0f0d".to_owned(); - let japan_e: ~str = "\u65e5\u672c".to_owned(); - let uzbekistan_e: ~str = - "\u040e\u0437\u0431\u0435\u043a\u0438\u0441\u0442\u043e\u043d".to_owned(); - let austria_e: ~str = "\u00d6sterreich".to_owned(); + let bhutan: StrBuf = "འབྲུག་ཡུལ།".to_strbuf(); + let japan: StrBuf = "日本".to_strbuf(); + let uzbekistan: StrBuf = "Ўзбекистон".to_strbuf(); + let austria: StrBuf = "Österreich".to_strbuf(); + + let bhutan_e: StrBuf = + "\u0f60\u0f56\u0fb2\u0f74\u0f42\u0f0b\u0f61\u0f74\u0f63\u0f0d".to_strbuf(); + let japan_e: StrBuf = "\u65e5\u672c".to_strbuf(); + let uzbekistan_e: StrBuf = + "\u040e\u0437\u0431\u0435\u043a\u0438\u0441\u0442\u043e\u043d".to_strbuf(); + let austria_e: StrBuf = "\u00d6sterreich".to_strbuf(); let oo: char = 'Ö'; assert_eq!(oo as int, 0xd6); - fn check_str_eq(a: ~str, b: ~str) { + fn check_str_eq(a: StrBuf, b: StrBuf) { let mut i: int = 0; - for ab in a.bytes() { + for ab in a.as_slice().bytes() { println!("{}", i); println!("{}", ab); - let bb: u8 = b[i as uint]; + let bb: u8 = b.as_slice()[i as uint]; println!("{}", bb); assert_eq!(ab, bb); i += 1; diff --git a/src/test/run-pass/utf8_chars.rs b/src/test/run-pass/utf8_chars.rs index a418cd0ae022..2e0e1af43b4e 100644 --- a/src/test/run-pass/utf8_chars.rs +++ b/src/test/run-pass/utf8_chars.rs @@ -13,15 +13,15 @@ use std::str; pub fn main() { // Chars of 1, 2, 3, and 4 bytes let chs: Vec = vec!('e', 'é', '€', '\U00010000'); - let s: ~str = str::from_chars(chs.as_slice()); - let schs: Vec = s.chars().collect(); + let s: StrBuf = str::from_chars(chs.as_slice()).to_strbuf(); + let schs: Vec = s.as_slice().chars().collect(); assert!(s.len() == 10u); - assert!(s.char_len() == 4u); + assert!(s.as_slice().char_len() == 4u); assert!(schs.len() == 4u); - assert!(str::from_chars(schs.as_slice()) == s); - assert!(s.char_at(0u) == 'e'); - assert!(s.char_at(1u) == 'é'); + assert!(str::from_chars(schs.as_slice()).to_strbuf() == s); + assert!(s.as_slice().char_at(0u) == 'e'); + assert!(s.as_slice().char_at(1u) == 'é'); assert!((str::is_utf8(s.as_bytes()))); // invalid prefix diff --git a/src/test/run-pass/variant-attributes.rs b/src/test/run-pass/variant-attributes.rs index 2b200c8af308..e26c592a0648 100644 --- a/src/test/run-pass/variant-attributes.rs +++ b/src/test/run-pass/variant-attributes.rs @@ -34,6 +34,6 @@ enum crew_of_enterprise_d { geordi_la_forge, } -fn boldly_go(_crew_member: crew_of_enterprise_d, _where: ~str) { } +fn boldly_go(_crew_member: crew_of_enterprise_d, _where: StrBuf) { } -pub fn main() { boldly_go(worf, "where no one has gone before".to_owned()); } +pub fn main() { boldly_go(worf, "where no one has gone before".to_strbuf()); } diff --git a/src/test/run-pass/vec-tail-matching.rs b/src/test/run-pass/vec-tail-matching.rs index 0703955f2116..8d2f29d9b097 100644 --- a/src/test/run-pass/vec-tail-matching.rs +++ b/src/test/run-pass/vec-tail-matching.rs @@ -10,29 +10,29 @@ struct Foo { - string: ~str + string: StrBuf } pub fn main() { let x = [ - Foo { string: "foo".to_owned() }, - Foo { string: "bar".to_owned() }, - Foo { string: "baz".to_owned() } + Foo { string: "foo".to_strbuf() }, + Foo { string: "bar".to_strbuf() }, + Foo { string: "baz".to_strbuf() } ]; match x { [ref first, ..tail] => { - assert!(first.string == "foo".to_owned()); + assert!(first.string == "foo".to_strbuf()); assert_eq!(tail.len(), 2); - assert!(tail[0].string == "bar".to_owned()); - assert!(tail[1].string == "baz".to_owned()); + assert!(tail[0].string == "bar".to_strbuf()); + assert!(tail[1].string == "baz".to_strbuf()); match tail { [Foo { .. }, _, Foo { .. }, .. _tail] => { unreachable!(); } [Foo { string: ref a }, Foo { string: ref b }] => { - assert_eq!("bar", a.slice(0, a.len())); - assert_eq!("baz", b.slice(0, b.len())); + assert_eq!("bar", a.as_slice().slice(0, a.len())); + assert_eq!("baz", b.as_slice().slice(0, b.len())); } _ => { unreachable!();