Skip to content

Commit d5c3bec

Browse files
author
Stjepan Glavina
committed
Change to_owned to to_string in docs
We should teach conversion from `str` to `String` using `to_string` rather than the legacy `to_owned`.
1 parent e357178 commit d5c3bec

File tree

4 files changed

+14
-14
lines changed

4 files changed

+14
-14
lines changed

src/libcollections/btree/map.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1990,11 +1990,11 @@ impl<'a, K: Ord, V> Entry<'a, K, V> {
19901990
/// use std::collections::BTreeMap;
19911991
///
19921992
/// let mut map: BTreeMap<&str, String> = BTreeMap::new();
1993-
/// let s = "hoho".to_owned();
1993+
/// let s = "hoho".to_string();
19941994
///
19951995
/// map.entry("poneyland").or_insert_with(|| s);
19961996
///
1997-
/// assert_eq!(map["poneyland"], "hoho".to_owned());
1997+
/// assert_eq!(map["poneyland"], "hoho".to_string());
19981998
/// ```
19991999
#[stable(feature = "rust1", since = "1.0.0")]
20002000
pub fn or_insert_with<F: FnOnce() -> V>(self, default: F) -> &'a mut V {

src/libcore/any.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ pub trait Any: 'static {
101101
///
102102
/// fn main() {
103103
/// assert_eq!(is_string(&0), false);
104-
/// assert_eq!(is_string(&"cookie monster".to_owned()), true);
104+
/// assert_eq!(is_string(&"cookie monster".to_string()), true);
105105
/// }
106106
/// ```
107107
#[unstable(feature = "get_type_id",
@@ -154,7 +154,7 @@ impl Any {
154154
///
155155
/// fn main() {
156156
/// is_string(&0);
157-
/// is_string(&"cookie monster".to_owned());
157+
/// is_string(&"cookie monster".to_string());
158158
/// }
159159
/// ```
160160
#[stable(feature = "rust1", since = "1.0.0")]
@@ -188,7 +188,7 @@ impl Any {
188188
///
189189
/// fn main() {
190190
/// print_if_string(&0);
191-
/// print_if_string(&"cookie monster".to_owned());
191+
/// print_if_string(&"cookie monster".to_string());
192192
/// }
193193
/// ```
194194
#[stable(feature = "rust1", since = "1.0.0")]
@@ -219,7 +219,7 @@ impl Any {
219219
///
220220
/// fn main() {
221221
/// let mut x = 10u32;
222-
/// let mut s = "starlord".to_owned();
222+
/// let mut s = "starlord".to_string();
223223
///
224224
/// modify_if_u32(&mut x);
225225
/// modify_if_u32(&mut s);
@@ -259,7 +259,7 @@ impl Any+Send {
259259
///
260260
/// fn main() {
261261
/// is_string(&0);
262-
/// is_string(&"cookie monster".to_owned());
262+
/// is_string(&"cookie monster".to_string());
263263
/// }
264264
/// ```
265265
#[stable(feature = "rust1", since = "1.0.0")]
@@ -285,7 +285,7 @@ impl Any+Send {
285285
///
286286
/// fn main() {
287287
/// print_if_string(&0);
288-
/// print_if_string(&"cookie monster".to_owned());
288+
/// print_if_string(&"cookie monster".to_string());
289289
/// }
290290
/// ```
291291
#[stable(feature = "rust1", since = "1.0.0")]
@@ -309,7 +309,7 @@ impl Any+Send {
309309
///
310310
/// fn main() {
311311
/// let mut x = 10u32;
312-
/// let mut s = "starlord".to_owned();
312+
/// let mut s = "starlord".to_string();
313313
///
314314
/// modify_if_u32(&mut x);
315315
/// modify_if_u32(&mut s);
@@ -359,7 +359,7 @@ impl TypeId {
359359
///
360360
/// fn main() {
361361
/// assert_eq!(is_string(&0), false);
362-
/// assert_eq!(is_string(&"cookie monster".to_owned()), true);
362+
/// assert_eq!(is_string(&"cookie monster".to_string()), true);
363363
/// }
364364
/// ```
365365
#[stable(feature = "rust1", since = "1.0.0")]

src/libstd/collections/hash/map.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1779,11 +1779,11 @@ impl<'a, K, V> Entry<'a, K, V> {
17791779
/// use std::collections::HashMap;
17801780
///
17811781
/// let mut map: HashMap<&str, String> = HashMap::new();
1782-
/// let s = "hoho".to_owned();
1782+
/// let s = "hoho".to_string();
17831783
///
17841784
/// map.entry("poneyland").or_insert_with(|| s);
17851785
///
1786-
/// assert_eq!(map["poneyland"], "hoho".to_owned());
1786+
/// assert_eq!(map["poneyland"], "hoho".to_string());
17871787
/// ```
17881788
pub fn or_insert_with<F: FnOnce() -> V>(self, default: F) -> &'a mut V {
17891789
match self {

src/libstd/io/error.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -388,12 +388,12 @@ impl Error {
388388
/// impl MyError {
389389
/// fn new() -> MyError {
390390
/// MyError {
391-
/// v: "oh no!".to_owned()
391+
/// v: "oh no!".to_string()
392392
/// }
393393
/// }
394394
///
395395
/// fn change_message(&mut self, new_message: &str) {
396-
/// self.v = new_message.to_owned();
396+
/// self.v = new_message.to_string();
397397
/// }
398398
/// }
399399
///

0 commit comments

Comments
 (0)