about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorManish Goregaokar <manishsmail@gmail.com>2015-02-23 14:44:12 +0530
committerManish Goregaokar <manishsmail@gmail.com>2015-02-23 23:28:46 +0530
commit0fab2b95354f519e89e07d4e4d723c24372e75fd (patch)
tree48e5ae682aa609ccc3d50ff895b8b037986d918d /src
parent59726953cc5d27d73df1d024801394126b0854fa (diff)
parent96be55376ecdc13b0e711fe9398c70cd932af166 (diff)
downloadrust-0fab2b95354f519e89e07d4e4d723c24372e75fd.tar.gz
rust-0fab2b95354f519e89e07d4e4d723c24372e75fd.zip
Rollup merge of #22556 - brson:str, r=steveklabnik
 Clarify that `to_string` is how you make `String`. Use a coercion in an example.

r? @steveklabnik
Diffstat (limited to 'src')
-rw-r--r--src/doc/trpl/crates-and-modules.md2
-rw-r--r--src/doc/trpl/more-strings.md9
-rw-r--r--src/doc/trpl/strings.md6
3 files changed, 10 insertions, 7 deletions
diff --git a/src/doc/trpl/crates-and-modules.md b/src/doc/trpl/crates-and-modules.md
index 1f5d3eadae3..f3c0195855c 100644
--- a/src/doc/trpl/crates-and-modules.md
+++ b/src/doc/trpl/crates-and-modules.md
@@ -12,7 +12,7 @@ Rust has two distinct terms that relate to the module system: *crate* and
 *module*. A crate is synonymous with a *library* or *package* in other
 languages. Hence "Cargo" as the name of Rust's package management tool: you
 ship your crates to others with Cargo. Crates can produce an executable or a
-shared library, depending on the project.
+library, depending on the project.
 
 Each crate has an implicit *root module* that contains the code for that crate.
 You can then define a tree of sub-modules under that root module. Modules allow
diff --git a/src/doc/trpl/more-strings.md b/src/doc/trpl/more-strings.md
index 20f1406aebb..a2a558094e1 100644
--- a/src/doc/trpl/more-strings.md
+++ b/src/doc/trpl/more-strings.md
@@ -38,8 +38,9 @@ string literal or a `String`.
 
 # String
 
-A `String` is a heap-allocated string. This string is growable, and is also
-guaranteed to be UTF-8.
+A `String` is a heap-allocated string. This string is growable, and is
+also guaranteed to be UTF-8. `String`s are commonly created by
+converting from a string slice using the `to_string` method.
 
 ```
 let mut s = "Hello".to_string();
@@ -49,7 +50,7 @@ s.push_str(", world.");
 println!("{}", s);
 ```
 
-You can coerce a `String` into a `&str` by dereferencing it:
+A reference to a `String` will automatically coerce to a string slice:
 
 ```
 fn takes_slice(slice: &str) {
@@ -58,7 +59,7 @@ fn takes_slice(slice: &str) {
 
 fn main() {
     let s = "Hello".to_string();
-    takes_slice(&*s);
+    takes_slice(&s);
 }
 ```
 
diff --git a/src/doc/trpl/strings.md b/src/doc/trpl/strings.md
index 8ebebc98baf..2c2e6a8c7c5 100644
--- a/src/doc/trpl/strings.md
+++ b/src/doc/trpl/strings.md
@@ -25,8 +25,10 @@ compiled program, and exists for the entire duration it runs. The `string`
 binding is a reference to this statically allocated string. String slices
 have a fixed size, and cannot be mutated.
 
-A `String`, on the other hand, is an in-memory string.  This string is
-growable, and is also guaranteed to be UTF-8.
+A `String`, on the other hand, is a heap-allocated string. This string
+is growable, and is also guaranteed to be UTF-8. `String`s are
+commonly created by converting from a string slice using the
+`to_string` method.
 
 ```{rust}
 let mut s = "Hello".to_string(); // mut s: String