Skip to content

Commit d272026

Browse files
authored
Tidy grammar output.md
Tidies up grammar and tightens up some of the language.
1 parent d2a95a7 commit d272026

File tree

1 file changed

+37
-37
lines changed

1 file changed

+37
-37
lines changed

src/tutorial/output.md

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@ println!("Hello World");
77
```
88

99
Well, that was easy.
10-
Great, onto the next topic.
10+
Great! Onto the next topic.
1111

1212
## Using `println!`
1313

1414
You can pretty much print all the things you like
1515
with the `println!` macro.
1616
This macro has some pretty amazing capabilities,
1717
but also a special syntax.
18-
It expects you to write a string literal as the first parameter,
19-
that contains placeholders that will be filled in
18+
It expects a string literal that contains placeholders
19+
as the first parameter. The string will be filled in
2020
by the values of the parameters that follow as further arguments.
2121

2222
For example:
@@ -26,7 +26,7 @@ let x = 42;
2626
println!("My lucky number is {}.", x);
2727
```
2828

29-
will print
29+
will print:
3030

3131
```console
3232
My lucky number is 42.
@@ -35,31 +35,31 @@ My lucky number is 42.
3535
The curly braces (`{}`) in the string above is one of these placeholders.
3636
This is the default placeholder type
3737
that tries to print the given value in a human readable way.
38-
For numbers and strings this works very well,
38+
For numbers and strings, this works very well,
3939
but not all types can do that.
40-
This is why there is also a "debug representation",
40+
This is why there is also a "debug representation"
4141
that you can get by filling the braces of the placeholder like this: `{:?}`.
4242

43-
For example,
43+
For example:
4444

4545
```rust
4646
let xs = vec![1, 2, 3];
4747
println!("The list is: {:?}", xs);
4848
```
4949

50-
will print
50+
will print:
5151

5252
```console
5353
The list is: [1, 2, 3]
5454
```
5555

5656
If you want your own data types to be printable for debugging and logging,
57-
you can in most cases add a `#[derive(Debug)]` above their definition.
57+
you can typically add a `#[derive(Debug)]` above their definition.
5858

5959
<aside>
6060

6161
**Note:**
62-
"User-friendly" printing is done using the [`Display`] trait,
62+
"User-friendly" printing is done using the [`Display`] trait and
6363
debug output (human-readable but targeted at developers) uses the [`Debug`] trait.
6464
You can find more information about the syntax you can use in `println!`
6565
in the [documentation for the `std::fmt` module][std::fmt].
@@ -82,16 +82,16 @@ or more tools.
8282

8383
**Note:**
8484
On most operating systems,
85-
a program can write to two output streams, `stdout` and `stderr`.
86-
`stdout` is for the program's actual output,
85+
a program can write to two output streams: `stdout` and `stderr`.
86+
`stdout` is for the program's actual output
8787
while `stderr` allows errors and other messages to be kept separate from `stdout`.
8888
That way,
8989
output can be stored to a file or piped to another program
9090
while errors are shown to the user.
9191

9292
</aside>
9393

94-
In Rust this is achieved
94+
In Rust, this is achieved
9595
with `println!` and `eprintln!`,
9696
the former printing to `stdout`
9797
and the latter to `stderr`.
@@ -103,13 +103,13 @@ eprintln!("This is an error! :(");
103103

104104
<aside>
105105

106-
**Beware**: Printing [escape codes] can be dangerous,
107-
putting the user's terminal into a weird state.
106+
**Beware**: Printing [escape codes] can be dangerous and
107+
put the user's terminal into a weird state.
108108
Always be careful when manually printing them!
109109

110110
[escape codes]: https://en.wikipedia.org/wiki/ANSI_escape_code
111111

