Skip to content

Commit 4348e23

Browse files
committed
std: Remove String's to_owned
1 parent c7fe4ff commit 4348e23

File tree

113 files changed

+442
-438
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

113 files changed

+442
-438
lines changed

src/compiletest/compiletest.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -314,10 +314,10 @@ pub fn is_test(config: &Config, testfile: &Path) -> bool {
314314
// Pretty-printer does not work with .rc files yet
315315
let valid_extensions =
316316
match config.mode {
317-
Pretty => vec!(".rs".to_owned()),
318-
_ => vec!(".rc".to_owned(), ".rs".to_owned())
317+
Pretty => vec!(".rs".to_string()),
318+
_ => vec!(".rc".to_string(), ".rs".to_string())
319319
};
320-
let invalid_prefixes = vec!(".".to_owned(), "#".to_owned(), "~".to_owned());
320+
let invalid_prefixes = vec!(".".to_string(), "#".to_string(), "~".to_string());
321321
let name = testfile.filename_str().unwrap();
322322

323323
let mut valid = false;

src/compiletest/runtest.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1034,7 +1034,7 @@ fn compose_and_run_compiler(
10341034

10351035
let aux_dir = aux_output_dir_name(config, testfile);
10361036
// FIXME (#9639): This needs to handle non-utf8 paths
1037-
let extra_link_args = vec!("-L".to_owned(), aux_dir.as_str().unwrap().to_owned());
1037+
let extra_link_args = vec!("-L".to_string(), aux_dir.as_str().unwrap().to_owned());
10381038

10391039
for rel_ab in props.aux_builds.iter() {
10401040
let abs_ab = config.aux_base.join(rel_ab.as_slice());

src/doc/rust.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3538,7 +3538,7 @@ allocated on the heap (unlike closures). An example of creating and calling a
35383538
procedure:
35393539

35403540
```rust
3541-
let string = "Hello".to_owned();
3541+
let string = "Hello".to_string();
35423542

35433543
// Creates a new procedure, passing it to the `spawn` function.
35443544
spawn(proc() {

src/libcollections/bitv.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -988,10 +988,10 @@ mod tests {
988988
#[test]
989989
fn test_to_str() {
990990
let zerolen = Bitv::new(0u, false);
991-
assert_eq!(zerolen.to_str(), "".to_owned());
991+
assert_eq!(zerolen.to_str(), "".to_string());
992992

993993
let eightbits = Bitv::new(8u, false);
994-
assert_eq!(eightbits.to_str(), "00000000".to_owned());
994+
assert_eq!(eightbits.to_str(), "00000000".to_string());
995995
}
996996

997997
#[test]
@@ -1014,7 +1014,7 @@ mod tests {
10141014
let mut b = bitv::Bitv::new(2, false);
10151015
b.set(0, true);
10161016
b.set(1, false);
1017-
assert_eq!(b.to_str(), "10".to_owned());
1017+
assert_eq!(b.to_str(), "10".to_string());
10181018
}
10191019

10201020
#[test]
@@ -1343,7 +1343,7 @@ mod tests {
13431343
#[test]
13441344
fn test_from_bools() {
13451345
assert!(from_bools([true, false, true, true]).to_str() ==
1346-
"1011".to_owned());
1346+
"1011".to_string());
13471347
}
13481348

13491349
#[test]

src/libcollections/btree.rs

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -778,81 +778,81 @@ mod test_btree {
778778
//Tests the functionality of the insert methods (which are unfinished).
779779
#[test]
780780
fn insert_test_one() {
781-
let b = BTree::new(1, "abc".to_owned(), 2);
782-
let is_insert = b.insert(2, "xyz".to_owned());
781+
let b = BTree::new(1, "abc".to_string(), 2);
782+
let is_insert = b.insert(2, "xyz".to_string());
783783
//println!("{}", is_insert.clone().to_str());
784784
assert!(is_insert.root.is_leaf());
785785
}
786786

787787
#[test]
788788
fn insert_test_two() {
789-
let leaf_elt_1 = LeafElt::new(1, "aaa".to_owned());
790-
let leaf_elt_2 = LeafElt::new(2, "bbb".to_owned());
791-
let leaf_elt_3 = LeafElt::new(3, "ccc".to_owned());
789+
let leaf_elt_1 = LeafElt::new(1, "aaa".to_string());
790+
let leaf_elt_2 = LeafElt::new(2, "bbb".to_string());
791+
let leaf_elt_3 = LeafElt::new(3, "ccc".to_string());
792792
let n = Node::new_leaf(vec!(leaf_elt_1, leaf_elt_2, leaf_elt_3));
793793
let b = BTree::new_with_node_len(n, 3, 2);
794-
//println!("{}", b.clone().insert(4, "ddd".to_owned()).to_str());
795-
assert!(b.insert(4, "ddd".to_owned()).root.is_leaf());
794+
//println!("{}", b.clone().insert(4, "ddd".to_string()).to_str());
795+
assert!(b.insert(4, "ddd".to_string()).root.is_leaf());
796796
}
797797

798798
#[test]
799799
fn insert_test_three() {
800-
let leaf_elt_1 = LeafElt::new(1, "aaa".to_owned());
801-
let leaf_elt_2 = LeafElt::new(2, "bbb".to_owned());
802-
let leaf_elt_3 = LeafElt::new(3, "ccc".to_owned());
803-
let leaf_elt_4 = LeafElt::new(4, "ddd".to_owned());
800+
let leaf_elt_1 = LeafElt::new(1, "aaa".to_string());
801+
let leaf_elt_2 = LeafElt::new(2, "bbb".to_string());
802+
let leaf_elt_3 = LeafElt::new(3, "ccc".to_string());
803+
let leaf_elt_4 = LeafElt::new(4, "ddd".to_string());
804804
let n = Node::new_leaf(vec!(leaf_elt_1, leaf_elt_2, leaf_elt_3, leaf_elt_4));
805805
let b = BTree::new_with_node_len(n, 3, 2);
806-
//println!("{}", b.clone().insert(5, "eee".to_owned()).to_str());
807-
assert!(!b.insert(5, "eee".to_owned()).root.is_leaf());
806+
//println!("{}", b.clone().insert(5, "eee".to_string()).to_str());
807+
assert!(!b.insert(5, "eee".to_string()).root.is_leaf());
808808
}
809809

810810
#[test]
811811
fn insert_test_four() {
812-
let leaf_elt_1 = LeafElt::new(1, "aaa".to_owned());
813-
let leaf_elt_2 = LeafElt::new(2, "bbb".to_owned());
814-
let leaf_elt_3 = LeafElt::new(3, "ccc".to_owned());
815-
let leaf_elt_4 = LeafElt::new(4, "ddd".to_owned());
812+
let leaf_elt_1 = LeafElt::new(1, "aaa".to_string());
813+
let leaf_elt_2 = LeafElt::new(2, "bbb".to_string());
814+
let leaf_elt_3 = LeafElt::new(3, "ccc".to_string());
815+
let leaf_elt_4 = LeafElt::new(4, "ddd".to_string());
816816
let n = Node::new_leaf(vec!(leaf_elt_1, leaf_elt_2, leaf_elt_3, leaf_elt_4));
817817
let mut b = BTree::new_with_node_len(n, 3, 2);
818-
b = b.clone().insert(5, "eee".to_owned());
819-
b = b.clone().insert(6, "fff".to_owned());
820-
b = b.clone().insert(7, "ggg".to_owned());
821-
b = b.clone().insert(8, "hhh".to_owned());
822-
b = b.clone().insert(0, "omg".to_owned());
818+
b = b.clone().insert(5, "eee".to_string());
819+
b = b.clone().insert(6, "fff".to_string());
820+
b = b.clone().insert(7, "ggg".to_string());
821+
b = b.clone().insert(8, "hhh".to_string());
822+
b = b.clone().insert(0, "omg".to_string());
823823
//println!("{}", b.clone().to_str());
824824
assert!(!b.root.is_leaf());
825825
}
826826

827827
#[test]
828828
fn bsearch_test_one() {
829-
let b = BTree::new(1, "abc".to_owned(), 2);
829+
let b = BTree::new(1, "abc".to_string(), 2);
830830
assert_eq!(Some(1), b.root.bsearch_node(2));
831831
}
832832

833833
#[test]
834834
fn bsearch_test_two() {
835-
let b = BTree::new(1, "abc".to_owned(), 2);
835+
let b = BTree::new(1, "abc".to_string(), 2);
836836
assert_eq!(Some(0), b.root.bsearch_node(0));
837837
}
838838

839839
#[test]
840840
fn bsearch_test_three() {
841-
let leaf_elt_1 = LeafElt::new(1, "aaa".to_owned());
842-
let leaf_elt_2 = LeafElt::new(2, "bbb".to_owned());
843-
let leaf_elt_3 = LeafElt::new(4, "ccc".to_owned());
844-
let leaf_elt_4 = LeafElt::new(5, "ddd".to_owned());
841+
let leaf_elt_1 = LeafElt::new(1, "aaa".to_string());
842+
let leaf_elt_2 = LeafElt::new(2, "bbb".to_string());
843+
let leaf_elt_3 = LeafElt::new(4, "ccc".to_string());
844+
let leaf_elt_4 = LeafElt::new(5, "ddd".to_string());
845845
let n = Node::new_leaf(vec!(leaf_elt_1, leaf_elt_2, leaf_elt_3, leaf_elt_4));
846846
let b = BTree::new_with_node_len(n, 3, 2);
847847
assert_eq!(Some(2), b.root.bsearch_node(3));
848848
}
849849

850850
#[test]
851851
fn bsearch_test_four() {
852-
let leaf_elt_1 = LeafElt::new(1, "aaa".to_owned());
853-
let leaf_elt_2 = LeafElt::new(2, "bbb".to_owned());
854-
let leaf_elt_3 = LeafElt::new(4, "ccc".to_owned());
855-
let leaf_elt_4 = LeafElt::new(5, "ddd".to_owned());
852+
let leaf_elt_1 = LeafElt::new(1, "aaa".to_string());
853+
let leaf_elt_2 = LeafElt::new(2, "bbb".to_string());
854+
let leaf_elt_3 = LeafElt::new(4, "ccc".to_string());
855+
let leaf_elt_4 = LeafElt::new(5, "ddd".to_string());
856856
let n = Node::new_leaf(vec!(leaf_elt_1, leaf_elt_2, leaf_elt_3, leaf_elt_4));
857857
let b = BTree::new_with_node_len(n, 3, 2);
858858
assert_eq!(Some(4), b.root.bsearch_node(800));
@@ -861,48 +861,48 @@ mod test_btree {
861861
//Tests the functionality of the get method.
862862
#[test]
863863
fn get_test() {
864-
let b = BTree::new(1, "abc".to_owned(), 2);
864+
let b = BTree::new(1, "abc".to_string(), 2);
865865
let val = b.get(1);
866-
assert_eq!(val, Some("abc".to_owned()));
866+
assert_eq!(val, Some("abc".to_string()));
867867
}
868868

869869
//Tests the BTree's clone() method.
870870
#[test]
871871
fn btree_clone_test() {
872-
let b = BTree::new(1, "abc".to_owned(), 2);
872+
let b = BTree::new(1, "abc".to_string(), 2);
873873
let b2 = b.clone();
874874
assert!(b.root == b2.root)
875875
}
876876

877877
//Tests the BTree's cmp() method when one node is "less than" another.
878878
#[test]
879879
fn btree_cmp_test_less() {
880-
let b = BTree::new(1, "abc".to_owned(), 2);
881-
let b2 = BTree::new(2, "bcd".to_owned(), 2);
880+
let b = BTree::new(1, "abc".to_string(), 2);
881+
let b2 = BTree::new(2, "bcd".to_string(), 2);
882882
assert!(&b.cmp(&b2) == &Less)
883883
}
884884

885885
//Tests the BTree's cmp() method when two nodes are equal.
886886
#[test]
887887
fn btree_cmp_test_eq() {
888-
let b = BTree::new(1, "abc".to_owned(), 2);
889-
let b2 = BTree::new(1, "bcd".to_owned(), 2);
888+
let b = BTree::new(1, "abc".to_string(), 2);
889+
let b2 = BTree::new(1, "bcd".to_string(), 2);
890890
assert!(&b.cmp(&b2) == &Equal)
891891
}
892892

893893
//Tests the BTree's cmp() method when one node is "greater than" another.
894894
#[test]
895895
fn btree_cmp_test_greater() {
896-
let b = BTree::new(1, "abc".to_owned(), 2);
897-
let b2 = BTree::new(2, "bcd".to_owned(), 2);
896+
let b = BTree::new(1, "abc".to_string(), 2);
897+
let b2 = BTree::new(2, "bcd".to_string(), 2);
898898
assert!(&b2.cmp(&b) == &Greater)
899899
}
900900

901901
//Tests the BTree's to_str() method.
902902
#[test]
903903
fn btree_tostr_test() {
904-
let b = BTree::new(1, "abc".to_owned(), 2);
905-
assert_eq!(b.to_str(), "Key: 1, value: abc;".to_owned())
904+
let b = BTree::new(1, "abc".to_string(), 2);
905+
assert_eq!(b.to_str(), "Key: 1, value: abc;".to_string())
906906
}
907907

908908
}

src/libcollections/hashmap.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2026,9 +2026,9 @@ mod test_map {
20262026
let mut m = HashMap::new();
20272027

20282028
let (foo, bar, baz) = (1,2,3);
2029-
m.insert("foo".to_owned(), foo);
2030-
m.insert("bar".to_owned(), bar);
2031-
m.insert("baz".to_owned(), baz);
2029+
m.insert("foo".to_string(), foo);
2030+
m.insert("bar".to_string(), bar);
2031+
m.insert("baz".to_string(), baz);
20322032

20332033

20342034
assert_eq!(m.find_equiv(&("foo")), Some(&foo));
@@ -2313,8 +2313,8 @@ mod test_set {
23132313

23142314
let set_str = format!("{}", set);
23152315

2316-
assert!(set_str == "{1, 2}".to_owned() || set_str == "{2, 1}".to_owned());
2317-
assert_eq!(format!("{}", empty), "{}".to_owned());
2316+
assert!(set_str == "{1, 2}".to_string() || set_str == "{2, 1}".to_string());
2317+
assert_eq!(format!("{}", empty), "{}".to_string());
23182318
}
23192319
}
23202320

src/libcollections/lru_cache.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -319,15 +319,15 @@ mod tests {
319319
cache.put(1, 10);
320320
cache.put(2, 20);
321321
cache.put(3, 30);
322-
assert_eq!(cache.to_str(), "{3: 30, 2: 20, 1: 10}".to_owned());
322+
assert_eq!(cache.to_str(), "{3: 30, 2: 20, 1: 10}".to_string());
323323
cache.put(2, 22);
324-
assert_eq!(cache.to_str(), "{2: 22, 3: 30, 1: 10}".to_owned());
324+
assert_eq!(cache.to_str(), "{2: 22, 3: 30, 1: 10}".to_string());
325325
cache.put(6, 60);
326-
assert_eq!(cache.to_str(), "{6: 60, 2: 22, 3: 30}".to_owned());
326+
assert_eq!(cache.to_str(), "{6: 60, 2: 22, 3: 30}".to_string());
327327
cache.get(&3);
328-
assert_eq!(cache.to_str(), "{3: 30, 6: 60, 2: 22}".to_owned());
328+
assert_eq!(cache.to_str(), "{3: 30, 6: 60, 2: 22}".to_string());
329329
cache.change_capacity(2);
330-
assert_eq!(cache.to_str(), "{3: 30, 6: 60}".to_owned());
330+
assert_eq!(cache.to_str(), "{3: 30, 6: 60}".to_string());
331331
}
332332

333333
#[test]
@@ -338,6 +338,6 @@ mod tests {
338338
cache.clear();
339339
assert!(cache.get(&1).is_none());
340340
assert!(cache.get(&2).is_none());
341-
assert_eq!(cache.to_str(), "{}".to_owned());
341+
assert_eq!(cache.to_str(), "{}".to_string());
342342
}
343343
}

src/libcore/fmt/num.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ pub struct RadixFmt<T, R>(T, R);
140140
///
141141
/// ~~~
142142
/// use std::fmt::radix;
143-
/// assert_eq!(format!("{}", radix(55, 36)), "1j".to_owned());
143+
/// assert_eq!(format!("{}", radix(55, 36)), "1j".to_string());
144144
/// ~~~
145145
pub fn radix<T>(x: T, base: u8) -> RadixFmt<T, Radix> {
146146
RadixFmt(x, Radix::new(base))

src/libcore/mem.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ mod tests {
552552

553553
#[test]
554554
fn test_replace() {
555-
let mut x = Some("test".to_owned());
555+
let mut x = Some("test".to_string());
556556
let y = replace(&mut x, None);
557557
assert!(x.is_none());
558558
assert!(y.is_some());
@@ -576,7 +576,7 @@ mod tests {
576576
}
577577

578578
unsafe {
579-
assert!(Vec::from_slice([76u8]) == transmute("L".to_owned()));
579+
assert!(Vec::from_slice([76u8]) == transmute("L".to_string()));
580580
}
581581
}
582582
}

src/libcore/slice.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -925,15 +925,15 @@ pub trait MutableVector<'a, T> {
925925
/// # Example
926926
///
927927
/// ```rust
928-
/// let mut v = ~["foo".to_owned(), "bar".to_owned(), "baz".to_owned()];
928+
/// let mut v = ~["foo".to_string(), "bar".to_string(), "baz".to_string()];
929929
///
930930
/// unsafe {
931-
/// // `"baz".to_owned()` is deallocated.
932-
/// v.unsafe_set(2, "qux".to_owned());
931+
/// // `"baz".to_string()` is deallocated.
932+
/// v.unsafe_set(2, "qux".to_string());
933933
///
934934
/// // Out of bounds: could cause a crash, or overwriting
935935
/// // other data, or something else.
936-
/// // v.unsafe_set(10, "oops".to_owned());
936+
/// // v.unsafe_set(10, "oops".to_string());
937937
/// }
938938
/// ```
939939
unsafe fn unsafe_set(self, index: uint, val: T);
@@ -945,10 +945,10 @@ pub trait MutableVector<'a, T> {
945945
/// # Example
946946
///
947947
/// ```rust
948-
/// let mut v = ["foo".to_owned(), "bar".to_owned()];
948+
/// let mut v = ["foo".to_string(), "bar".to_string()];
949949
///
950-
/// // memory leak! `"bar".to_owned()` is not deallocated.
951-
/// unsafe { v.init_elem(1, "baz".to_owned()); }
950+
/// // memory leak! `"bar".to_string()` is not deallocated.
951+
/// unsafe { v.init_elem(1, "baz".to_string()); }
952952
/// ```
953953
unsafe fn init_elem(self, i: uint, val: T);
954954

src/libgetopts/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,7 @@ pub fn usage(brief: &str, opts: &[OptGroup]) -> String {
728728
each_split_within(desc_normalized_whitespace.as_slice(),
729729
54,
730730
|substr| {
731-
desc_rows.push(substr.to_owned());
731+
desc_rows.push(substr.to_string());
732732
true
733733
});
734734

src/libnative/io/process.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1103,24 +1103,24 @@ mod tests {
11031103

11041104
assert_eq!(
11051105
test_wrapper("prog", ["aaa", "bbb", "ccc"]),
1106-
"prog aaa bbb ccc".to_owned()
1106+
"prog aaa bbb ccc".to_string()
11071107
);
11081108

11091109
assert_eq!(
11101110
test_wrapper("C:\\Program Files\\blah\\blah.exe", ["aaa"]),
1111-
"\"C:\\Program Files\\blah\\blah.exe\" aaa".to_owned()
1111+
"\"C:\\Program Files\\blah\\blah.exe\" aaa".to_string()
11121112
);
11131113
assert_eq!(
11141114
test_wrapper("C:\\Program Files\\test", ["aa\"bb"]),
1115-
"\"C:\\Program Files\\test\" aa\\\"bb".to_owned()
1115+
"\"C:\\Program Files\\test\" aa\\\"bb".to_string()
11161116
);
11171117
assert_eq!(
11181118
test_wrapper("echo", ["a b c"]),
1119-
"echo \"a b c\"".to_owned()
1119+
"echo \"a b c\"".to_string()
11201120
);
11211121
assert_eq!(
11221122
test_wrapper("\u03c0\u042f\u97f3\u00e6\u221e", []),
1123-
"\u03c0\u042f\u97f3\u00e6\u221e".to_owned()
1123+
"\u03c0\u042f\u97f3\u00e6\u221e".to_string()
11241124
);
11251125
}
11261126
}

src/librustc/back/link.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,7 @@ pub fn exported_name(path: PathElems, hash: &str, vers: &str) -> String {
703703
let vers = if vers.len() > 0 && !char::is_XID_start(vers.char_at(0)) {
704704
format!("v{}", vers)
705705
} else {
706-
vers.to_owned()
706+
vers.to_string()
707707
};
708708

709709
mangle(path, Some(hash), Some(vers.as_slice()))

0 commit comments

Comments
 (0)