Skip to content

Commit c160192

Browse files
committed
Replace usage of String::from_str with String:from
1 parent 2ff4243 commit c160192

File tree

29 files changed

+105
-106
lines changed

29 files changed

+105
-106
lines changed

src/compiletest/runtest.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,7 @@ fn run_debuginfo_lldb_test(config: &Config, props: &TestProps, testfile: &Path)
651651

652652
// Write debugger script:
653653
// We don't want to hang when calling `quit` while the process is still running
654-
let mut script_str = String::from_str("settings set auto-confirm true\n");
654+
let mut script_str = String::from("settings set auto-confirm true\n");
655655

656656
// Make LLDB emit its version, so we have it documented in the test output
657657
script_str.push_str("version\n");

src/grammar/verify.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ fn main() {
287287
let options = config::basic_options();
288288
let session = session::build_session(options, None,
289289
syntax::diagnostics::registry::Registry::new(&[]));
290-
let filemap = session.parse_sess.codemap().new_filemap(String::from_str("<n/a>"), code);
290+
let filemap = session.parse_sess.codemap().new_filemap(String::from("<n/a>"), code);
291291
let mut lexer = lexer::StringReader::new(session.diagnostic(), filemap);
292292
let cm = session.codemap();
293293

src/libcollections/string.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ impl String {
8989
///
9090
/// ```
9191
/// # #![feature(collections)]
92-
/// let s = String::from_str("hello");
92+
/// let s = String::from("hello");
9393
/// assert_eq!(&s[..], "hello");
9494
/// ```
9595
#[inline]
@@ -1002,7 +1002,7 @@ pub fn as_string<'a>(x: &'a str) -> DerefString<'a> {
10021002
DerefString { x: as_vec(x.as_bytes()) }
10031003
}
10041004

1005-
/// Error returned from `String::from_str`
1005+
/// Error returned from `String::from`
10061006
#[unstable(feature = "str_parse_error", reason = "may want to be replaced with \
10071007
Void if it ever exists")]
10081008
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
@@ -1013,7 +1013,7 @@ impl FromStr for String {
10131013
type Err = ParseError;
10141014
#[inline]
10151015
fn from_str(s: &str) -> Result<String, ParseError> {
1016-
Ok(String::from_str(s))
1016+
Ok(String::from(s))
10171017
}
10181018
}
10191019

src/libcollectionstest/str.rs

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -71,17 +71,17 @@ fn test_rfind() {
7171

7272
#[test]
7373
fn test_collect() {
74-
let empty = String::from_str("");
74+
let empty = String::from("");
7575
let s: String = empty.chars().collect();
7676
assert_eq!(empty, s);
77-
let data = String::from_str("ประเทศไทย中");
77+
let data = String::from("ประเทศไทย中");
7878
let s: String = data.chars().collect();
7979
assert_eq!(data, s);
8080
}
8181

8282
#[test]
8383
fn test_into_bytes() {
84-
let data = String::from_str("asdf");
84+
let data = String::from("asdf");
8585
let buf = data.into_bytes();
8686
assert_eq!(buf, b"asdf");
8787
}
@@ -98,7 +98,7 @@ fn test_find_str() {
9898
assert!(data[2..4].find("ab").is_none());
9999

100100
let string = "ประเทศไทย中华Việt Nam";
101-
let mut data = String::from_str(string);
101+
let mut data = String::from(string);
102102
data.push_str(string);
103103
assert!(data.find("ไท华").is_none());
104104
assert_eq!(data[0..43].find(""), Some(0));
@@ -211,7 +211,7 @@ fn test_unsafe_slice() {
211211
}
212212
let letters = a_million_letter_a();
213213
assert!(half_a_million_letter_a() ==
214-
unsafe {String::from_str(letters.slice_unchecked(
214+
unsafe {String::from(letters.slice_unchecked(
215215
0,
216216
500000))});
217217
}
@@ -247,13 +247,13 @@ fn test_is_empty() {
247247
#[test]
248248
fn test_replace() {
249249
let a = "a";
250-
assert_eq!("".replace(a, "b"), String::from_str(""));
251-
assert_eq!("a".replace(a, "b"), String::from_str("b"));
252-
assert_eq!("ab".replace(a, "b"), String::from_str("bb"));
250+
assert_eq!("".replace(a, "b"), String::from(""));
251+
assert_eq!("a".replace(a, "b"), String::from("b"));
252+
assert_eq!("ab".replace(a, "b"), String::from("bb"));
253253
let test = "test";
254254
assert!(" test test ".replace(test, "toast") ==
255-
String::from_str(" toast toast "));
256-
assert_eq!(" test test ".replace(test, ""), String::from_str(" "));
255+
String::from(" toast toast "));
256+
assert_eq!(" test test ".replace(test, ""), String::from(" "));
257257
}
258258

259259
#[test]
@@ -328,7 +328,7 @@ fn test_slice() {
328328
}
329329
let letters = a_million_letter_x();
330330
assert!(half_a_million_letter_x() ==
331-
String::from_str(&letters[0..3 * 500000]));
331+
String::from(&letters[0..3 * 500000]));
332332
}
333333

334334
#[test]
@@ -581,7 +581,7 @@ fn test_as_bytes() {
581581
fn test_as_bytes_fail() {
582582
// Don't double free. (I'm not sure if this exercises the
583583
// original problem code path anymore.)
584-
let s = String::from_str("");
584+
let s = String::from("");
585585
let _bytes = s.as_bytes();
586586
panic!();
587587
}
@@ -623,10 +623,10 @@ fn test_subslice_offset_2() {
623623

624624
#[test]
625625
fn vec_str_conversions() {
626-
let s1: String = String::from_str("All mimsy were the borogoves");
626+
let s1: String = String::from("All mimsy were the borogoves");
627627

628628
let v: Vec<u8> = s1.as_bytes().to_vec();
629-
let s2: String = String::from_str(from_utf8(&v).unwrap());
629+
let s2: String = String::from(from_utf8(&v).unwrap());
630630
let mut i = 0;
631631
let n1 = s1.len();
632632
let n2 = v.len();
@@ -691,39 +691,39 @@ fn test_char_at_reverse() {
691691
#[test]
692692
fn test_escape_unicode() {
693693
assert_eq!("abc".escape_unicode(),
694-
String::from_str("\\u{61}\\u{62}\\u{63}"));
694+
String::from("\\u{61}\\u{62}\\u{63}"));
695695
assert_eq!("a c".escape_unicode(),
696-
String::from_str("\\u{61}\\u{20}\\u{63}"));
696+
String::from("\\u{61}\\u{20}\\u{63}"));
697697
assert_eq!("\r\n\t".escape_unicode(),
698-
String::from_str("\\u{d}\\u{a}\\u{9}"));
698+
String::from("\\u{d}\\u{a}\\u{9}"));
699699
assert_eq!("'\"\\".escape_unicode(),
700-
String::from_str("\\u{27}\\u{22}\\u{5c}"));
700+
String::from("\\u{27}\\u{22}\\u{5c}"));
701701
assert_eq!("\x00\x01\u{fe}\u{ff}".escape_unicode(),
702-
String::from_str("\\u{0}\\u{1}\\u{fe}\\u{ff}"));
702+
String::from("\\u{0}\\u{1}\\u{fe}\\u{ff}"));
703703
assert_eq!("\u{100}\u{ffff}".escape_unicode(),
704-
String::from_str("\\u{100}\\u{ffff}"));
704+
String::from("\\u{100}\\u{ffff}"));
705705
assert_eq!("\u{10000}\u{10ffff}".escape_unicode(),
706-
String::from_str("\\u{10000}\\u{10ffff}"));
706+
String::from("\\u{10000}\\u{10ffff}"));
707707
assert_eq!("ab\u{fb00}".escape_unicode(),
708-
String::from_str("\\u{61}\\u{62}\\u{fb00}"));
708+
String::from("\\u{61}\\u{62}\\u{fb00}"));
709709
assert_eq!("\u{1d4ea}\r".escape_unicode(),
710-
String::from_str("\\u{1d4ea}\\u{d}"));
710+
String::from("\\u{1d4ea}\\u{d}"));
711711
}
712712

