From 67867c663593e60108d09310752e5758b291e6ce Mon Sep 17 00:00:00 2001 From: Micah Tigley Date: Mon, 20 Mar 2017 13:11:58 -0600 Subject: [PATCH 1/4] Update docs for std::str --- src/libcollections/str.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/libcollections/str.rs b/src/libcollections/str.rs index 90e54a383d623..40abc8a96f066 100644 --- a/src/libcollections/str.rs +++ b/src/libcollections/str.rs @@ -59,6 +59,27 @@ pub use std_unicode::str::SplitWhitespace; #[stable(feature = "rust1", since = "1.0.0")] pub use core::str::pattern; +/// Unicode string slices. +/// +/// The `&str` type is one of the two main string types, the other being `String`. Unlike its `String` counterpart, its contents +/// are borrowed and therefore cannot be moved someplace else. +/// +/// # Basic Usage +/// A basic string declaration of `&str` type: +/// +/// ``` +/// let hello_world = "Hello, World!"; +/// ``` +/// Here we have declared a string literal, also known as a string slice. +/// String literals have a static lifetime, which means the string `hello_world` +/// is guaranteed to be valid for the duration of the entire program. We can explicitly specify +/// `hello_world`'s lifetime as well: +/// +/// ``` +/// let hello_world:&'static str = "Hello, world!"; +/// ``` +/// + #[unstable(feature = "slice_concat_ext", reason = "trait should not have to exist", issue = "27747")] From 63652726c39a0c018b7897f7c3e92690c3599207 Mon Sep 17 00:00:00 2001 From: Micah Tigley Date: Mon, 20 Mar 2017 15:21:28 -0600 Subject: [PATCH 2/4] Move str docs to proper place in file. --- src/libcollections/str.rs | 41 ++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/src/libcollections/str.rs b/src/libcollections/str.rs index 40abc8a96f066..c87e2b086adda 100644 --- a/src/libcollections/str.rs +++ b/src/libcollections/str.rs @@ -10,9 +10,27 @@ //! Unicode string slices. //! +//! The `&str` type is one of the two main string types, the other being `String`. Unlike its `String` counterpart, its contents +//! are borrowed and therefore cannot be moved someplace else. +//! +//! # Basic Usage +//! A basic string declaration of `&str` type: +//! +//! ``` +//! let hello_world = "Hello, World!"; +//! ``` +//! +//! Here we have declared a string literal, also known as a string slice. +//! String literals have a static lifetime, which means the string `hello_world` +//! is guaranteed to be valid for the duration of the entire program. We can explicitly specify +//! `hello_world`'s lifetime as well: +//! +//! ``` +//! let hello_world:&'static str = "Hello, world!"; +//! ``` +//! //! *[See also the `str` primitive type](../../std/primitive.str.html).* - #![stable(feature = "rust1", since = "1.0.0")] // Many of the usings in this module are only used in the test configuration. @@ -59,27 +77,6 @@ pub use std_unicode::str::SplitWhitespace; #[stable(feature = "rust1", since = "1.0.0")] pub use core::str::pattern; -/// Unicode string slices. -/// -/// The `&str` type is one of the two main string types, the other being `String`. Unlike its `String` counterpart, its contents -/// are borrowed and therefore cannot be moved someplace else. -/// -/// # Basic Usage -/// A basic string declaration of `&str` type: -/// -/// ``` -/// let hello_world = "Hello, World!"; -/// ``` -/// Here we have declared a string literal, also known as a string slice. -/// String literals have a static lifetime, which means the string `hello_world` -/// is guaranteed to be valid for the duration of the entire program. We can explicitly specify -/// `hello_world`'s lifetime as well: -/// -/// ``` -/// let hello_world:&'static str = "Hello, world!"; -/// ``` -/// - #[unstable(feature = "slice_concat_ext", reason = "trait should not have to exist", issue = "27747")] From f628117529dfb117d87d62803d0746bedd6e0e83 Mon Sep 17 00:00:00 2001 From: Micah Tigley Date: Mon, 20 Mar 2017 20:20:12 -0600 Subject: [PATCH 3/4] Fix Rust linting error --- src/libcollections/str.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/libcollections/str.rs b/src/libcollections/str.rs index c87e2b086adda..d4480ce77d646 100644 --- a/src/libcollections/str.rs +++ b/src/libcollections/str.rs @@ -10,8 +10,9 @@ //! Unicode string slices. //! -//! The `&str` type is one of the two main string types, the other being `String`. Unlike its `String` counterpart, its contents -//! are borrowed and therefore cannot be moved someplace else. +//! The `&str` type is one of the two main string types, the other being `String`. +//! Unlike its `String` counterpart, its contents are borrowed and therefore +//! cannot be moved someplace else. //! //! # Basic Usage //! A basic string declaration of `&str` type: @@ -22,8 +23,8 @@ //! //! Here we have declared a string literal, also known as a string slice. //! String literals have a static lifetime, which means the string `hello_world` -//! is guaranteed to be valid for the duration of the entire program. We can explicitly specify -//! `hello_world`'s lifetime as well: +//! is guaranteed to be valid for the duration of the entire program. +//! We can explicitly specify `hello_world`'s lifetime as well: //! //! ``` //! let hello_world:&'static str = "Hello, world!"; From da74e865b5a2400fb44660f989008208eb25d538 Mon Sep 17 00:00:00 2001 From: Micah Tigley Date: Mon, 27 Mar 2017 16:14:13 -0600 Subject: [PATCH 4/4] Review request changes --- src/libcollections/str.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libcollections/str.rs b/src/libcollections/str.rs index d4480ce77d646..34563e310df3b 100644 --- a/src/libcollections/str.rs +++ b/src/libcollections/str.rs @@ -11,10 +11,10 @@ //! Unicode string slices. //! //! The `&str` type is one of the two main string types, the other being `String`. -//! Unlike its `String` counterpart, its contents are borrowed and therefore -//! cannot be moved someplace else. +//! Unlike its `String` counterpart, its contents are borrowed. //! //! # Basic Usage +//! //! A basic string declaration of `&str` type: //! //! ``` @@ -27,7 +27,7 @@ //! We can explicitly specify `hello_world`'s lifetime as well: //! //! ``` -//! let hello_world:&'static str = "Hello, world!"; +//! let hello_world: &'static str = "Hello, world!"; //! ``` //! //! *[See also the `str` primitive type](../../std/primitive.str.html).*