about summary refs log tree commit diff
path: root/src/liballoc/string.rs
diff options
context:
space:
mode:
authorNatalie Boehm <nmb56@pitt.edu>2017-08-07 13:56:20 -0400
committerGitHub <noreply@github.com>2017-08-07 13:56:20 -0400
commit2a62b91343b4de94b6cfe401e8ad9bc0414f245f (patch)
tree55add8e63d4eff249b5529da3b11ca70e8ebacdb /src/liballoc/string.rs
parentb298a58c782f1434b09d4aaea6bffd4f99d3e7f6 (diff)
downloadrust-2a62b91343b4de94b6cfe401e8ad9bc0414f245f.tar.gz
rust-2a62b91343b4de94b6cfe401e8ad9bc0414f245f.zip
Update explanation of deref coercion
Diffstat (limited to 'src/liballoc/string.rs')
-rw-r--r--src/liballoc/string.rs18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/liballoc/string.rs b/src/liballoc/string.rs
index 110699c1e03..89f3ddcd18a 100644
--- a/src/liballoc/string.rs
+++ b/src/liballoc/string.rs
@@ -163,11 +163,12 @@ use boxed::Box;
 /// [`&str`]s as arguments unless they need a `String` for some specific
 /// reason.
 ///
-/// In certain cases Rust doesn't have enough information to make this conversion,
-/// known as deref coercion. For example, in this case a string slice implements
-/// a trait and the function takes anything that implements the trait, Rust would
-/// need to make two implicit conversions which Rust doesn't know how to do. The
-/// following example will not compile for that reason.
+/// In certain cases Rust doesn't have enough information to make this
+/// conversion, known as deref coercion. In the following example a string
+/// slice `&'a str` implements the trait `TraitExample`, and the function
+/// `example_func` takes anything that implements the trait. In this case Rust
+/// would need to make two implicit conversions, which Rust doesn't have the
+/// means to do. For that reason, the following example will not compile.
 ///
 /// ```compile_fail,E0277
 /// trait TraitExample {}
@@ -182,9 +183,10 @@ use boxed::Box;
 /// }
 /// ```
 ///
-/// What would work in this case is changing the line `example_func(&example_string);`
-/// to `example_func(example_string.to_str());`. This works because we're doing the
-/// conversion explicitly, rather than relying on the implicit conversion.
+/// What would work in this case is changing the line
+/// `example_func(&example_string);` to 
+/// `example_func(example_string.to_str());`. This works because we're doing
+/// the conversion explicitly, rather than relying on the implicit conversion.
 ///
 /// # Representation
 ///