diff --git a/src/tutorial/output.md b/src/tutorial/output.md index 901b85e..82a9b21 100644 --- a/src/tutorial/output.md +++ b/src/tutorial/output.md @@ -7,7 +7,7 @@ println!("Hello World"); ``` Well, that was easy. -Great, onto the next topic. +Great! Onto the next topic. ## Using `println!` @@ -15,8 +15,8 @@ You can pretty much print all the things you like with the `println!` macro. This macro has some pretty amazing capabilities, but also a special syntax. -It expects you to write a string literal as the first parameter, -that contains placeholders that will be filled in +It expects a string literal that contains placeholders +as the first parameter. The string will be filled in by the values of the parameters that follow as further arguments. For example: @@ -26,7 +26,7 @@ let x = 42; println!("My lucky number is {}.", x); ``` -will print +will print: ```console My lucky number is 42. @@ -35,31 +35,31 @@ My lucky number is 42. The curly braces (`{}`) in the string above is one of these placeholders. This is the default placeholder type that tries to print the given value in a human readable way. -For numbers and strings this works very well, +For numbers and strings, this works very well, but not all types can do that. -This is why there is also a "debug representation", +This is why there is also a "debug representation" that you can get by filling the braces of the placeholder like this: `{:?}`. -For example, +For example: ```rust let xs = vec![1, 2, 3]; println!("The list is: {:?}", xs); ``` -will print +will print: ```console The list is: [1, 2, 3] ``` If you want your own data types to be printable for debugging and logging, -you can in most cases add a `#[derive(Debug)]` above their definition. +you can typically add a `#[derive(Debug)]` above their definition. -In Rust this is achieved +In Rust, this is achieved with `println!` and `eprintln!`, the former printing to `stdout` and the latter to `stderr`. @@ -103,13 +103,13 @@ eprintln!("This is an error! :(");