about summary refs log tree commit diff
diff options
context:
space:
mode:
authorP1start <rewi-github@whanau.org>2014-05-26 16:41:35 +1200
committerP1start <rewi-github@whanau.org>2014-05-26 16:52:12 +1200
commitc1fd3459fa69f7f93685dde5ca23ff432dbe231a (patch)
tree443c566b5be47a586f6629ad9fa1d4c4b5b2f720
parent20a41519fd92c50c44132870a95415159a1d09ea (diff)
downloadrust-c1fd3459fa69f7f93685dde5ca23ff432dbe231a.tar.gz
rust-c1fd3459fa69f7f93685dde5ca23ff432dbe231a.zip
Minor fixes to `std::str` docs
This tweaks the `std::str` docs to compensate for the recent shift from `~str`
to `String`.
-rw-r--r--src/libstd/str.rs23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/libstd/str.rs b/src/libstd/str.rs
index d68ed099a4a..69977b254bb 100644
--- a/src/libstd/str.rs
+++ b/src/libstd/str.rs
@@ -16,15 +16,16 @@ Unicode string manipulation (`str` type)
 
 Rust's string type is one of the core primitive types of the language. While
 represented by the name `str`, the name `str` is not actually a valid type in
-Rust. Each string must also be decorated with its ownership. This means that
-there is one common kind of string in Rust:
+Rust. Each string must also be decorated with a pointer. `String` is used
+for an owned string, so there is only one commonly-used `str` type in Rust:
+`&str`.
 
-* `&str` - This is the borrowed string type. This type of string can only be
-           created from the other kind of string. As the name "borrowed"
-           implies, this type of string is owned elsewhere, and this string
-           cannot be moved out of.
+`&str` is the borrowed string type. This type of string can only be created
+from other strings, unless it is a static string (see below). As the word
+"borrowed" implies, this type of string is owned elsewhere, and this string
+cannot be moved out of.
 
-As an example, here's the one kind of string.
+As an example, here's some code that uses a string.
 
 ```rust
 fn main() {
@@ -32,8 +33,8 @@ fn main() {
 }
 ```
 
-From the example above, you can see that Rust has 1 different kind of string
-literal. The "borrowed literal" is akin to C's concept of a static string.
+From the example above, you can see that Rust's string literals have the
+`'static` lifetime. This is akin to C's concept of a static string.
 
 String literals are allocated statically in the rodata of the
 executable/library. The string then has the type `&'static str` meaning that
@@ -509,7 +510,7 @@ pub fn from_utf8_lossy<'a>(v: &'a [u8]) -> MaybeOwned<'a> {
 Section: MaybeOwned
 */
 
-/// A MaybeOwned is a string that can hold either a String or a &str.
+/// A `MaybeOwned` is a string that can hold either a `String` or a `&str`.
 /// This can be useful as an optimization when an allocation is sometimes
 /// needed but not always.
 pub enum MaybeOwned<'a> {
@@ -519,7 +520,7 @@ pub enum MaybeOwned<'a> {
     Owned(String)
 }
 
-/// SendStr is a specialization of `MaybeOwned` to be sendable
+/// `SendStr` is a specialization of `MaybeOwned` to be sendable
 pub type SendStr = MaybeOwned<'static>;
 
 impl<'a> MaybeOwned<'a> {