about summary refs log tree commit diff
diff options
context:
space:
mode:
authorSteve Klabnik <steve@steveklabnik.com>2015-04-10 10:27:16 -0400
committerSteve Klabnik <steve@steveklabnik.com>2015-04-10 11:24:36 -0400
commit2b38819b8409cbadc74260c3beb7559f6515155e (patch)
tree7ceaaf0f28560d68a7ea8514cb0ecb5d6d06a735
parent734bdc656a6fae7a2c1f5722de4c1f9611bc28b5 (diff)
downloadrust-2b38819b8409cbadc74260c3beb7559f6515155e.tar.gz
rust-2b38819b8409cbadc74260c3beb7559f6515155e.zip
copyedits: documentation
-rw-r--r--src/doc/trpl/comments.md38
1 files changed, 18 insertions, 20 deletions
diff --git a/src/doc/trpl/comments.md b/src/doc/trpl/comments.md
index 441496e6a75..fa27d1c226c 100644
--- a/src/doc/trpl/comments.md
+++ b/src/doc/trpl/comments.md
@@ -1,47 +1,45 @@
 % Comments
 
-Now that we have some functions, it's a good idea to learn about comments.
+Now that we have some functions, it’s a good idea to learn about comments.
 Comments are notes that you leave to other programmers to help explain things
 about your code. The compiler mostly ignores them.
 
 Rust has two kinds of comments that you should care about: *line comments*
 and *doc comments*.
 
-```{rust}
-// Line comments are anything after '//' and extend to the end of the line.
+```rust
+// Line comments are anything after ‘//’ and extend to the end of the line.
 
 let x = 5; // this is also a line comment.
 
 // If you have a long explanation for something, you can put line comments next
-// to each other. Put a space between the // and your comment so that it's
+// to each other. Put a space between the // and your comment so that it’s
 // more readable.
 ```
 
 The other kind of comment is a doc comment. Doc comments use `///` instead of
 `//`, and support Markdown notation inside:
 
-```{rust}
-/// `hello` is a function that prints a greeting that is personalized based on
-/// the name given.
-///
-/// # Arguments
-///
-/// * `name` - The name of the person you'd like to greet.
+```rust
+/// Adds one to the number given.
 ///
 /// # Examples
 ///
-/// ```rust
-/// let name = "Steve";
-/// hello(name); // prints "Hello, Steve!"
 /// ```
-fn hello(name: &str) {
-    println!("Hello, {}!", name);
+/// let five = 5;
+///
+/// assert_eq!(6, add_one(5));
+/// ```
+fn add_one(x: i32) -> i32 {
+    x + 1
 }
 ```
 
-When writing doc comments, adding sections for any arguments, return values,
-and providing some examples of usage is very, very helpful. Don't worry about
-the `&str`, we'll get to it soon.
+When writing doc comments, providing some examples of usage is very, very
+helpful. You’ll notice we’ve used a new macro here: `assert_eq!`. This compares
+two values, and `panic!`s if they’re not equal to each other. It’s very helpful
+in documentation. There’s another macro, `assert!`, which `panic!`s if the
+value passed to it is `false`.
 
 You can use the [`rustdoc`](documentation.html) tool to generate HTML documentation
-from these doc comments.
+from these doc comments, and also to run the code examples as tests!