diff options
| author | Ulrik Sverdrup <root@localhost> | 2015-05-19 03:33:17 +0200 |
|---|---|---|
| committer | Ulrik Sverdrup <root@localhost> | 2015-05-19 03:33:17 +0200 |
| commit | 4e4374b7de0beec459f6d9db8e06f2cad0c969e7 (patch) | |
| tree | b0f1e553dc26cdd66b1af1ef233c5dd2fc571abc | |
| parent | 4daa62a55f906bd7ec7ad265cb23d49d9d0db66a (diff) | |
collections: Avoid unstable code in examples for String
Prefer String::from over from_str; String::from_str is unstable while String::from is stable. Promote the latter by using it in examples. Simply migrating unstable function to the closest alternative.
| -rw-r--r-- | src/liballoc/rc.rs | 4 | ||||
| -rw-r--r-- | src/libcollections/string.rs | 30 |
2 files changed, 11 insertions, 23 deletions
diff --git a/src/liballoc/rc.rs b/src/liballoc/rc.rs index 88c5c38172a..1e773b7f206 100644 --- a/src/liballoc/rc.rs +++ b/src/liballoc/rc.rs @@ -32,7 +32,7 @@ //! and have the `Owner` remain allocated as long as any `Gadget` points at it. //! //! ```rust -//! # #![feature(alloc, collections)] +//! # #![feature(alloc)] //! use std::rc::Rc; //! //! struct Owner { @@ -49,7 +49,7 @@ //! fn main() { //! // Create a reference counted Owner. //! let gadget_owner : Rc<Owner> = Rc::new( -//! Owner { name: String::from_str("Gadget Man") } +//! Owner { name: String::from("Gadget Man") } //! ); //! //! // Create Gadgets belonging to gadget_owner. To increment the reference diff --git a/src/libcollections/string.rs b/src/libcollections/string.rs index 1f2443d9771..7563bb76b52 100644 --- a/src/libcollections/string.rs +++ b/src/libcollections/string.rs @@ -121,9 +121,6 @@ impl String { /// # Examples /// /// ``` - /// # #![feature(core)] - /// use std::str::Utf8Error; - /// /// let hello_vec = vec![104, 101, 108, 108, 111]; /// let s = String::from_utf8(hello_vec).unwrap(); /// assert_eq!(s, "hello"); @@ -346,8 +343,7 @@ impl String { /// # Examples /// /// ``` - /// # #![feature(collections)] - /// let s = String::from_str("hello"); + /// let s = String::from("hello"); /// let bytes = s.into_bytes(); /// assert_eq!(bytes, [104, 101, 108, 108, 111]); /// ``` @@ -370,8 +366,7 @@ impl String { /// # Examples /// /// ``` - /// # #![feature(collections)] - /// let mut s = String::from_str("foo"); + /// let mut s = String::from("foo"); /// s.push_str("bar"); /// assert_eq!(s, "foobar"); /// ``` @@ -447,8 +442,7 @@ impl String { /// # Examples /// /// ``` - /// # #![feature(collections)] - /// let mut s = String::from_str("foo"); + /// let mut s = String::from("foo"); /// s.reserve(100); /// assert!(s.capacity() >= 100); /// s.shrink_to_fit(); @@ -465,8 +459,7 @@ impl String { /// # Examples /// /// ``` - /// # #![feature(collections)] - /// let mut s = String::from_str("abc"); + /// let mut s = String::from("abc"); /// s.push('1'); /// s.push('2'); /// s.push('3'); @@ -501,8 +494,7 @@ impl String { /// # Examples /// /// ``` - /// # #![feature(collections)] - /// let s = String::from_str("hello"); + /// let s = String::from("hello"); /// let b: &[_] = &[104, 101, 108, 108, 111]; /// assert_eq!(s.as_bytes(), b); /// ``` @@ -522,8 +514,7 @@ impl String { /// # Examples /// /// ``` - /// # #![feature(collections)] - /// let mut s = String::from_str("hello"); + /// let mut s = String::from("hello"); /// s.truncate(2); /// assert_eq!(s, "he"); /// ``` @@ -540,8 +531,7 @@ impl String { /// # Examples /// /// ``` - /// # #![feature(collections)] - /// let mut s = String::from_str("foo"); + /// let mut s = String::from("foo"); /// assert_eq!(s.pop(), Some('o')); /// assert_eq!(s.pop(), Some('o')); /// assert_eq!(s.pop(), Some('f')); @@ -578,8 +568,7 @@ impl String { /// # Examples /// /// ``` - /// # #![feature(collections)] - /// let mut s = String::from_str("foo"); + /// let mut s = String::from("foo"); /// assert_eq!(s.remove(0), 'f'); /// assert_eq!(s.remove(1), 'o'); /// assert_eq!(s.remove(0), 'o'); @@ -641,8 +630,7 @@ impl String { /// # Examples /// /// ``` - /// # #![feature(collections)] - /// let mut s = String::from_str("hello"); + /// let mut s = String::from("hello"); /// unsafe { /// let vec = s.as_mut_vec(); /// assert!(vec == &[104, 101, 108, 108, 111]); |
