// Pretty-printer does not work with .rc files yet
let valid_extensions =
match config.mode {
- Pretty => vec!(".rs".to_owned()),
- _ => vec!(".rc".to_owned(), ".rs".to_owned())
+ Pretty => vec!(".rs".to_string()),
+ _ => vec!(".rc".to_string(), ".rs".to_string())
};
- let invalid_prefixes = vec!(".".to_owned(), "#".to_owned(), "~".to_owned());
+ let invalid_prefixes = vec!(".".to_string(), "#".to_string(), "~".to_string());
let name = testfile.filename_str().unwrap();
let mut valid = false;
let aux_dir = aux_output_dir_name(config, testfile);
// FIXME (#9639): This needs to handle non-utf8 paths
- let extra_link_args = vec!("-L".to_owned(), aux_dir.as_str().unwrap().to_owned());
+ let extra_link_args = vec!("-L".to_string(), aux_dir.as_str().unwrap().to_owned());
for rel_ab in props.aux_builds.iter() {
let abs_ab = config.aux_base.join(rel_ab.as_slice());
procedure:
```rust
-let string = "Hello".to_owned();
+let string = "Hello".to_string();
// Creates a new procedure, passing it to the `spawn` function.
spawn(proc() {
#[test]
fn test_to_str() {
let zerolen = Bitv::new(0u, false);
- assert_eq!(zerolen.to_str(), "".to_owned());
+ assert_eq!(zerolen.to_str(), "".to_string());
let eightbits = Bitv::new(8u, false);
- assert_eq!(eightbits.to_str(), "00000000".to_owned());
+ assert_eq!(eightbits.to_str(), "00000000".to_string());
}
#[test]
let mut b = bitv::Bitv::new(2, false);
b.set(0, true);
b.set(1, false);
- assert_eq!(b.to_str(), "10".to_owned());
+ assert_eq!(b.to_str(), "10".to_string());
}
#[test]
#[test]
fn test_from_bools() {
assert!(from_bools([true, false, true, true]).to_str() ==
- "1011".to_owned());
+ "1011".to_string());
}
#[test]
//Tests the functionality of the insert methods (which are unfinished).
#[test]
fn insert_test_one() {
- let b = BTree::new(1, "abc".to_owned(), 2);
- let is_insert = b.insert(2, "xyz".to_owned());
+ let b = BTree::new(1, "abc".to_string(), 2);
+ let is_insert = b.insert(2, "xyz".to_string());
//println!("{}", is_insert.clone().to_str());
assert!(is_insert.root.is_leaf());
}
#[test]
fn insert_test_two() {
- let leaf_elt_1 = LeafElt::new(1, "aaa".to_owned());
- let leaf_elt_2 = LeafElt::new(2, "bbb".to_owned());
- let leaf_elt_3 = LeafElt::new(3, "ccc".to_owned());
+ let leaf_elt_1 = LeafElt::new(1, "aaa".to_string());
+ let leaf_elt_2 = LeafElt::new(2, "bbb".to_string());
+ let leaf_elt_3 = LeafElt::new(3, "ccc".to_string());
let n = Node::new_leaf(vec!(leaf_elt_1, leaf_elt_2, leaf_elt_3));
let b = BTree::new_with_node_len(n, 3, 2);
- //println!("{}", b.clone().insert(4, "ddd".to_owned()).to_str());
- assert!(b.insert(4, "ddd".to_owned()).root.is_leaf());
+ //println!("{}", b.clone().insert(4, "ddd".to_string()).to_str());
+ assert!(b.insert(4, "ddd".to_string()).root.is_leaf());
}
#[test]
fn insert_test_three() {
- let leaf_elt_1 = LeafElt::new(1, "aaa".to_owned());
- let leaf_elt_2 = LeafElt::new(2, "bbb".to_owned());
- let leaf_elt_3 = LeafElt::new(3, "ccc".to_owned());
- let leaf_elt_4 = LeafElt::new(4, "ddd".to_owned());
+ let leaf_elt_1 = LeafElt::new(1, "aaa".to_string());
+ let leaf_elt_2 = LeafElt::new(2, "bbb".to_string());
+ let leaf_elt_3 = LeafElt::new(3, "ccc".to_string());
+ let leaf_elt_4 = LeafElt::new(4, "ddd".to_string());
let n = Node::new_leaf(vec!(leaf_elt_1, leaf_elt_2, leaf_elt_3, leaf_elt_4));
let b = BTree::new_with_node_len(n, 3, 2);
- //println!("{}", b.clone().insert(5, "eee".to_owned()).to_str());
- assert!(!b.insert(5, "eee".to_owned()).root.is_leaf());
+ //println!("{}", b.clone().insert(5, "eee".to_string()).to_str());
+ assert!(!b.insert(5, "eee".to_string()).root.is_leaf());
}
#[test]
fn insert_test_four() {
- let leaf_elt_1 = LeafElt::new(1, "aaa".to_owned());
- let leaf_elt_2 = LeafElt::new(2, "bbb".to_owned());
- let leaf_elt_3 = LeafElt::new(3, "ccc".to_owned());
- let leaf_elt_4 = LeafElt::new(4, "ddd".to_owned());
+ let leaf_elt_1 = LeafElt::new(1, "aaa".to_string());
+ let leaf_elt_2 = LeafElt::new(2, "bbb".to_string());
+ let leaf_elt_3 = LeafElt::new(3, "ccc".to_string());
+ let leaf_elt_4 = LeafElt::new(4, "ddd".to_string());
let n = Node::new_leaf(vec!(leaf_elt_1, leaf_elt_2, leaf_elt_3, leaf_elt_4));
let mut b = BTree::new_with_node_len(n, 3, 2);
- b = b.clone().insert(5, "eee".to_owned());
- b = b.clone().insert(6, "fff".to_owned());
- b = b.clone().insert(7, "ggg".to_owned());
- b = b.clone().insert(8, "hhh".to_owned());
- b = b.clone().insert(0, "omg".to_owned());
+ b = b.clone().insert(5, "eee".to_string());
+ b = b.clone().insert(6, "fff".to_string());
+ b = b.clone().insert(7, "ggg".to_string());
+ b = b.clone().insert(8, "hhh".to_string());
+ b = b.clone().insert(0, "omg".to_string());
//println!("{}", b.clone().to_str());
assert!(!b.root.is_leaf());
}
#[test]
fn bsearch_test_one() {
- let b = BTree::new(1, "abc".to_owned(), 2);
+ let b = BTree::new(1, "abc".to_string(), 2);
assert_eq!(Some(1), b.root.bsearch_node(2));
}
#[test]
fn bsearch_test_two() {
- let b = BTree::new(1, "abc".to_owned(), 2);
+ let b = BTree::new(1, "abc".to_string(), 2);
assert_eq!(Some(0), b.root.bsearch_node(0));
}
#[test]
fn bsearch_test_three() {
- let leaf_elt_1 = LeafElt::new(1, "aaa".to_owned());
- let leaf_elt_2 = LeafElt::new(2, "bbb".to_owned());
- let leaf_elt_3 = LeafElt::new(4, "ccc".to_owned());
- let leaf_elt_4 = LeafElt::new(5, "ddd".to_owned());
+ let leaf_elt_1 = LeafElt::new(1, "aaa".to_string());
+ let leaf_elt_2 = LeafElt::new(2, "bbb".to_string());
+ let leaf_elt_3 = LeafElt::new(4, "ccc".to_string());
+ let leaf_elt_4 = LeafElt::new(5, "ddd".to_string());
let n = Node::new_leaf(vec!(leaf_elt_1, leaf_elt_2, leaf_elt_3, leaf_elt_4));
let b = BTree::new_with_node_len(n, 3, 2);
assert_eq!(Some(2), b.root.bsearch_node(3));
#[test]
fn bsearch_test_four() {
- let leaf_elt_1 = LeafElt::new(1, "aaa".to_owned());
- let leaf_elt_2 = LeafElt::new(2, "bbb".to_owned());
- let leaf_elt_3 = LeafElt::new(4, "ccc".to_owned());
- let leaf_elt_4 = LeafElt::new(5, "ddd".to_owned());
+ let leaf_elt_1 = LeafElt::new(1, "aaa".to_string());
+ let leaf_elt_2 = LeafElt::new(2, "bbb".to_string());
+ let leaf_elt_3 = LeafElt::new(4, "ccc".to_string());
+ let leaf_elt_4 = LeafElt::new(5, "ddd".to_string());
let n = Node::new_leaf(vec!(leaf_elt_1, leaf_elt_2, leaf_elt_3, leaf_elt_4));
let b = BTree::new_with_node_len(n, 3, 2);
assert_eq!(Some(4), b.root.bsearch_node(800));
//Tests the functionality of the get method.
#[test]
fn get_test() {
- let b = BTree::new(1, "abc".to_owned(), 2);
+ let b = BTree::new(1, "abc".to_string(), 2);
let val = b.get(1);
- assert_eq!(val, Some("abc".to_owned()));
+ assert_eq!(val, Some("abc".to_string()));
}
//Tests the BTree's clone() method.
#[test]
fn btree_clone_test() {
- let b = BTree::new(1, "abc".to_owned(), 2);
+ let b = BTree::new(1, "abc".to_string(), 2);
let b2 = b.clone();
assert!(b.root == b2.root)
}
//Tests the BTree's cmp() method when one node is "less than" another.
#[test]
fn btree_cmp_test_less() {
- let b = BTree::new(1, "abc".to_owned(), 2);
- let b2 = BTree::new(2, "bcd".to_owned(), 2);
+ let b = BTree::new(1, "abc".to_string(), 2);
+ let b2 = BTree::new(2, "bcd".to_string(), 2);
assert!(&b.cmp(&b2) == &Less)
}
//Tests the BTree's cmp() method when two nodes are equal.
#[test]
fn btree_cmp_test_eq() {
- let b = BTree::new(1, "abc".to_owned(), 2);
- let b2 = BTree::new(1, "bcd".to_owned(), 2);
+ let b = BTree::new(1, "abc".to_string(), 2);
+ let b2 = BTree::new(1, "bcd".to_string(), 2);
assert!(&b.cmp(&b2) == &Equal)
}
//Tests the BTree's cmp() method when one node is "greater than" another.
#[test]
fn btree_cmp_test_greater() {
- let b = BTree::new(1, "abc".to_owned(), 2);
- let b2 = BTree::new(2, "bcd".to_owned(), 2);
+ let b = BTree::new(1, "abc".to_string(), 2);
+ let b2 = BTree::new(2, "bcd".to_string(), 2);
assert!(&b2.cmp(&b) == &Greater)
}
//Tests the BTree's to_str() method.
#[test]
fn btree_tostr_test() {
- let b = BTree::new(1, "abc".to_owned(), 2);
- assert_eq!(b.to_str(), "Key: 1, value: abc;".to_owned())
+ let b = BTree::new(1, "abc".to_string(), 2);
+ assert_eq!(b.to_str(), "Key: 1, value: abc;".to_string())
}
}
let mut m = HashMap::new();
let (foo, bar, baz) = (1,2,3);
- m.insert("foo".to_owned(), foo);
- m.insert("bar".to_owned(), bar);
- m.insert("baz".to_owned(), baz);
+ m.insert("foo".to_string(), foo);
+ m.insert("bar".to_string(), bar);
+ m.insert("baz".to_string(), baz);
assert_eq!(m.find_equiv(&("foo")), Some(&foo));
let set_str = format!("{}", set);
- assert!(set_str == "{1, 2}".to_owned() || set_str == "{2, 1}".to_owned());
- assert_eq!(format!("{}", empty), "{}".to_owned());
+ assert!(set_str == "{1, 2}".to_string() || set_str == "{2, 1}".to_string());
+ assert_eq!(format!("{}", empty), "{}".to_string());
}
}
cache.put(1, 10);
cache.put(2, 20);
cache.put(3, 30);
- assert_eq!(cache.to_str(), "{3: 30, 2: 20, 1: 10}".to_owned());
+ assert_eq!(cache.to_str(), "{3: 30, 2: 20, 1: 10}".to_string());
cache.put(2, 22);
- assert_eq!(cache.to_str(), "{2: 22, 3: 30, 1: 10}".to_owned());
+ assert_eq!(cache.to_str(), "{2: 22, 3: 30, 1: 10}".to_string());
cache.put(6, 60);
- assert_eq!(cache.to_str(), "{6: 60, 2: 22, 3: 30}".to_owned());
+ assert_eq!(cache.to_str(), "{6: 60, 2: 22, 3: 30}".to_string());
cache.get(&3);
- assert_eq!(cache.to_str(), "{3: 30, 6: 60, 2: 22}".to_owned());
+ assert_eq!(cache.to_str(), "{3: 30, 6: 60, 2: 22}".to_string());
cache.change_capacity(2);
- assert_eq!(cache.to_str(), "{3: 30, 6: 60}".to_owned());
+ assert_eq!(cache.to_str(), "{3: 30, 6: 60}".to_string());
}
#[test]
cache.clear();
assert!(cache.get(&1).is_none());
assert!(cache.get(&2).is_none());
- assert_eq!(cache.to_str(), "{}".to_owned());
+ assert_eq!(cache.to_str(), "{}".to_string());
}
}
///
/// ~~~
/// use std::fmt::radix;
-/// assert_eq!(format!("{}", radix(55, 36)), "1j".to_owned());
+/// assert_eq!(format!("{}", radix(55, 36)), "1j".to_string());
/// ~~~
pub fn radix<T>(x: T, base: u8) -> RadixFmt<T, Radix> {
RadixFmt(x, Radix::new(base))
#[test]
fn test_replace() {
- let mut x = Some("test".to_owned());
+ let mut x = Some("test".to_string());
let y = replace(&mut x, None);
assert!(x.is_none());
assert!(y.is_some());
}
unsafe {
- assert!(Vec::from_slice([76u8]) == transmute("L".to_owned()));
+ assert!(Vec::from_slice([76u8]) == transmute("L".to_string()));
}
}
}
/// # Example
///
/// ```rust
- /// let mut v = ~["foo".to_owned(), "bar".to_owned(), "baz".to_owned()];
+ /// let mut v = ~["foo".to_string(), "bar".to_string(), "baz".to_string()];
///
/// unsafe {
- /// // `"baz".to_owned()` is deallocated.
- /// v.unsafe_set(2, "qux".to_owned());
+ /// // `"baz".to_string()` is deallocated.
+ /// v.unsafe_set(2, "qux".to_string());
///
/// // Out of bounds: could cause a crash, or overwriting
/// // other data, or something else.
- /// // v.unsafe_set(10, "oops".to_owned());
+ /// // v.unsafe_set(10, "oops".to_string());
/// }
/// ```
unsafe fn unsafe_set(self, index: uint, val: T);
/// # Example
///
/// ```rust
- /// let mut v = ["foo".to_owned(), "bar".to_owned()];
+ /// let mut v = ["foo".to_string(), "bar".to_string()];
///
- /// // memory leak! `"bar".to_owned()` is not deallocated.
- /// unsafe { v.init_elem(1, "baz".to_owned()); }
+ /// // memory leak! `"bar".to_string()` is not deallocated.
+ /// unsafe { v.init_elem(1, "baz".to_string()); }
/// ```
unsafe fn init_elem(self, i: uint, val: T);
each_split_within(desc_normalized_whitespace.as_slice(),
54,
|substr| {
- desc_rows.push(substr.to_owned());
+ desc_rows.push(substr.to_string());
true
});
assert_eq!(
test_wrapper("prog", ["aaa", "bbb", "ccc"]),
- "prog aaa bbb ccc".to_owned()
+ "prog aaa bbb ccc".to_string()
);
assert_eq!(
test_wrapper("C:\\Program Files\\blah\\blah.exe", ["aaa"]),
- "\"C:\\Program Files\\blah\\blah.exe\" aaa".to_owned()
+ "\"C:\\Program Files\\blah\\blah.exe\" aaa".to_string()
);
assert_eq!(
test_wrapper("C:\\Program Files\\test", ["aa\"bb"]),
- "\"C:\\Program Files\\test\" aa\\\"bb".to_owned()
+ "\"C:\\Program Files\\test\" aa\\\"bb".to_string()
);
assert_eq!(
test_wrapper("echo", ["a b c"]),
- "echo \"a b c\"".to_owned()
+ "echo \"a b c\"".to_string()
);
assert_eq!(
test_wrapper("\u03c0\u042f\u97f3\u00e6\u221e", []),
- "\u03c0\u042f\u97f3\u00e6\u221e".to_owned()
+ "\u03c0\u042f\u97f3\u00e6\u221e".to_string()
);
}
}
let vers = if vers.len() > 0 && !char::is_XID_start(vers.char_at(0)) {
format!("v{}", vers)
} else {
- vers.to_owned()
+ vers.to_string()
};
mangle(path, Some(hash), Some(vers.as_slice()))
}
let xs = [
- "the compiler hit an unexpected failure path. this is a bug.".to_owned(),
+ "the compiler hit an unexpected failure path. this is a bug.".to_string(),
format!("we would appreciate a bug report: {}",
BUG_REPORT_URL),
- "run with `RUST_BACKTRACE=1` for a backtrace".to_owned(),
+ "run with `RUST_BACKTRACE=1` for a backtrace".to_string(),
];
for note in xs.iter() {
emitter.emit(None, note.as_slice(), diagnostic::Note)
fn parse_abi_set(st: &mut PState) -> abi::Abi {
assert_eq!(next(st), '[');
scan(st, |c| c == ']', |bytes| {
- let abi_str = str::from_utf8(bytes).unwrap().to_owned();
+ let abi_str = str::from_utf8(bytes).unwrap().to_string();
abi::lookup(abi_str.as_slice()).expect(abi_str)
})
}
for (&name, import_resolution) in import_resolutions.iter() {
let value_repr;
match import_resolution.target_for_namespace(ValueNS) {
- None => { value_repr = "".to_owned(); }
+ None => { value_repr = "".to_string(); }
Some(_) => {
- value_repr = " value:?".to_owned();
+ value_repr = " value:?".to_string();
// FIXME #4954
}
}
let type_repr;
match import_resolution.target_for_namespace(TypeNS) {
- None => { type_repr = "".to_owned(); }
+ None => { type_repr = "".to_string(); }
Some(_) => {
- type_repr = " type:?".to_owned();
+ type_repr = " type:?".to_string();
// FIXME #4954
}
}
debug!("new_fn_ctxt(path={}, id={}, param_substs={})",
if id == -1 {
- "".to_owned()
+ "".to_string()
} else {
- ccx.tcx.map.path_to_str(id).to_owned()
+ ccx.tcx.map.path_to_str(id).to_string()
},
id, param_substs.map(|s| s.repr(ccx.tcx())));
debug!("basic_type_metadata: {:?}", ty::get(t));
let (name, encoding) = match ty::get(t).sty {
- ty::ty_nil => ("()".to_owned(), DW_ATE_unsigned),
- ty::ty_bot => ("!".to_owned(), DW_ATE_unsigned),
- ty::ty_bool => ("bool".to_owned(), DW_ATE_boolean),
- ty::ty_char => ("char".to_owned(), DW_ATE_unsigned_char),
+ ty::ty_nil => ("()".to_string(), DW_ATE_unsigned),
+ ty::ty_bot => ("!".to_string(), DW_ATE_unsigned),
+ ty::ty_bool => ("bool".to_string(), DW_ATE_boolean),
+ ty::ty_char => ("char".to_string(), DW_ATE_unsigned_char),
ty::ty_int(int_ty) => match int_ty {
- ast::TyI => ("int".to_owned(), DW_ATE_signed),
- ast::TyI8 => ("i8".to_owned(), DW_ATE_signed),
- ast::TyI16 => ("i16".to_owned(), DW_ATE_signed),
- ast::TyI32 => ("i32".to_owned(), DW_ATE_signed),
- ast::TyI64 => ("i64".to_owned(), DW_ATE_signed)
+ ast::TyI => ("int".to_string(), DW_ATE_signed),
+ ast::TyI8 => ("i8".to_string(), DW_ATE_signed),
+ ast::TyI16 => ("i16".to_string(), DW_ATE_signed),
+ ast::TyI32 => ("i32".to_string(), DW_ATE_signed),
+ ast::TyI64 => ("i64".to_string(), DW_ATE_signed)
},
ty::ty_uint(uint_ty) => match uint_ty {
- ast::TyU => ("uint".to_owned(), DW_ATE_unsigned),
- ast::TyU8 => ("u8".to_owned(), DW_ATE_unsigned),
- ast::TyU16 => ("u16".to_owned(), DW_ATE_unsigned),
- ast::TyU32 => ("u32".to_owned(), DW_ATE_unsigned),
- ast::TyU64 => ("u64".to_owned(), DW_ATE_unsigned)
+ ast::TyU => ("uint".to_string(), DW_ATE_unsigned),
+ ast::TyU8 => ("u8".to_string(), DW_ATE_unsigned),
+ ast::TyU16 => ("u16".to_string(), DW_ATE_unsigned),
+ ast::TyU32 => ("u32".to_string(), DW_ATE_unsigned),
+ ast::TyU64 => ("u64".to_string(), DW_ATE_unsigned)
},
ty::ty_float(float_ty) => match float_ty {
- ast::TyF32 => ("f32".to_owned(), DW_ATE_float),
- ast::TyF64 => ("f64".to_owned(), DW_ATE_float),
- ast::TyF128 => ("f128".to_owned(), DW_ATE_float)
+ ast::TyF32 => ("f32".to_string(), DW_ATE_float),
+ ast::TyF64 => ("f64".to_string(), DW_ATE_float),
+ ast::TyF128 => ("f128".to_string(), DW_ATE_float)
},
_ => cx.sess().bug("debuginfo::basic_type_metadata - t is invalid type")
};
ty::ty_rptr(_, ref mt) => {
match ty::get(mt.ty).sty {
ty::ty_vec(ref mt, None) => {
- let (name, extra) = ("slice".to_owned(), Vec::new());
+ let (name, extra) = ("slice".to_string(), Vec::new());
let extra = extra.append(self.c_mt(mt).as_slice());
self.visit(format!("evec_{}", name).as_slice(),
extra.as_slice())
content_expr: &ast::Expr)
-> DatumBlock<'a, Expr> {
/*!
- * ~[...] and "...".to_owned() allocate boxes in the exchange heap and write
+ * ~[...] and "...".to_string() allocate boxes in the exchange heap and write
* the array elements into them.
*/
let fcx = bcx.fcx;
let ccx = fcx.ccx;
- // Handle "".to_owned().
+ // Handle "".to_string().
match content_expr.node {
ast::ExprLit(lit) => {
match lit.node {
let error = if vst == ast::ExprVstoreSlice {
"`&\"string\"` has been removed; use `\"string\"` instead"
} else {
- "`~\"string\"` has been removed; use `\"string\".to_owned()` instead"
+ "`~\"string\"` has been removed; use `\"string\".to_string()` instead"
};
tcx.sess.span_err(expr.span, error);
ty::mk_err()
// choice of lifetime name deterministic and thus easier to test.
let mut names = Vec::new();
for rn in region_names.iter() {
- let lt_name = token::get_name(*rn).get().to_owned();
+ let lt_name = token::get_name(*rn).get().to_string();
names.push(lt_name);
}
names.sort();
fn setup_env(test_name: &str, source_string: &str) -> Env {
let messages = @DVec();
- let matches = getopts(vec!("-Z".to_owned(), "verbose".to_owned()), optgroups()).get();
+ let matches = getopts(vec!("-Z".to_string(), "verbose".to_string()), optgroups()).get();
let diag = diagnostic::collect(messages);
- let sessopts = build_session_options("rustc".to_owned(), &matches, diag);
+ let sessopts = build_session_options("rustc".to_string(), &matches, diag);
let sess = build_session(sessopts, None, diag);
- let cfg = build_configuration(sess, "whatever".to_owned(), str_input("".to_owned()));
+ let cfg = build_configuration(sess, "whatever".to_string(), str_input("".to_string()));
let dm = HashMap();
let amap = HashMap();
let freevars = HashMap();
let cache = cache_key.get().unwrap();
let abs_root = root(&**cache, loc.as_slice());
let rel_root = match path.segments.get(0).name.as_slice() {
- "self" => Some("./".to_owned()),
+ "self" => Some("./".to_string()),
_ => None,
};
// Extract the text provided
let s = if text.is_null() {
- "".to_owned()
+ "".to_string()
} else {
unsafe {
str::raw::from_buf_len((*text).data, (*text).size as uint)
try!(write!(&mut w, r"]\};"));
- str::from_utf8(w.unwrap().as_slice()).unwrap().to_owned()
+ str::from_utf8(w.unwrap().as_slice()).unwrap().to_string()
};
// Write out the shared files. Note that these are shared among all rustdoc
if ast_util::is_local(self.item.def_id) {
let mut path = Vec::new();
clean_srcpath(self.item.source.filename.as_bytes(), |component| {
- path.push(component.to_owned());
+ path.push(component.to_string());
});
let href = if self.item.source.loline == self.item.source.hiline {
format!("{}", self.item.source.loline)
let cache = cache_key.get().unwrap();
let path = cache.external_paths.get(&self.item.def_id);
let root = match *cache.extern_locations.get(&self.item.def_id.krate) {
- Remote(ref s) => s.to_strbuf(),
+ Remote(ref s) => s.to_string(),
Local => format!("{}/..", self.cx.root_path),
Unknown => return None,
};
#[test]
fn should_unindent() {
- let s = " line1\n line2".to_owned();
+ let s = " line1\n line2".to_string();
let r = unindent(s.as_slice());
assert_eq!(r.as_slice(), "line1\nline2");
}
#[test]
fn should_unindent_multiple_paragraphs() {
- let s = " line1\n\n line2".to_owned();
+ let s = " line1\n\n line2".to_string();
let r = unindent(s.as_slice());
assert_eq!(r.as_slice(), "line1\n\nline2");
}
fn should_leave_multiple_indent_levels() {
// Line 2 is indented another level beyond the
// base indentation and should be preserved
- let s = " line1\n\n line2".to_owned();
+ let s = " line1\n\n line2".to_string();
let r = unindent(s.as_slice());
assert_eq!(r.as_slice(), "line1\n\n line2");
}
//
// #[doc = "Start way over here
// and continue here"]
- let s = "line1\n line2".to_owned();
+ let s = "line1\n line2".to_string();
let r = unindent(s.as_slice());
assert_eq!(r.as_slice(), "line1\nline2");
}
#[test]
fn should_not_ignore_first_line_indent_in_a_single_line_para() {
- let s = "line1\n\n line2".to_owned();
+ let s = "line1\n\n line2".to_string();
let r = unindent(s.as_slice());
assert_eq!(r.as_slice(), "line1\n\n line2");
}
// Add the new dylib search path var
let newpath = DynamicLibrary::create_path(path.as_slice());
- env.push((var.to_owned(),
- str::from_utf8(newpath.as_slice()).unwrap().to_owned()));
+ env.push((var.to_string(),
+ str::from_utf8(newpath.as_slice()).unwrap().to_string()));
env
};
match Command::new(exe).env(env.as_slice()).output() {
};
self.cnt += 1;
let libs = self.libs.clone();
- let cratename = self.cratename.to_owned();
+ let cratename = self.cratename.to_string();
let loose_feature_gating = self.loose_feature_gating;
debug!("Creating test {}: {}", name, test);
self.tests.push(testing::TestDescAndFn {
#[test]
fn test_to_str() {
- assert_eq!(parse("1.2.3").unwrap().to_str(), "1.2.3".to_owned());
- assert_eq!(parse("1.2.3-alpha1").unwrap().to_str(), "1.2.3-alpha1".to_owned());
- assert_eq!(parse("1.2.3+build.42").unwrap().to_str(), "1.2.3+build.42".to_owned());
- assert_eq!(parse("1.2.3-alpha1+42").unwrap().to_str(), "1.2.3-alpha1+42".to_owned());
+ assert_eq!(parse("1.2.3").unwrap().to_str(), "1.2.3".to_string());
+ assert_eq!(parse("1.2.3-alpha1").unwrap().to_str(), "1.2.3-alpha1".to_string());
+ assert_eq!(parse("1.2.3+build.42").unwrap().to_str(), "1.2.3+build.42".to_string());
+ assert_eq!(parse("1.2.3-alpha1+42").unwrap().to_str(), "1.2.3-alpha1+42".to_string());
}
#[test]
#[test]
fn test_clone_noleak() {
fn foo(f: |c: &CString|) {
- let s = "test".to_owned();
+ let s = "test".to_string();
let c = s.to_c_str();
// give the closure a non-owned CString
let mut c_ = c.with_ref(|c| unsafe { CString::new(c, false) } );
Some examples of the `format!` extension are:
```rust
-format!("Hello"); // => "Hello".to_owned()
-format!("Hello, {:s}!", "world"); // => "Hello, world!".to_owned()
-format!("The number is {:d}", 1); // => "The number is 1".to_owned()
-format!("{:?}", ~[3, 4]); // => "~[3, 4]".to_owned()
-format!("{value}", value=4); // => "4".to_owned()
-format!("{} {}", 1, 2); // => "1 2".to_owned()
+format!("Hello"); // => "Hello".to_string()
+format!("Hello, {:s}!", "world"); // => "Hello, world!".to_string()
+format!("The number is {:d}", 1); // => "The number is 1".to_string()
+format!("{:?}", ~[3, 4]); // => "~[3, 4]".to_string()
+format!("{value}", value=4); // => "4".to_string()
+format!("{} {}", 1, 2); // => "1 2".to_string()
```
From these, you can see that the first argument is a format string. It is
iterator advances. This leads to behavior like this:
```rust
-format!("{1} {} {0} {}", 1, 2); // => "2 1 1 2".to_owned()
+format!("{1} {} {0} {}", 1, 2); // => "2 1 1 2".to_string()
```
The internal iterator over the argument has not been advanced by the time the
For example, the following `format!` expressions all use named argument:
```rust
-format!("{argument}", argument = "test"); // => "test".to_owned()
-format!("{name} {}", 1, name = 2); // => "2 1".to_owned()
-format!("{a:s} {c:d} {b:?}", a="a", b=(), c=3); // => "a 3 ()".to_owned()
+format!("{argument}", argument = "test"); // => "test".to_string()
+format!("{name} {}", 1, name = 2); // => "2 1".to_string()
+format!("{a:s} {c:d} {b:?}", a="a", b=(), c=3); // => "a 3 ()".to_string()
```
It is illegal to put positional parameters (those without names) after arguments
example:
```rust
-format!("{0, select, other{#}}", "hello"); // => "hello".to_owned()
+format!("{0, select, other{#}}", "hello"); // => "hello".to_string()
```
This example is the equivalent of `{0:s}` essentially.
/// use std::fmt;
///
/// let s = format_args!(fmt::format, "Hello, {}!", "world");
-/// assert_eq!(s, "Hello, world!".to_owned());
+/// assert_eq!(s, "Hello, world!".to_string());
/// ```
pub fn format(args: &Arguments) -> string::String{
let mut output = io::MemWriter::new();
* phone: u64,
* }
*
- * 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_string(), phone: 555_666_7777 };
+ * let person2 = Person { id: 5, name: "Bob".to_string(), phone: 555_666_7777 };
*
* assert!(hash::hash(&person1) != hash::hash(&person2));
* ```
* }
* }
*
- * 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_string(), phone: 555_666_7777 };
+ * let person2 = Person { id: 5, name: "Bob".to_string(), phone: 555_666_7777 };
*
* assert!(hash::hash(&person1) == hash::hash(&person2));
* ```
/// use std::io;
///
/// let mut reader = io::stdin();
- /// let input = reader.read_line().ok().unwrap_or("nothing".to_owned());
+ /// let input = reader.read_line().ok().unwrap_or("nothing".to_string());
/// ```
///
/// # Error
/// # Examples
///
/// ```rust
- /// let v = ~["a".to_owned(), "b".to_owned()];
+ /// let v = ~["a".to_string(), "b".to_string()];
/// for s in v.move_iter() {
/// // s has type ~str, not &~str
/// println!("{}", s);
assert_eq!(it.next(), None);
}
{
- let v = ["Hello".to_owned()];
+ let v = ["Hello".to_string()];
let mut it = v.permutations();
let (min_size, max_opt) = it.size_hint();
assert_eq!(min_size, 1);
/// // 𝄞music
/// let mut v = [0xD834, 0xDD1E, 0x006d, 0x0075,
/// 0x0073, 0x0069, 0x0063];
-/// assert_eq!(str::from_utf16(v), Some("𝄞music".to_owned()));
+/// assert_eq!(str::from_utf16(v), Some("𝄞music".to_string()));
///
/// // 𝄞mu<invalid>ic
/// v[4] = 0xD800;
/// 0xD834];
///
/// assert_eq!(str::from_utf16_lossy(v),
-/// "𝄞mus\uFFFDic\uFFFD".to_owned());
+/// "𝄞mus\uFFFDic\uFFFD".to_string());
/// ```
pub fn from_utf16_lossy(v: &[u16]) -> String {
utf16_items(v).map(|c| c.to_char_lossy()).collect()
#[inline]
fn into_owned(self) -> String {
match self {
- Slice(s) => s.to_owned(),
+ Slice(s) => s.to_string(),
Owned(s) => s
}
}
fn clone(&self) -> MaybeOwned<'a> {
match *self {
Slice(s) => Slice(s),
- Owned(ref s) => Owned(s.to_owned())
+ Owned(ref s) => Owned(s.to_string())
}
}
}
let a = ~[65u8, 65u8, 65u8, 65u8, 65u8, 65u8, 65u8, 0u8];
let b = a.as_ptr();
let c = from_buf_len(b, 3u);
- assert_eq!(c, "AAA".to_owned());
+ assert_eq!(c, "AAA".to_string());
}
}
}
///
/// ```rust
/// let s = "Do you know the muffin man,
- /// The muffin man, the muffin man, ...".to_owned();
+ /// The muffin man, the muffin man, ...".to_string();
///
/// assert_eq!(s.replace("muffin man", "little lamb"),
/// "Do you know the little lamb,
- /// The little lamb, the little lamb, ...".to_owned());
+ /// The little lamb, the little lamb, ...".to_string());
///
/// // not found, so no change.
/// assert_eq!(s.replace("cookie monster", "little lamb"), s);
result
}
- /// Copy a slice into a new `String`.
+ #[allow(missing_doc)]
+ #[deprecated = "obsolete, use `to_string`"]
#[inline]
fn to_owned(&self) -> String {
use slice::Vector;
impl<'a> StrAllocating for &'a str {
#[inline]
fn into_owned(self) -> String {
- self.to_owned()
+ self.to_string()
}
}
#[test]
fn test_collect() {
- let empty = "".to_owned();
+ let empty = "".to_string();
let s: String = empty.as_slice().chars().collect();
assert_eq!(empty, s);
- let data = "ประเทศไทย中".to_owned();
+ let data = "ประเทศไทย中".to_string();
let s: String = data.as_slice().chars().collect();
assert_eq!(data, s);
}
#[test]
fn test_into_bytes() {
- let data = "asdf".to_owned();
+ let data = "asdf".to_string();
let buf = data.into_bytes();
assert_eq!(bytes!("asdf"), buf.as_slice());
}
fn t(v: &[String], s: &str) {
assert_eq!(v.concat(), s.to_str().into_owned());
}
- t(["you".to_owned(), "know".to_owned(), "I'm".to_owned(),
- "no".to_owned(), "good".to_owned()], "youknowI'mnogood");
+ t(["you".to_string(), "know".to_string(), "I'm".to_string(),
+ "no".to_string(), "good".to_string()], "youknowI'mnogood");
let v: &[String] = [];
t(v, "");
- t(["hi".to_owned()], "hi");
+ t(["hi".to_string()], "hi");
}
#[test]
fn t(v: &[String], sep: &str, s: &str) {
assert_eq!(v.connect(sep), s.to_str().into_owned());
}
- t(["you".to_owned(), "know".to_owned(), "I'm".to_owned(),
- "no".to_owned(), "good".to_owned()],
+ t(["you".to_string(), "know".to_string(), "I'm".to_string(),
+ "no".to_string(), "good".to_string()],
" ", "you know I'm no good");
let v: &[String] = [];
t(v, " ", "");
- t(["hi".to_owned()], " ", "hi");
+ t(["hi".to_string()], " ", "hi");
}
#[test]
#[test]
fn test_repeat() {
- assert_eq!("x".repeat(4), "xxxx".to_owned());
- assert_eq!("hi".repeat(4), "hihihihi".to_owned());
- assert_eq!("ไท华".repeat(3), "ไท华ไท华ไท华".to_owned());
- assert_eq!("".repeat(4), "".to_owned());
- assert_eq!("hi".repeat(0), "".to_owned());
+ assert_eq!("x".repeat(4), "xxxx".to_string());
+ assert_eq!("hi".repeat(4), "hihihihi".to_string());
+ assert_eq!("ไท华".repeat(3), "ไท华ไท华ไท华".to_string());
+ assert_eq!("".repeat(4), "".to_string());
+ assert_eq!("hi".repeat(0), "".to_string());
}
#[test]
#[test]
fn test_replace() {
let a = "a";
- assert_eq!("".replace(a, "b"), "".to_owned());
- assert_eq!("a".replace(a, "b"), "b".to_owned());
- assert_eq!("ab".replace(a, "b"), "bb".to_owned());
+ assert_eq!("".replace(a, "b"), "".to_string());
+ assert_eq!("a".replace(a, "b"), "b".to_string());
+ assert_eq!("ab".replace(a, "b"), "bb".to_string());
let test = "test";
assert!(" test test ".replace(test, "toast") ==
- " toast toast ".to_owned());
- assert_eq!(" test test ".replace(test, ""), " ".to_owned());
+ " toast toast ".to_string());
+ assert_eq!(" test test ".replace(test, ""), " ".to_string());
}
#[test]
let a = box [65, 65, 65, 65, 65, 65, 65, 0];
let b = a.as_ptr();
let c = raw::from_c_str(b);
- assert_eq!(c, "AAAAAAA".to_owned());
+ assert_eq!(c, "AAAAAAA".to_string());
}
}
fn test_as_bytes_fail() {
// Don't double free. (I'm not sure if this exercises the
// original problem code path anymore.)
- let s = "".to_owned();
+ let s = "".to_string();
let _bytes = s.as_bytes();
fail!();
}
#[test]
fn test_utf16() {
let pairs =
- [("𐍅𐌿𐌻𐍆𐌹𐌻𐌰\n".to_owned(),
+ [("𐍅𐌿𐌻𐍆𐌹𐌻𐌰\n".to_string(),
vec![0xd800_u16, 0xdf45_u16, 0xd800_u16, 0xdf3f_u16,
0xd800_u16, 0xdf3b_u16, 0xd800_u16, 0xdf46_u16,
0xd800_u16, 0xdf39_u16, 0xd800_u16, 0xdf3b_u16,
0xd800_u16, 0xdf30_u16, 0x000a_u16]),
- ("𐐒𐑉𐐮𐑀𐐲𐑋 𐐏𐐲𐑍\n".to_owned(),
+ ("𐐒𐑉𐐮𐑀𐐲𐑋 𐐏𐐲𐑍\n".to_string(),
vec![0xd801_u16, 0xdc12_u16, 0xd801_u16,
0xdc49_u16, 0xd801_u16, 0xdc2e_u16, 0xd801_u16,
0xdc40_u16, 0xd801_u16, 0xdc32_u16, 0xd801_u16,
0xd801_u16, 0xdc32_u16, 0xd801_u16, 0xdc4d_u16,
0x000a_u16]),
- ("𐌀𐌖𐌋𐌄𐌑𐌉·𐌌𐌄𐌕𐌄𐌋𐌉𐌑\n".to_owned(),
+ ("𐌀𐌖𐌋𐌄𐌑𐌉·𐌌𐌄𐌕𐌄𐌋𐌉𐌑\n".to_string(),
vec![0xd800_u16, 0xdf00_u16, 0xd800_u16, 0xdf16_u16,
0xd800_u16, 0xdf0b_u16, 0xd800_u16, 0xdf04_u16,
0xd800_u16, 0xdf11_u16, 0xd800_u16, 0xdf09_u16,
0xdf04_u16, 0xd800_u16, 0xdf0b_u16, 0xd800_u16,
0xdf09_u16, 0xd800_u16, 0xdf11_u16, 0x000a_u16 ]),
- ("𐒋𐒘𐒈𐒑𐒛𐒒 𐒕𐒓 𐒈𐒚𐒍 𐒏𐒜𐒒𐒖𐒆 𐒕𐒆\n".to_owned(),
+ ("𐒋𐒘𐒈𐒑𐒛𐒒 𐒕𐒓 𐒈𐒚𐒍 𐒏𐒜𐒒𐒖𐒆 𐒕𐒆\n".to_string(),
vec![0xd801_u16, 0xdc8b_u16, 0xd801_u16, 0xdc98_u16,
0xd801_u16, 0xdc88_u16, 0xd801_u16, 0xdc91_u16,
0xd801_u16, 0xdc9b_u16, 0xd801_u16, 0xdc92_u16,
0xd801_u16, 0xdc95_u16, 0xd801_u16, 0xdc86_u16,
0x000a_u16 ]),
// Issue #12318, even-numbered non-BMP planes
- ("\U00020000".to_owned(),
+ ("\U00020000".to_string(),
vec![0xD840, 0xDC00])];
for p in pairs.iter() {
fn test_utf16_lossy() {
// completely positive cases tested above.
// lead + eof
- assert_eq!(from_utf16_lossy([0xD800]), "\uFFFD".to_owned());
+ assert_eq!(from_utf16_lossy([0xD800]), "\uFFFD".to_string());
// lead + lead
- assert_eq!(from_utf16_lossy([0xD800, 0xD800]), "\uFFFD\uFFFD".to_owned());
+ assert_eq!(from_utf16_lossy([0xD800, 0xD800]), "\uFFFD\uFFFD".to_string());
// isolated trail
- assert_eq!(from_utf16_lossy([0x0061, 0xDC00]), "a\uFFFD".to_owned());
+ assert_eq!(from_utf16_lossy([0x0061, 0xDC00]), "a\uFFFD".to_string());
// general
- assert_eq!(from_utf16_lossy([0xD800, 0xd801, 0xdc8b, 0xD800]), "\uFFFD𐒋\uFFFD".to_owned());
+ assert_eq!(from_utf16_lossy([0xD800, 0xd801, 0xdc8b, 0xD800]),
+ "\uFFFD𐒋\uFFFD".to_string());
}
#[test]
#[test]
fn test_escape_unicode() {
- assert_eq!("abc".escape_unicode(), "\\x61\\x62\\x63".to_owned());
- assert_eq!("a c".escape_unicode(), "\\x61\\x20\\x63".to_owned());
- assert_eq!("\r\n\t".escape_unicode(), "\\x0d\\x0a\\x09".to_owned());
- assert_eq!("'\"\\".escape_unicode(), "\\x27\\x22\\x5c".to_owned());
- assert_eq!("\x00\x01\xfe\xff".escape_unicode(), "\\x00\\x01\\xfe\\xff".to_owned());
- assert_eq!("\u0100\uffff".escape_unicode(), "\\u0100\\uffff".to_owned());
- assert_eq!("\U00010000\U0010ffff".escape_unicode(), "\\U00010000\\U0010ffff".to_owned());
- assert_eq!("ab\ufb00".escape_unicode(), "\\x61\\x62\\ufb00".to_owned());
- assert_eq!("\U0001d4ea\r".escape_unicode(), "\\U0001d4ea\\x0d".to_owned());
+ assert_eq!("abc".escape_unicode(), "\\x61\\x62\\x63".to_string());
+ assert_eq!("a c".escape_unicode(), "\\x61\\x20\\x63".to_string());
+ assert_eq!("\r\n\t".escape_unicode(), "\\x0d\\x0a\\x09".to_string());
+ assert_eq!("'\"\\".escape_unicode(), "\\x27\\x22\\x5c".to_string());
+ assert_eq!("\x00\x01\xfe\xff".escape_unicode(), "\\x00\\x01\\xfe\\xff".to_string());
+ assert_eq!("\u0100\uffff".escape_unicode(), "\\u0100\\uffff".to_string());
+ assert_eq!("\U00010000\U0010ffff".escape_unicode(), "\\U00010000\\U0010ffff".to_string());
+ assert_eq!("ab\ufb00".escape_unicode(), "\\x61\\x62\\ufb00".to_string());
+ assert_eq!("\U0001d4ea\r".escape_unicode(), "\\U0001d4ea\\x0d".to_string());
}
#[test]
fn test_escape_default() {
- assert_eq!("abc".escape_default(), "abc".to_owned());
- assert_eq!("a c".escape_default(), "a c".to_owned());
- assert_eq!("\r\n\t".escape_default(), "\\r\\n\\t".to_owned());
- assert_eq!("'\"\\".escape_default(), "\\'\\\"\\\\".to_owned());
- assert_eq!("\u0100\uffff".escape_default(), "\\u0100\\uffff".to_owned());
- assert_eq!("\U00010000\U0010ffff".escape_default(), "\\U00010000\\U0010ffff".to_owned());
- assert_eq!("ab\ufb00".escape_default(), "ab\\ufb00".to_owned());
- assert_eq!("\U0001d4ea\r".escape_default(), "\\U0001d4ea\\r".to_owned());
+ assert_eq!("abc".escape_default(), "abc".to_string());
+ assert_eq!("a c".escape_default(), "a c".to_string());
+ assert_eq!("\r\n\t".escape_default(), "\\r\\n\\t".to_string());
+ assert_eq!("'\"\\".escape_default(), "\\'\\\"\\\\".to_string());
+ assert_eq!("\u0100\uffff".escape_default(), "\\u0100\\uffff".to_string());
+ assert_eq!("\U00010000\U0010ffff".escape_default(), "\\U00010000\\U0010ffff".to_string());
+ assert_eq!("ab\ufb00".escape_default(), "ab\\ufb00".to_string());
+ assert_eq!("\U0001d4ea\r".escape_default(), "\\U0001d4ea\\r".to_string());
}
#[test]
v.iter().map(|x| x.len()).sum()
}
- let s = "01234".to_owned();
+ let s = "01234".to_string();
assert_eq!(5, sum_len(["012", "", "34"]));
- assert_eq!(5, sum_len(["01".to_owned(), "2".to_owned(), "34".to_owned(), "".to_owned()]));
+ assert_eq!(5, sum_len(["01".to_string(), "2".to_string(),
+ "34".to_string(), "".to_string()]));
assert_eq!(5, sum_len([s.as_slice()]));
}
#[test]
fn test_str_from_utf8_owned() {
let xs = Vec::from_slice(bytes!("hello"));
- assert_eq!(from_utf8_owned(xs), Ok("hello".to_owned()));
+ assert_eq!(from_utf8_owned(xs), Ok("hello".to_string()));
let xs = Vec::from_slice(bytes!("ศไทย中华Việt Nam"));
- assert_eq!(from_utf8_owned(xs), Ok("ศไทย中华Việt Nam".to_owned()));
+ assert_eq!(from_utf8_owned(xs), Ok("ศไทย中华Việt Nam".to_string()));
let xs = Vec::from_slice(bytes!("hello", 0xff));
assert_eq!(from_utf8_owned(xs),
assert_eq!(from_utf8_lossy(xs), Slice("ศไทย中华Việt Nam"));
let xs = bytes!("Hello", 0xC2, " There", 0xFF, " Goodbye");
- assert_eq!(from_utf8_lossy(xs), Owned("Hello\uFFFD There\uFFFD Goodbye".to_owned()));
+ assert_eq!(from_utf8_lossy(xs), Owned("Hello\uFFFD There\uFFFD Goodbye".to_string()));
let xs = bytes!("Hello", 0xC0, 0x80, " There", 0xE6, 0x83, " Goodbye");
- assert_eq!(from_utf8_lossy(xs), Owned("Hello\uFFFD\uFFFD There\uFFFD Goodbye".to_owned()));
+ assert_eq!(from_utf8_lossy(xs), Owned("Hello\uFFFD\uFFFD There\uFFFD Goodbye".to_string()));
let xs = bytes!(0xF5, "foo", 0xF5, 0x80, "bar");
- assert_eq!(from_utf8_lossy(xs), Owned("\uFFFDfoo\uFFFD\uFFFDbar".to_owned()));
+ assert_eq!(from_utf8_lossy(xs), Owned("\uFFFDfoo\uFFFD\uFFFDbar".to_string()));
let xs = bytes!(0xF1, "foo", 0xF1, 0x80, "bar", 0xF1, 0x80, 0x80, "baz");
- assert_eq!(from_utf8_lossy(xs), Owned("\uFFFDfoo\uFFFDbar\uFFFDbaz".to_owned()));
+ assert_eq!(from_utf8_lossy(xs), Owned("\uFFFDfoo\uFFFDbar\uFFFDbaz".to_string()));
let xs = bytes!(0xF4, "foo", 0xF4, 0x80, "bar", 0xF4, 0xBF, "baz");
- assert_eq!(from_utf8_lossy(xs), Owned("\uFFFDfoo\uFFFDbar\uFFFD\uFFFDbaz".to_owned()));
+ assert_eq!(from_utf8_lossy(xs), Owned("\uFFFDfoo\uFFFDbar\uFFFD\uFFFDbaz".to_string()));
let xs = bytes!(0xF0, 0x80, 0x80, 0x80, "foo", 0xF0, 0x90, 0x80, 0x80, "bar");
assert_eq!(from_utf8_lossy(xs), Owned("\uFFFD\uFFFD\uFFFD\uFFFD\
- foo\U00010000bar".to_owned()));
+ foo\U00010000bar".to_string()));
// surrogates
let xs = bytes!(0xED, 0xA0, 0x80, "foo", 0xED, 0xBF, 0xBF, "bar");
assert_eq!(from_utf8_lossy(xs), Owned("\uFFFD\uFFFD\uFFFDfoo\
- \uFFFD\uFFFD\uFFFDbar".to_owned()));
+ \uFFFD\uFFFD\uFFFDbar".to_string()));
}
#[test]
let s = Slice("abcde");
assert_eq!(s.len(), 5);
assert_eq!(s.as_slice(), "abcde");
- assert_eq!(s.to_str(), "abcde".to_strbuf());
- assert_eq!(format_strbuf!("{}", s), "abcde".to_strbuf());
- assert!(s.lt(&Owned("bcdef".to_owned())));
+ assert_eq!(s.to_str(), "abcde".to_string());
+ assert_eq!(format_strbuf!("{}", s), "abcde".to_string());
+ assert!(s.lt(&Owned("bcdef".to_string())));
assert_eq!(Slice(""), Default::default());
- let o = Owned("abcde".to_owned());
+ let o = Owned("abcde".to_string());
assert_eq!(o.len(), 5);
assert_eq!(o.as_slice(), "abcde");
assert_eq!(o.to_str(), "abcde".to_strbuf());
assert_eq!(format_strbuf!("{}", o), "abcde".to_strbuf());
assert!(o.lt(&Slice("bcdef")));
- assert_eq!(Owned("".to_owned()), Default::default());
+ assert_eq!(Owned("".to_string()), Default::default());
assert!(s.cmp(&o) == Equal);
assert!(s.equiv(&o));
assert!(s.is_slice());
assert!(!s.is_owned());
- let o = Owned("abcde".to_owned());
+ let o = Owned("abcde".to_string());
assert!(!o.is_slice());
assert!(o.is_owned());
}
#[test]
fn test_maybe_owned_clone() {
- assert_eq!(Owned("abcde".to_owned()), Slice("abcde").clone());
- assert_eq!(Owned("abcde".to_owned()), Owned("abcde".to_owned()).clone());
+ assert_eq!(Owned("abcde".to_string()), Slice("abcde").clone());
+ assert_eq!(Owned("abcde".to_string()), Owned("abcde".to_string()).clone());
assert_eq!(Slice("abcde"), Slice("abcde").clone());
- assert_eq!(Slice("abcde"), Owned("abcde".to_owned()).clone());
+ assert_eq!(Slice("abcde"), Owned("abcde".to_string()).clone());
}
#[test]
fn test_maybe_owned_into_owned() {
- assert_eq!(Slice("abcde").into_owned(), "abcde".to_owned());
- assert_eq!(Owned("abcde".to_owned()).into_owned(), "abcde".to_owned());
+ assert_eq!(Slice("abcde").into_owned(), "abcde".to_string());
+ assert_eq!(Owned("abcde".to_string()).into_owned(), "abcde".to_string());
}
#[test]
fn test_into_maybe_owned() {
assert_eq!("abcde".into_maybe_owned(), Slice("abcde"));
- assert_eq!(("abcde".to_owned()).into_maybe_owned(), Slice("abcde"));
- assert_eq!("abcde".into_maybe_owned(), Owned("abcde".to_owned()));
- assert_eq!(("abcde".to_owned()).into_maybe_owned(), Owned("abcde".to_owned()));
+ assert_eq!(("abcde".to_string()).into_maybe_owned(), Slice("abcde"));
+ assert_eq!("abcde".into_maybe_owned(), Owned("abcde".to_string()));
+ assert_eq!(("abcde".to_string()).into_maybe_owned(), Owned("abcde".to_string()));
}
}
#[test]
fn test_owned_named_task() {
- TaskBuilder::new().named("ada lovelace".to_owned()).spawn(proc() {
+ TaskBuilder::new().named("ada lovelace".to_string()).spawn(proc() {
with_task_name(|name| {
assert!(name.unwrap() == "ada lovelace");
})
#[test]
fn test_try_success() {
match try(proc() {
- "Success!".to_owned()
+ "Success!".to_string()
}).as_ref().map(|s| s.as_slice()) {
result::Ok("Success!") => (),
_ => fail!()
/// # Example
///
/// ```rust
- /// let v = vec!("a".to_owned(), "b".to_owned());
+ /// let v = vec!("a".to_string(), "b".to_string());
/// for s in v.move_iter() {
/// // s has type String, not &String
/// println!("{}", s);
///
/// # Example
/// ```rust
- /// let mut v = vec!("foo".to_owned(), "bar".to_owned(), "baz".to_owned(), "qux".to_owned());
+ /// let mut v = vec!("foo".to_string(), "bar".to_string(),
+ /// "baz".to_string(), "qux".to_string());
///
- /// assert_eq!(v.swap_remove(1), Some("bar".to_owned()));
- /// assert_eq!(v, vec!("foo".to_owned(), "qux".to_owned(), "baz".to_owned()));
+ /// assert_eq!(v.swap_remove(1), Some("bar".to_string()));
+ /// assert_eq!(v, vec!("foo".to_string(), "qux".to_string(), "baz".to_string()));
///
- /// assert_eq!(v.swap_remove(0), Some("foo".to_owned()));
- /// assert_eq!(v, vec!("baz".to_owned(), "qux".to_owned()));
+ /// assert_eq!(v.swap_remove(0), Some("foo".to_string()));
+ /// assert_eq!(v, vec!("baz".to_string(), "qux".to_string()));
///
/// assert_eq!(v.swap_remove(2), None);
/// ```
pub fn DuplexStream1() {
let (left, right) = duplex();
- left.send("abc".to_owned());
+ left.send("abc".to_string());
right.send(123);
assert!(left.recv() == 123);
- assert!(right.recv() == "abc".to_owned());
+ assert!(right.recv() == "abc".to_string());
}
}
#[test]
fn test_from_value() {
- let mut f = Future::from_value("snail".to_owned());
- assert_eq!(f.get(), "snail".to_owned());
+ let mut f = Future::from_value("snail".to_string());
+ assert_eq!(f.get(), "snail".to_string());
}
#[test]
fn test_from_receiver() {
let (tx, rx) = channel();
- tx.send("whale".to_owned());
+ tx.send("whale".to_string());
let mut f = Future::from_receiver(rx);
- assert_eq!(f.get(), "whale".to_owned());
+ assert_eq!(f.get(), "whale".to_string());
}
#[test]
fn test_from_fn() {
- let mut f = Future::from_fn(proc() "brail".to_owned());
- assert_eq!(f.get(), "brail".to_owned());
+ let mut f = Future::from_fn(proc() "brail".to_string());
+ assert_eq!(f.get(), "brail".to_string());
}
#[test]
fn test_interface_get() {
- let mut f = Future::from_value("fail".to_owned());
- assert_eq!(f.get(), "fail".to_owned());
+ let mut f = Future::from_value("fail".to_string());
+ assert_eq!(f.get(), "fail".to_string());
}
#[test]
fn test_interface_unwrap() {
- let f = Future::from_value("fail".to_owned());
- assert_eq!(f.unwrap(), "fail".to_owned());
+ let f = Future::from_value("fail".to_string());
+ assert_eq!(f.unwrap(), "fail".to_string());
}
#[test]
#[test]
fn test_spawn() {
- let mut f = Future::spawn(proc() "bale".to_owned());
- assert_eq!(f.get(), "bale".to_owned());
+ let mut f = Future::spawn(proc() "bale".to_string());
+ assert_eq!(f.get(), "bale".to_string());
}
#[test]
impl FromStr for CrateId {
fn from_str(s: &str) -> Option<CrateId> {
let pieces: Vec<&str> = s.splitn('#', 1).collect();
- let path = pieces.get(0).to_owned();
+ let path = pieces.get(0).to_string();
if path.as_slice().starts_with("/") || path.as_slice().ends_with("/") ||
path.as_slice().starts_with(".") || path.is_empty() {
let mut asm_str_style = None;
let mut outputs = Vec::new();
let mut inputs = Vec::new();
- let mut cons = "".to_owned();
+ let mut cons = "".to_string();
let mut volatile = false;
let mut alignstack = false;
let mut dialect = ast::AsmAtt;
fn decode(d: &D) -> Node {
d.read_struct("Node", 1, || {
Node {
- id: d.read_field("x".to_owned(), 0, || decode(d))
+ id: d.read_field("x".to_string(), 0, || decode(d))
}
})
}
fn decode(d: &D) -> spanned<T> {
d.read_rec(|| {
{
- node: d.read_field("node".to_owned(), 0, || decode(d)),
- span: d.read_field("span".to_owned(), 1, || decode(d)),
+ node: d.read_field("node".to_string(), 0, || decode(d)),
+ span: d.read_field("span".to_string(), 1, || decode(d)),
}
})
}
LIT_INT(i, ity) => {
let s_ity = match ity {
- ast::TyI => "TyI".to_owned(),
- ast::TyI8 => "TyI8".to_owned(),
- ast::TyI16 => "TyI16".to_owned(),
- ast::TyI32 => "TyI32".to_owned(),
- ast::TyI64 => "TyI64".to_owned()
+ ast::TyI => "TyI".to_string(),
+ ast::TyI8 => "TyI8".to_string(),
+ ast::TyI16 => "TyI16".to_string(),
+ ast::TyI32 => "TyI32".to_string(),
+ ast::TyI64 => "TyI64".to_string()
};
let e_ity = cx.expr_ident(sp, id_ext(s_ity.as_slice()));
LIT_UINT(u, uty) => {
let s_uty = match uty {
- ast::TyU => "TyU".to_owned(),
- ast::TyU8 => "TyU8".to_owned(),
- ast::TyU16 => "TyU16".to_owned(),
- ast::TyU32 => "TyU32".to_owned(),
- ast::TyU64 => "TyU64".to_owned()
+ ast::TyU => "TyU".to_string(),
+ ast::TyU8 => "TyU8".to_string(),
+ ast::TyU16 => "TyU16".to_string(),
+ ast::TyU32 => "TyU32".to_string(),
+ ast::TyU64 => "TyU64".to_string()
};
let e_uty = cx.expr_ident(sp, id_ext(s_uty.as_slice()));
LIT_FLOAT(fident, fty) => {
let s_fty = match fty {
- ast::TyF32 => "TyF32".to_owned(),
- ast::TyF64 => "TyF64".to_owned(),
- ast::TyF128 => "TyF128".to_owned()
+ ast::TyF32 => "TyF32".to_string(),
+ ast::TyF64 => "TyF64".to_string(),
+ ast::TyF128 => "TyF128".to_string()
};
let e_fty = cx.expr_ident(sp, id_ext(s_fty.as_slice()));
outer_attrs, "path") {
Some(d) => (dir_path.join(d), true),
None => {
- let mod_name = mod_string.get().to_owned();
+ let mod_name = mod_string.get().to_string();
let default_path_str = format!("{}.rs", mod_name);
let secondary_path_str = format!("{}/mod.rs", mod_name);
let default_path = dir_path.join(default_path_str.as_slice());
// don't read NUL
let bytes = try!(file.read_exact(names_bytes as uint - 1));
let names_str = match str::from_utf8(bytes.as_slice()) {
- Some(s) => s.to_owned(),
+ Some(s) => s.to_string(),
None => return Err("input not utf-8".to_strbuf()),
};
let stdout = ChanWriter::new(tx.clone());
let stderr = ChanWriter::new(tx);
let mut task = TaskBuilder::new().named(match desc.name {
- DynTestName(ref name) => name.clone().to_owned(),
- StaticTestName(name) => name.to_owned(),
+ DynTestName(ref name) => name.clone().to_string(),
+ StaticTestName(name) => name.to_string(),
});
if nocapture {
drop((stdout, stderr));
fn main() {
let args = os::args();
let args = if os::getenv("RUST_BENCH").is_some() {
- vec!("".to_owned(), "10000000".to_owned())
+ vec!("".to_string(), "10000000".to_string())
} else if args.len() <= 1u {
- vec!("".to_owned(), "100000".to_owned())
+ vec!("".to_string(), "100000".to_string())
} else {
args.move_iter().collect()
};
fn main() {
let args = os::args();
let args = if os::getenv("RUST_BENCH").is_some() {
- vec!("".to_owned(), "100".to_owned(), "10000".to_owned())
+ vec!("".to_string(), "100".to_string(), "10000".to_string())
} else if args.len() <= 1u {
- vec!("".to_owned(), "10".to_owned(), "100".to_owned())
+ vec!("".to_string(), "10".to_string(), "100".to_string())
} else {
args.clone().move_iter().collect()
};
fn main() {
let args = os::args();
let args = if os::getenv("RUST_BENCH").is_some() {
- vec!("".to_owned(), "100".to_owned(), "10000".to_owned())
+ vec!("".to_string(), "100".to_string(), "10000".to_string())
} else if args.len() <= 1u {
- vec!("".to_owned(), "10".to_owned(), "100".to_owned())
+ vec!("".to_string(), "10".to_string(), "100".to_string())
} else {
args.clone().move_iter().collect()
};
fn main() {
let args = os::args();
let args = if os::getenv("RUST_BENCH").is_some() {
- vec!("".to_owned(), "12".to_owned())
+ vec!("".to_string(), "12".to_string())
} else if args.len() <= 1u {
- vec!("".to_owned(), "8".to_owned())
+ vec!("".to_string(), "8".to_string())
} else {
args.move_iter().collect()
};
fn main() {
let args = os::args();
let args = if os::getenv("RUST_BENCH").is_some() {
- vec!("".to_owned(), "40".to_owned())
+ vec!("".to_string(), "40".to_string())
} else if args.len() <= 1u {
- vec!("".to_owned(), "30".to_owned())
+ vec!("".to_string(), "30".to_string())
} else {
args.move_iter().collect()
};
fn main() {
let args = os::args();
let args = if os::getenv("RUST_BENCH").is_some() {
- vec!("".to_owned(), "100000".to_owned(), "100".to_owned())
+ vec!("".to_string(), "100000".to_string(), "100".to_string())
} else if args.len() <= 1u {
- vec!("".to_owned(), "10000".to_owned(), "50".to_owned())
+ vec!("".to_string(), "10000".to_string(), "50".to_string())
} else {
args.move_iter().collect()
};
pub fn read(mut reader: BufferedReader<StdReader>) -> Sudoku {
/* assert first line is exactly "9,9" */
- assert!(reader.read_line().unwrap() == "9,9".to_owned());
+ assert!(reader.read_line().unwrap() == "9,9".to_string());
let mut g = Vec::from_fn(10u, { |_i| vec!(0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8) });
for line in reader.lines() {
fn main() {
let args = os::args();
let args = if os::getenv("RUST_BENCH").is_some() {
- vec!("".to_owned(), "100000".to_owned())
+ vec!("".to_string(), "100000".to_string())
} else if args.len() <= 1 {
- vec!("".to_owned(), "100".to_owned())
+ vec!("".to_string(), "100".to_string())
} else {
args.clone().move_iter().collect()
};
fn main() {
let args = os::args();
let args = if os::getenv("RUST_BENCH").is_some() {
- vec!("".to_owned(), "30".to_owned())
+ vec!("".to_string(), "30".to_string())
} else if args.len() <= 1u {
- vec!("".to_owned(), "10".to_owned())
+ vec!("".to_string(), "10".to_string())
} else {
args
};
fn main() {
let args = os::args();
let args = if os::getenv("RUST_BENCH").is_some() {
- vec!("".to_owned(), "400".to_owned())
+ vec!("".to_string(), "400".to_string())
} else if args.len() <= 1u {
- vec!("".to_owned(), "10".to_owned())
+ vec!("".to_string(), "10".to_string())
} else {
args.move_iter().collect()
};
}
fn let_pat() {
- let &_x = &"hi".to_owned();
+ let &_x = &"hi".to_string();
//~^ ERROR cannot move out of dereference of `&`-pointer
}
use std::rc::Rc;
pub fn main() {
- let _x = *Rc::new("hi".to_owned());
+ let _x = *Rc::new("hi".to_string());
//~^ ERROR cannot move out of dereference of `&`-pointer
}
fn main() {
let msg;
- match Some("Hello".to_owned()) {
+ match Some("Hello".to_string()) {
Some(ref m) => { //~ ERROR borrowed value does not live long enough
msg = m;
},
mod circular_modules_hello; //~ERROR: circular modules
pub fn hi_str() -> String {
- "Hi!".to_owned()
+ "Hi!".to_string()
}
fn main() {
fn check_bound<T:Copy>(_: T) {}
fn main() {
- check_bound("nocopy".to_owned()); //~ ERROR does not fulfill `Copy`
+ check_bound("nocopy".to_string()); //~ ERROR does not fulfill `Copy`
}
fn main() {
println!("hello");
- let x = "foo".to_owned();
+ let x = "foo".to_string();
let y = x;
println!("{}", y);
}
// except according to those terms.
fn foo(b: bool) -> Result<bool,String> {
- Err("bar".to_owned());
+ Err("bar".to_string());
//~^ ERROR: cannot determine a type for this expression: unconstrained type
}
use std::task;
fn main() {
- let x = "Hello world!".to_owned();
+ let x = "Hello world!".to_string();
task::spawn(proc() {
println!("{}", x);
});
fn touch<A>(_a: &A) {}
fn f00() {
- let x = "hi".to_owned();
+ let x = "hi".to_string();
let _y = Foo { f:x }; //~ NOTE `x` moved here
touch(&x); //~ ERROR use of moved value: `x`
}
fn f05() {
- let x = "hi".to_owned();
+ let x = "hi".to_string();
let _y = Foo { f:(((x))) }; //~ NOTE `x` moved here
touch(&x); //~ ERROR use of moved value: `x`
}
fn f10() {
- let x = "hi".to_owned();
+ let x = "hi".to_string();
let _y = Foo { f:x.clone() };
touch(&x);
}
fn f20() {
- let x = "hi".to_owned();
+ let x = "hi".to_string();
let _y = Foo { f:(x).clone() };
touch(&x);
}
fn f30() {
- let x = "hi".to_owned();
+ let x = "hi".to_string();
let _y = Foo { f:((x)).clone() };
touch(&x);
}
fn f40() {
- let x = "hi".to_owned();
+ let x = "hi".to_string();
let _y = Foo { f:(((((((x)).clone()))))) };
touch(&x);
}
fn touch<A>(_a: &A) {}
fn f10() {
- let x = Foo {f: "hi".to_owned()};
+ let x = Foo {f: "hi".to_string()};
let y = match x {
Foo {f} => {} //~ NOTE moved here
}
fn innocent_looking_victim() {
- let mut x = Some("hello".to_owned());
+ let mut x = Some("hello".to_string());
conspirator(|f, writer| {
if writer {
x = None;
impl Cmp, ToStr for S { //~ ERROR: expected `{` but found `,`
fn eq(&&other: S) { false }
- fn to_str(&self) -> String { "hi".to_owned() }
+ fn to_str(&self) -> String { "hi".to_string() }
}
#![feature(concat_idents)]
pub fn main() {
- let asdf_fdsa = "<.<".to_owned();
- assert_eq!(concat_idents!(asd, f_f, dsa), "<.<".to_owned());
+ let asdf_fdsa = "<.<".to_string();
+ assert_eq!(concat_idents!(asd, f_f, dsa), "<.<".to_string());
//~^ ERROR: unresolved name `asdf_fdsa`
assert!(stringify!(use_mention_distinction) ==
}
fn main() {
- let person = "Fred".to_owned();
+ let person = "Fred".to_string();
let person: &str = person.as_slice(); //~ ERROR `person` does not live long enough
let s: Box<Trait<&'static str>> = box Struct { person: person };
}
// except according to those terms.
fn main() {
- let x = "Hello!".to_owned();
+ let x = "Hello!".to_string();
let _y = x;
println!("{}", x); //~ ERROR use of moved value
}
let _y =
match x {
Some(_) =>
- ["some(_)".to_owned(), "not".to_owned(), "SO".to_owned(),
- "long".to_owned(), "string".to_owned()],
+ ["some(_)".to_string(), "not".to_string(), "SO".to_string(),
+ "long".to_string(), "string".to_string()],
None =>
- ["none".to_owned(), "a".to_owned(), "a".to_owned(),
- "a".to_owned(), "a".to_owned()]
+ ["none".to_string(), "a".to_string(), "a".to_string(),
+ "a".to_string(), "a".to_string()]
};
}
let x = Some(3);
let _y =
match x {
- Some(_) => "some(_)".to_owned(),
- None => "none".to_owned()
+ Some(_) => "some(_)".to_string(),
+ None => "none".to_string()
};
}
use std::task::TaskBuilder;
fn main() {
- TaskBuilder::new().named("owned name".to_owned()).try(proc() {
+ TaskBuilder::new().named("owned name".to_string()).try(proc() {
fail!("test");
1
}).unwrap()
}
fn main() {
- let x = @"hi".to_owned();
+ let x = @"hi".to_string();
failfn();
println!("{:?}", x);
}
@0;
}
fn test_str() {
- let res = match false { true => { "happy".to_owned() },
+ let res = match false { true => { "happy".to_string() },
_ => fail!("non-exhaustive match failure") };
- assert_eq!(res, "happy".to_owned());
+ assert_eq!(res, "happy".to_string());
}
fn main() {
test_box();
let cx = mk_ctxt();
let abc = quote_expr!(cx, 23);
- check_pp(ext_cx, abc, pprust::print_expr, "23".to_owned());
+ check_pp(ext_cx, abc, pprust::print_expr, "23".to_string());
let ty = quote_ty!(cx, int);
- check_pp(ext_cx, ty, pprust::print_type, "int".to_owned());
+ check_pp(ext_cx, ty, pprust::print_type, "int".to_string());
let item = quote_item!(cx, static x : int = 10;).get();
- check_pp(ext_cx, item, pprust::print_item, "static x: int = 10;".to_owned());
+ check_pp(ext_cx, item, pprust::print_item, "static x: int = 10;".to_string());
let stmt = quote_stmt!(cx, let x = 20;);
- check_pp(ext_cx, *stmt, pprust::print_stmt, "let x = 20;".to_owned());
+ check_pp(ext_cx, *stmt, pprust::print_stmt, "let x = 20;".to_string());
let pat = quote_pat!(cx, Some(_));
- check_pp(ext_cx, pat, pprust::print_pat, "Some(_)".to_owned());
+ check_pp(ext_cx, pat, pprust::print_pat, "Some(_)".to_string());
}
pp::eof(pp.s);
});
stdout().write_line(s);
- if expect != "".to_owned() {
+ if expect != "".to_string() {
println!("expect: '%s', got: '%s'", expect, s);
assert_eq!(s, expect);
}
pub fn main() {
assert_eq!(14,14);
- assert_eq!("abc".to_owned(),"abc".to_owned());
+ assert_eq!("abc".to_string(),"abc".to_string());
assert_eq!(box Point{x:34},box Point{x:34});
assert_eq!(&Point{x:34},&Point{x:34});
assert_eq!(@Point{x:34},@Point{x:34});
pub fn main() {
assert!((@1 < @3));
- assert!((@@"hello ".to_owned() > @@"hello".to_owned()));
- assert!((@@@"hello".to_owned() != @@@"there".to_owned()));
+ assert!((@@"hello ".to_string() > @@"hello".to_string()));
+ assert!((@@@"hello".to_string() != @@@"there".to_string()));
}
pub fn main() {
let lst = new_int_alist();
- alist_add(&lst, 22, "hi".to_owned());
- alist_add(&lst, 44, "ho".to_owned());
- assert_eq!(alist_get(&lst, 22), "hi".to_owned());
- assert_eq!(alist_get(&lst, 44), "ho".to_owned());
+ alist_add(&lst, 22, "hi".to_string());
+ alist_add(&lst, 44, "ho".to_string());
+ assert_eq!(alist_get(&lst, 22), "hi".to_string());
+ assert_eq!(alist_get(&lst, 44), "ho".to_string());
let lst = new_int_alist_2();
- alist_add(&lst, 22, "hi".to_owned());
- alist_add(&lst, 44, "ho".to_owned());
- assert_eq!(alist_get(&lst, 22), "hi".to_owned());
- assert_eq!(alist_get(&lst, 44), "ho".to_owned());
+ alist_add(&lst, 22, "hi".to_string());
+ alist_add(&lst, 44, "ho".to_string());
+ assert_eq!(alist_get(&lst, 22), "hi".to_string());
+ assert_eq!(alist_get(&lst, 44), "ho".to_string());
}
pub fn main() {
let mut nyan : cat<char> = cat::<char>(52u, 99, vec!('p'));
- let mut kitty = cat(1000u, 2, vec!("tabby".to_owned()));
+ let mut kitty = cat(1000u, 2, vec!("tabby".to_string()));
assert_eq!(nyan.how_hungry, 99);
assert_eq!(kitty.how_hungry, 2);
nyan.speak(vec!(1u,2u,3u));
assert_eq!(nyan.meow_count(), 55u);
- kitty.speak(vec!("meow".to_owned(), "mew".to_owned(), "purr".to_owned(), "chirp".to_owned()));
+ kitty.speak(vec!("meow".to_string(), "mew".to_string(), "purr".to_string(), "chirp".to_string()));
assert_eq!(kitty.meow_count(), 1004u);
}
pub fn main() {
let mut nyan : cat<int> = cat::<int>(52u, 99, vec!(9));
- let mut kitty = cat(1000u, 2, vec!("tabby".to_owned()));
+ let mut kitty = cat(1000u, 2, vec!("tabby".to_string()));
assert_eq!(nyan.how_hungry, 99);
assert_eq!(kitty.how_hungry, 2);
nyan.speak(vec!(1,2,3));
assert_eq!(nyan.meow_count(), 55u);
- kitty.speak(vec!("meow".to_owned(), "mew".to_owned(), "purr".to_owned(), "chirp".to_owned()));
+ kitty.speak(vec!("meow".to_string(), "mew".to_string(), "purr".to_string(), "chirp".to_string()));
assert_eq!(kitty.meow_count(), 1004u);
}
let args = os::args();
let args = args.as_slice();
- // Here, the rvalue `"signal".to_owned()` requires cleanup. Older versions
+ // Here, the rvalue `"signal".to_string()` requires cleanup. Older versions
// of the code had a problem that the cleanup scope for this
- // expression was the end of the `if`, and as the `"signal".to_owned()`
+ // expression was the end of the `if`, and as the `"signal".to_string()`
// expression was never evaluated, we wound up trying to clean
// uninitialized memory.
pub fn main() {
/*foo(1);
- foo("hi".to_owned());
+ foo("hi".to_string());
foo(~[1, 2, 3]);
foo(F{field: 42});
foo((1, 2u));
unsafe {
let foo = &A as *u8;
assert_eq!(str::raw::from_utf8(A), "hi");
- assert_eq!(str::raw::from_buf_len(foo, A.len()), "hi".to_owned());
- assert_eq!(str::raw::from_buf_len(C, B.len()), "hi".to_owned());
+ assert_eq!(str::raw::from_buf_len(foo, A.len()), "hi".to_string());
+ assert_eq!(str::raw::from_buf_len(C, B.len()), "hi".to_string());
assert!(*C == A[0]);
assert!(*(&B[0] as *u8) == A[0]);
let bar = str::raw::from_utf8(A).to_c_str();
- assert_eq!(bar.with_ref(|buf| str::raw::from_c_str(buf)), "hi".to_owned());
+ assert_eq!(bar.with_ref(|buf| str::raw::from_c_str(buf)), "hi".to_string());
}
}
}
fn test_str() {
- let rs = if true { "happy".to_owned() } else { "sad".to_owned() };
- assert_eq!(rs, "happy".to_owned());
+ let rs = if true { "happy".to_string() } else { "sad".to_string() };
+ assert_eq!(rs, "happy".to_string());
}
pub fn main() { test_box(); test_str(); }
}
fn test_str() {
- let res = match true { true => { "happy".to_owned() },
+ let res = match true { true => { "happy".to_string() },
_ => fail!("not happy at all") };
- assert_eq!(res, "happy".to_owned());
+ assert_eq!(res, "happy".to_string());
}
pub fn main() { test_box(); test_str(); }
// This used to cause memory corruption in stage 0.
enum thing<K> { some(K), }
-pub fn main() { let _x = some("hi".to_owned()); }
+pub fn main() { let _x = some("hi".to_string()); }
t!(format!("{}", 1.0f32), "1");
t!(format!("{}", 1.0f64), "1");
t!(format!("{}", "a"), "a");
- t!(format!("{}", "a".to_owned()), "a");
+ t!(format!("{}", "a".to_string()), "a");
t!(format!("{}", false), "false");
t!(format!("{}", 'a'), "a");
t!(format!("{:x}", 10u), "a");
t!(format!("{:X}", 10u), "A");
t!(format!("{:s}", "foo"), "foo");
- t!(format!("{:s}", "foo".to_owned()), "foo");
+ t!(format!("{:s}", "foo".to_string()), "foo");
t!(format!("{:p}", 0x1234 as *int), "0x1234");
t!(format!("{:p}", 0x1234 as *mut int), "0x1234");
t!(format!("{:d}", A), "aloha");
pub fn main() {
let x = 2;
let x_message = match x {
- 0 .. 1 => { "not many".to_owned() }
- _ => { "lots".to_owned() }
+ 0 .. 1 => { "not many".to_string() }
+ _ => { "lots".to_string() }
};
- assert_eq!(x_message, "lots".to_owned());
+ assert_eq!(x_message, "lots".to_string());
let y = 2i;
let y_message = match y {
- 0 .. 1 => { "not many".to_owned() }
- _ => { "lots".to_owned() }
+ 0 .. 1 => { "not many".to_string() }
+ _ => { "lots".to_string() }
};
- assert_eq!(y_message, "lots".to_owned());
+ assert_eq!(y_message, "lots".to_string());
let z = 1u64;
let z_message = match z {
- 0 .. 1 => { "not many".to_owned() }
- _ => { "lots".to_owned() }
+ 0 .. 1 => { "not many".to_string() }
+ _ => { "lots".to_string() }
};
- assert_eq!(z_message, "not many".to_owned());
+ assert_eq!(z_message, "not many".to_string());
}
// except according to those terms.
pub fn main () {
- let mut line = "".to_owned();
+ let mut line = "".to_string();
let mut i = 0;
- while line != "exit".to_owned() {
- line = if i == 9 { "exit".to_owned() } else { "notexit".to_owned() };
+ while line != "exit".to_string() {
+ line = if i == 9 { "exit".to_string() } else { "notexit".to_string() };
i += 1;
}
}
// Issue 1974
// Don't double free the condition allocation
pub fn main() {
- let s = "hej".to_owned();
- while s != "".to_owned() {
+ let s = "hej".to_string();
+ while s != "".to_string() {
return;
}
}
}
fn deadcode() {
- perform_hax(box "deadcode".to_owned());
+ perform_hax(box "deadcode".to_string());
}
pub fn main() {
}
fn deadcode() {
- perform_hax(box "deadcode".to_owned());
+ perform_hax(box "deadcode".to_string());
}
pub fn main() {
impl fmt::Show for square {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", match *self {
- bot => { "R".to_owned() }
- wall => { "#".to_owned() }
- rock => { "*".to_owned() }
- lambda => { "\\".to_owned() }
- closed_lift => { "L".to_owned() }
- open_lift => { "O".to_owned() }
- earth => { ".".to_owned() }
- empty => { " ".to_owned() }
+ bot => { "R".to_string() }
+ wall => { "#".to_string() }
+ rock => { "*".to_string() }
+ lambda => { "\\".to_string() }
+ closed_lift => { "L".to_string() }
+ open_lift => { "O".to_string() }
+ earth => { ".".to_string() }
+ empty => { " ".to_string() }
})
}
}
pub fn main()
{
-// assert!(check_strs(fmt!("%?", Text(@"foo".to_owned())), "Text(@~\"foo\")"));
-// assert!(check_strs(fmt!("%?", ETag(@~["foo".to_owned()], @"bar".to_owned())),
+// assert!(check_strs(fmt!("%?", Text(@"foo".to_string())), "Text(@~\"foo\")"));
+// assert!(check_strs(fmt!("%?", ETag(@~["foo".to_string()], @"bar".to_string())),
// "ETag(@~[ ~\"foo\" ], @~\"bar\")"));
let t = Text(@"foo".to_strbuf());
}
priv fn cmd_to_str(cmd: ~[String]) -> String {
- let mut res = "*".to_owned();
+ let mut res = "*".to_string();
res.push_str(cmd.len().to_str());
res.push_str("\r\n");
for s in cmd.iter() {
- res.push_str(["$".to_owned(), s.len().to_str(), "\r\n".to_owned(),
- (*s).clone(), "\r\n".to_owned()].concat() );
+ res.push_str(["$".to_string(), s.len().to_str(), "\r\n".to_string(),
+ (*s).clone(), "\r\n".to_string()].concat() );
}
res
}
fn query2(cmd: ~[String]) -> Result {
let _cmd = cmd_to_str(cmd);
- io::with_str_reader("$3\r\nXXX\r\n".to_owned())(|sb| {
+ io::with_str_reader("$3\r\nXXX\r\n".to_string())(|sb| {
let res = parse_response(@sb as @io::Reader);
println!("{:?}", res);
res
for i in x.iter() { println!("{:?}", *i); y += *i; }
println!("{:?}", y);
assert_eq!(y, 6);
- let s = "hello there".to_owned();
+ let s = "hello there".to_string();
let mut i: int = 0;
for c in s.as_slice().bytes() {
if i == 0 { assert!((c == 'h' as u8)); }
return
}
- let env = [("RUST_LOG".to_owned(), "debug".to_owned())];
+ let env = [("RUST_LOG".to_string(), "debug".to_string())];
let p = Command::new(args[0].as_slice())
.arg("child").env(env.as_slice())
.spawn().unwrap().wait_with_output().unwrap();
fn test1() {
// from issue 6338
- match ((1, "a".to_owned()), (2, "b".to_owned())) {
+ match ((1, "a".to_string()), (2, "b".to_string())) {
((1, a), (2, b)) | ((2, b), (1, a)) => {
- assert_eq!(a, "a".to_owned());
- assert_eq!(b, "b".to_owned());
+ assert_eq!(a, "a".to_string());
+ assert_eq!(b, "b".to_string());
},
_ => fail!(),
}
use std::task;
pub fn main() {
- let x = "Hello world!".to_owned();
+ let x = "Hello world!".to_string();
task::spawn(proc() {
println!("{}", x);
});
}
pub fn main() {
- let foo = "foo".to_owned();
- let bar = "bar".to_owned();
+ let foo = "foo".to_string();
+ let bar = "bar".to_string();
let mut list = AssociationList {pairs: Vec::new()};
list.push(foo.clone(), 22);
*i.borrow_mut() = 5;
assert_eq!((i_value, *i.borrow()), (2, 5));
- let s = Rc::new("foo".to_owned());
+ let s = Rc::new("foo".to_string());
assert!(s.equiv(&("foo")));
assert_eq!(s.as_slice(), "foo");
*(*i).borrow_mut() = 5;
assert_eq!((i_value, *(*i).borrow()), (2, 5));
- let s = Rc::new("foo".to_owned());
- assert_eq!(*s, "foo".to_owned());
+ let s = Rc::new("foo".to_string());
+ assert_eq!(*s, "foo".to_string());
assert_eq!((*s).as_slice(), "foo");
let mut_s = Rc::new(RefCell::new(String::from_str("foo")));
})
});
assert!((ostream as uint != 0u));
- let s = "hello".to_owned();
+ let s = "hello".to_string();
"hello".with_c_str(|buf| {
let write_len = libc::fwrite(buf as *libc::c_void,
1u as libc::size_t,
pub fn main() {
let mut map: HashMap<SendStr, uint> = HashMap::new();
assert!(map.insert(Slice("foo"), 42));
- assert!(!map.insert(Owned("foo".to_owned()), 42));
+ assert!(!map.insert(Owned("foo".to_string()), 42));
assert!(!map.insert(Slice("foo"), 42));
- assert!(!map.insert(Owned("foo".to_owned()), 42));
+ assert!(!map.insert(Owned("foo".to_string()), 42));
assert!(!map.insert(Slice("foo"), 43));
- assert!(!map.insert(Owned("foo".to_owned()), 44));
+ assert!(!map.insert(Owned("foo".to_string()), 44));
assert!(!map.insert(Slice("foo"), 45));
- assert!(!map.insert(Owned("foo".to_owned()), 46));
+ assert!(!map.insert(Owned("foo".to_string()), 46));
let v = 46;
- assert_eq!(map.find(&Owned("foo".to_owned())), Some(&v));
+ assert_eq!(map.find(&Owned("foo".to_string())), Some(&v));
assert_eq!(map.find(&Slice("foo")), Some(&v));
let (a, b, c, d) = (50, 51, 52, 53);
assert!(map.insert(Slice("abc"), a));
- assert!(map.insert(Owned("bcd".to_owned()), b));
+ assert!(map.insert(Owned("bcd".to_string()), b));
assert!(map.insert(Slice("cde"), c));
- assert!(map.insert(Owned("def".to_owned()), d));
+ assert!(map.insert(Owned("def".to_string()), d));
assert!(!map.insert(Slice("abc"), a));
- assert!(!map.insert(Owned("bcd".to_owned()), b));
+ assert!(!map.insert(Owned("bcd".to_string()), b));
assert!(!map.insert(Slice("cde"), c));
- assert!(!map.insert(Owned("def".to_owned()), d));
+ assert!(!map.insert(Owned("def".to_string()), d));
- assert!(!map.insert(Owned("abc".to_owned()), a));
+ assert!(!map.insert(Owned("abc".to_string()), a));
assert!(!map.insert(Slice("bcd"), b));
- assert!(!map.insert(Owned("cde".to_owned()), c));
+ assert!(!map.insert(Owned("cde".to_string()), c));
assert!(!map.insert(Slice("def"), d));
assert_eq!(map.find_equiv(&("abc")), Some(&a));
pub fn main() {
let mut map: TreeMap<SendStr, uint> = TreeMap::new();
assert!(map.insert(Slice("foo"), 42));
- assert!(!map.insert(Owned("foo".to_owned()), 42));
+ assert!(!map.insert(Owned("foo".to_string()), 42));
assert!(!map.insert(Slice("foo"), 42));
- assert!(!map.insert(Owned("foo".to_owned()), 42));
+ assert!(!map.insert(Owned("foo".to_string()), 42));
assert!(!map.insert(Slice("foo"), 43));
- assert!(!map.insert(Owned("foo".to_owned()), 44));
+ assert!(!map.insert(Owned("foo".to_string()), 44));
assert!(!map.insert(Slice("foo"), 45));
- assert!(!map.insert(Owned("foo".to_owned()), 46));
+ assert!(!map.insert(Owned("foo".to_string()), 46));
let v = 46;
- assert_eq!(map.find(&Owned("foo".to_owned())), Some(&v));
+ assert_eq!(map.find(&Owned("foo".to_string())), Some(&v));
assert_eq!(map.find(&Slice("foo")), Some(&v));
let (a, b, c, d) = (50, 51, 52, 53);
assert!(map.insert(Slice("abc"), a));
- assert!(map.insert(Owned("bcd".to_owned()), b));
+ assert!(map.insert(Owned("bcd".to_string()), b));
assert!(map.insert(Slice("cde"), c));
- assert!(map.insert(Owned("def".to_owned()), d));
+ assert!(map.insert(Owned("def".to_string()), d));
assert!(!map.insert(Slice("abc"), a));
- assert!(!map.insert(Owned("bcd".to_owned()), b));
+ assert!(!map.insert(Owned("bcd".to_string()), b));
assert!(!map.insert(Slice("cde"), c));
- assert!(!map.insert(Owned("def".to_owned()), d));
+ assert!(!map.insert(Owned("def".to_string()), d));
- assert!(!map.insert(Owned("abc".to_owned()), a));
+ assert!(!map.insert(Owned("abc".to_string()), a));
assert!(!map.insert(Slice("bcd"), b));
- assert!(!map.insert(Owned("cde".to_owned()), c));
+ assert!(!map.insert(Owned("cde".to_string()), c));
assert!(!map.insert(Slice("def"), d));
assert_eq!(map.find(&Slice("abc")), Some(&a));
assert_eq!(map.find(&Slice("cde")), Some(&c));
assert_eq!(map.find(&Slice("def")), Some(&d));
- assert_eq!(map.find(&Owned("abc".to_owned())), Some(&a));
- assert_eq!(map.find(&Owned("bcd".to_owned())), Some(&b));
- assert_eq!(map.find(&Owned("cde".to_owned())), Some(&c));
- assert_eq!(map.find(&Owned("def".to_owned())), Some(&d));
+ assert_eq!(map.find(&Owned("abc".to_string())), Some(&a));
+ assert_eq!(map.find(&Owned("bcd".to_string())), Some(&b));
+ assert_eq!(map.find(&Owned("cde".to_string())), Some(&c));
+ assert_eq!(map.find(&Owned("def".to_string())), Some(&d));
assert!(map.pop(&Slice("foo")).is_some());
assert_eq!(map.move_iter().map(|(k, v)| format_strbuf!("{}{}", k, v))
.collect::<Vec<String>>()
.concat(),
- "abc50bcd51cde52def53".to_owned());
+ "abc50bcd51cde52def53".to_string());
}
pub fn main() {
- assert!(("hello".to_owned() < "hellr".to_owned()));
- assert!(("hello ".to_owned() > "hello".to_owned()));
- assert!(("hello".to_owned() != "there".to_owned()));
+ assert!(("hello".to_string() < "hellr".to_string()));
+ assert!(("hello ".to_string() > "hello".to_string()));
+ assert!(("hello".to_string() != "there".to_string()));
assert!((vec!(1, 2, 3, 4) > vec!(1, 2, 3)));
assert!((vec!(1, 2, 3) < vec!(1, 2, 3, 4)));
assert!((vec!(1, 2, 4, 4) > vec!(1, 2, 3, 4)));
pub fn main() {
- let s = "hello".to_owned();
+ let s = "hello".to_string();
let c: u8 = s.as_slice()[4];
println!("{:?}", c);
assert_eq!(c, 0x6f as u8);
assert_eq!(foo, foo_);
let foo = Foo {
- bar: "one".to_owned(),
- baz: "two".to_owned()
+ bar: "one".to_string(),
+ baz: "two".to_string()
};
let foo_ = foo.clone();
fn test_str() {
let (tx, rx) = channel();
- let s0 = "test".to_owned();
+ let s0 = "test".to_string();
tx.send(s0);
let s1 = rx.recv();
assert_eq!(s1.as_slice()[0], 't' as u8);
pub fn main() {
assert_eq!(3.do_get2(), (3, 3));
- assert_eq!(Some("hi".to_owned()).do_get2(), ("hi".to_owned(), "hi".to_owned()));
+ assert_eq!(Some("hi".to_string()).do_get2(), ("hi".to_string(), "hi".to_string()));
}
fn empty_pointy() -> @RefCell<Pointy> {
return @RefCell::new(Pointy {
a : none,
- d : make_uniq_closure("hi".to_owned())
+ d : make_uniq_closure("hi".to_string())
})
}