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.
//! and have the `Owner` remain allocated as long as any `Gadget` points at it.
//!
//! ```rust
//! 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 {
//! use std::rc::Rc;
//!
//! struct Owner {
//! fn main() {
//! // Create a reference counted Owner.
//! let gadget_owner : Rc<Owner> = Rc::new(
//! 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
//! );
//!
//! // Create Gadgets belonging to gadget_owner. To increment the reference
/// # Examples
///
/// ```
/// # 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");
/// let hello_vec = vec![104, 101, 108, 108, 111];
/// let s = String::from_utf8(hello_vec).unwrap();
/// assert_eq!(s, "hello");
/// # Examples
///
/// ```
/// # 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]);
/// ```
/// let bytes = s.into_bytes();
/// assert_eq!(bytes, [104, 101, 108, 108, 111]);
/// ```
/// # Examples
///
/// ```
/// # Examples
///
/// ```
- /// # #![feature(collections)]
- /// let mut s = String::from_str("foo");
+ /// let mut s = String::from("foo");
/// s.push_str("bar");
/// assert_eq!(s, "foobar");
/// ```
/// s.push_str("bar");
/// assert_eq!(s, "foobar");
/// ```
/// # Examples
///
/// ```
/// # 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();
/// s.reserve(100);
/// assert!(s.capacity() >= 100);
/// s.shrink_to_fit();
/// # Examples
///
/// ```
/// # 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');
/// s.push('1');
/// s.push('2');
/// s.push('3');
/// # Examples
///
/// ```
/// # 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);
/// ```
/// let b: &[_] = &[104, 101, 108, 108, 111];
/// assert_eq!(s.as_bytes(), b);
/// ```
/// # Examples
///
/// ```
/// # Examples
///
/// ```
- /// # #![feature(collections)]
- /// let mut s = String::from_str("hello");
+ /// let mut s = String::from("hello");
/// s.truncate(2);
/// assert_eq!(s, "he");
/// ```
/// s.truncate(2);
/// assert_eq!(s, "he");
/// ```
/// # Examples
///
/// ```
/// # 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'));
/// assert_eq!(s.pop(), Some('o'));
/// assert_eq!(s.pop(), Some('o'));
/// assert_eq!(s.pop(), Some('f'));
/// # Examples
///
/// ```
/// # 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');
/// assert_eq!(s.remove(0), 'f');
/// assert_eq!(s.remove(1), 'o');
/// assert_eq!(s.remove(0), 'o');
/// # Examples
///
/// ```
/// # 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]);
/// unsafe {
/// let vec = s.as_mut_vec();
/// assert!(vec == &[104, 101, 108, 108, 111]);