]> git.lizzy.rs Git - rust.git/commitdiff
Fixed typos
authorClar Charr <clar@charr.xyz>
Sat, 5 May 2018 01:37:28 +0000 (21:37 -0400)
committerClar Charr <clar@charr.xyz>
Sat, 5 May 2018 04:18:10 +0000 (00:18 -0400)
src/libstd/primitive_docs.rs

index 8905f7c9e160512e288db09be2247c8b4b9bb034..49344cab1dd265a626ffa068b73165ae5d8ae829 100644 (file)
@@ -112,7 +112,7 @@ mod prim_bool { }
 ///
 /// # `!` and generics
 ///
-/// ## Infalliable errors
+/// ## Infallible errors
 ///
 /// The main place you'll see `!` used explicitly is in generic code. Consider the [`FromStr`]
 /// trait:
@@ -144,7 +144,7 @@ mod prim_bool { }
 ///
 /// ## Infinite loops
 ///
-/// While [`Result<T, !>`] is very useful for removing errors, `!` can also be used to removed
+/// While [`Result<T, !>`] is very useful for removing errors, `!` can also be used to remove
 /// successes as well. If we think of [`Result<T, !>`] as "if this function returns, it has not
 /// errored," we get a very intuitive idea of [`Result<!, E>`] as well: if the function returns, it
 /// *has* errored.
@@ -175,21 +175,22 @@ mod prim_bool { }
 /// ```
 ///
 /// Now, when the server disconnects, we exit the loop with an error instead of panicking. While it
-/// might be intuitive to simply return the error, we might want to wrap it in a [`Result<!, E>`] 
+/// might be intuitive to simply return the error, we might want to wrap it in a [`Result<!, E>`]
 /// instead:
 ///
 /// ```ignore (hypothetical-example)
 /// fn server_loop() -> Result<!, ConnectionError> {
-///     Ok(loop {
+///     loop {
 ///         let (client, request) = get_request()?;
 ///         let response = request.process();
 ///         response.send(client);
-///     })
+///     }
 /// }
 /// ```
 ///
 /// Now, we can use `?` instead of `match`, and the return type makes a lot more sense: if the loop
-/// ever stops, it means that an error occurred.
+/// ever stops, it means that an error occurred. We don't even have to wrap the loop in an `Ok`
+/// because `!` coerces to `Result<!, ConnectionError>` automatically.
 ///
 /// [`String::from_str`]: str/trait.FromStr.html#tymethod.from_str
 /// [`Result<String, !>`]: result/enum.Result.html