112-
Ideally you should be using a crate like `ansi_term`
112+
Ideally, you should be using a crate like `ansi_term`
113113
when dealing with raw escape codes
114114
to make your (and your user's) life easier.
115115

@@ -126,13 +126,13 @@ there are two things you can do.
126126
First,
127127
you might want to reduce the number of writes
128128
that actually "flush" to the terminal.
129-
`println!` tells the system to flush to the terminal _every_ time,
129+
`println!` tells the system to flush to the terminal _every_ time
130130
because it is common to print each new line.
131131
If you don't need that,
132-
you can wrap your `stdout` handle in a [`BufWriter`]
133-
which by default buffers up to 8 kB.
134-
(You can still call `.flush()` on this `BufWriter`
135-
when you want to print immediately.)
132+
you can wrap your `stdout` handle in a [`BufWriter`],
133+
which buffers up to 8 kB by default.
134+
You can still call `.flush()` on this `BufWriter`
135+
when you want to print immediately.
136136

137137
```rust
138138
use std::io::{self, Write};
@@ -161,7 +161,7 @@ You can also combine the two approaches.
161161

162162
## Showing a progress bar
163163

164-
Some CLI applications run less than a second,
164+
Some CLI applications run less than a second while
165165
others take minutes or hours.
166166
If you are writing one of the latter types of programs,
167167
you might want to show the user that something is happening.
@@ -189,10 +189,10 @@ for more information.
189189

190190
To make it easier to understand what is happening in our program,
191191
we might want to add some log statements.
192-
This is usually easy while writing your application.
193-
But it will become super helpful when running this program again in half a year.
194-
In some regard,
195-
logging is the same as using `println!`,
192+
This is usually easy while writing your application,
193+
and it will become super helpful when running this program again in half a year.
194+
In some ways,
195+
logging is the same as using `println!`
196196
except that you can specify the importance of a message.
197197
The levels you can usually use are _error_, _warn_, _info_, _debug_, and _trace_
198198
(_error_ has the highest priority, _trace_ the lowest).
@@ -203,16 +203,16 @@ The [log] crate (this contains macros named after the log level)
203203
and an _adapter_ that actually writes the log output somewhere useful.
204204
Having the ability to use log adapters is very flexible:
205205
You can, for example, use them to write logs not only to the terminal
206-
but also to [syslog], or to a central log server.
206+
but also to [syslog] or to a central log server.
207207

208208
[syslog]: https://en.wikipedia.org/wiki/Syslog
209209

210-
Since we are right now only concerned with writing a CLI application,
210+
Since we are only concerned with writing a CLI application,
211211
an easy adapter to use is [env_logger].
212212
It's called "env" logger because you can
213213
use an environment variable to specify which parts of your application
214214
you want to log
215-
(and at which level you want to log them).
215+
and at which level you want to log them.
216216
It will prefix your log messages with a timestamp
217217
and the module where the log messages come from.
218218
Since libraries can also use `log`,
@@ -260,20 +260,20 @@ $ cargo run --bin output-log
260260
`RUST_LOG` is the name of the environment variable
261261
you can use to set your log settings.
262262
`env_logger` also contains a builder
263-
so you can programmatically adjust these settings,
264-
and, for example, also show _info_ level messages by default.
263+
so you can programmatically adjust these settings
264+
like showing _info_ level messages by default.
265265

266-
There are a lot of alternative logging adapters out there,
267-
and also alternatives or extensions to `log`.
266+
There are a lot of alternative logging adapters out there
267+
as well as alternatives and extensions to `log`.
268268
If you know your application will have a lot to log,
269-
make sure to review them,
270-
and make your users' life easier.
269+
make sure to review them
270+
and make your users' lives easier.
271271

272272
<aside>
273273

274274
**Tip:**
275-
Experience has shown that even mildly useful CLI programs can end up being used for years to come.
276-
(Especially if they were meant as a temporary solution.)
275+
Experience has shown that even mildly useful CLI programs can end up being used for years to come,
276+
especially if they were meant as a temporary solution.
277277
If your application doesn't work
278278
and someone (e.g., you, in the future) needs to figure out why,
279279
being able to pass `--verbose` to get additional log output

0 commit comments

Comments
 (0)