713713
#[test]
714714
fn test_escape_default() {
715-
assert_eq!("abc".escape_default(), String::from_str("abc"));
716-
assert_eq!("a c".escape_default(), String::from_str("a c"));
717-
assert_eq!("\r\n\t".escape_default(), String::from_str("\\r\\n\\t"));
718-
assert_eq!("'\"\\".escape_default(), String::from_str("\\'\\\"\\\\"));
715+
assert_eq!("abc".escape_default(), String::from("abc"));
716+
assert_eq!("a c".escape_default(), String::from("a c"));
717+
assert_eq!("\r\n\t".escape_default(), String::from("\\r\\n\\t"));
718+
assert_eq!("'\"\\".escape_default(), String::from("\\'\\\"\\\\"));
719719
assert_eq!("\u{100}\u{ffff}".escape_default(),
720-
String::from_str("\\u{100}\\u{ffff}"));
720+
String::from("\\u{100}\\u{ffff}"));
721721
assert_eq!("\u{10000}\u{10ffff}".escape_default(),
722-
String::from_str("\\u{10000}\\u{10ffff}"));
722+
String::from("\\u{10000}\\u{10ffff}"));
723723
assert_eq!("ab\u{fb00}".escape_default(),
724-
String::from_str("ab\\u{fb00}"));
724+
String::from("ab\\u{fb00}"));
725725
assert_eq!("\u{1d4ea}\r".escape_default(),
726-
String::from_str("\\u{1d4ea}\\r"));
726+
String::from("\\u{1d4ea}\\r"));
727727
}
728728

729729
#[test]
@@ -1490,12 +1490,12 @@ fn test_str_container() {
14901490
v.iter().map(|x| x.len()).sum()
14911491
}
14921492

1493-
let s = String::from_str("01234");
1493+
let s = String::from("01234");
14941494
assert_eq!(5, sum_len(&["012", "", "34"]));
1495-
assert_eq!(5, sum_len(&[&String::from_str("01"),
1496-
&String::from_str("2"),
1497-
&String::from_str("34"),
1498-
&String::from_str("")]));
1495+
assert_eq!(5, sum_len(&[&String::from("01"),
1496+
&String::from("2"),
1497+
&String::from("34"),
1498+
&String::from("")]));
14991499
assert_eq!(5, sum_len(&[&s]));
15001500
}
15011501

0 commit comments

Comments
 (0)