Preface |
|
ix | |
|
|
1 | (16) |
|
Getting Started with "Hello, world!" |
|
|
1 | (2) |
|
Organizing a Rust Project Directory |
|
|
3 | (1) |
|
Creating and Running a Project with Cargo |
|
|
4 | (2) |
|
Writing and Running Integration Tests |
|
|
6 | (10) |
|
Adding a Project Dependency |
|
|
10 | (1) |
|
Understanding Program Exit Values |
|
|
11 | (3) |
|
Testing the Program Output |
|
|
14 | (1) |
|
Exit Values Make Programs Composable |
|
|
15 | (1) |
|
|
16 | (1) |
|
|
17 | (26) |
|
|
17 | (3) |
|
|
20 | (13) |
|
Accessing the Command-Line Arguments |
|
|
21 | (3) |
|
Adding clap as a Dependency |
|
|
24 | (1) |
|
Parsing Command-Line Arguments Using clap |
|
|
25 | (4) |
|
Creating the Program Output |
|
|
29 | (4) |
|
Writing Integration Tests |
|
|
33 | (8) |
|
Creating the Test Output Files |
|
|
34 | (1) |
|
|
35 | (1) |
|
|
36 | (5) |
|
|
41 | (2) |
|
|
43 | (26) |
|
|
44 | (4) |
|
|
48 | (15) |
|
|
48 | (2) |
|
|
50 | (1) |
|
|
51 | (5) |
|
Iterating Through the File Arguments |
|
|
56 | (1) |
|
|
56 | (3) |
|
|
59 | (4) |
|
|
63 | (4) |
|
Reading the Lines in a File |
|
|
63 | (1) |
|
|
64 | (3) |
|
|
67 | (1) |
|
|
67 | (2) |
|
|
69 | (26) |
|
|
70 | (3) |
|
|
73 | (13) |
|
Writing a Unit Test to Parse a String into a Number |
|
|
75 | (2) |
|
Converting Strings into Errors |
|
|
77 | (3) |
|
|
80 | (3) |
|
Processing the Input Files |
|
|
83 | (2) |
|
Reading Bytes Versus Characters |
|
|
85 | (1) |
|
|
86 | (6) |
|
Reading a File Line by Line |
|
|
86 | (1) |
|
Preserving Line Endings While Reading a File |
|
|
86 | (2) |
|
Reading Bytes from a File |
|
|
88 | (3) |
|
Printing the File Separators |
|
|
91 | (1) |
|
|
92 | (1) |
|
|
92 | (3) |
|
|
95 | (24) |
|
|
95 | (5) |
|
|
100 | (9) |
|
|
105 | (1) |
|
Writing and Testing a Function to Count File Elements |
|
|
106 | (3) |
|
|
109 | (8) |
|
Counting the Elements of a File or STDIN |
|
|
109 | (2) |
|
|
111 | (6) |
|
|
117 | (1) |
|
|
117 | (2) |
|
|
119 | (22) |
|
|
119 | (5) |
|
|
124 | (10) |
|
|
125 | (4) |
|
|
129 | (4) |
|
Processing the Input Files |
|
|
133 | (1) |
|
|
134 | (6) |
|
|
140 | (1) |
|
|
140 | (1) |
|
|
141 | (28) |
|
|
142 | (4) |
|
|
146 | (11) |
|
|
147 | (6) |
|
|
153 | (2) |
|
|
155 | (2) |
|
|
157 | (6) |
|
Conditionally Testing on Unix Versus Windows |
|
|
163 | (3) |
|
|
166 | (1) |
|
|
167 | (2) |
|
|
169 | (32) |
|
|
169 | (5) |
|
|
174 | (17) |
|
|
175 | (6) |
|
Parsing the Position List |
|
|
181 | (6) |
|
Extracting Characters or Bytes |
|
|
187 | (2) |
|
Parsing Delimited Text Files |
|
|
189 | (2) |
|
|
191 | (7) |
|
Selecting Characters from a String |
|
|
191 | (2) |
|
Selecting Bytes from a String |
|
|
193 | (2) |
|
Selecting Fields from a csv::StringRecord |
|
|
195 | (1) |
|
|
196 | (2) |
|
|
198 | (1) |
|
|
198 | (3) |
|
|
201 | (24) |
|
|
202 | (3) |
|
|
205 | (14) |
|
|
206 | (6) |
|
Finding the Files to Search |
|
|
212 | (3) |
|
Finding the Matching Lines of Input |
|
|
215 | (4) |
|
|
219 | (4) |
|
|
223 | (1) |
|
|
224 | (1) |
|
|
225 | (20) |
|
|
225 | (4) |
|
|
229 | (7) |
|
|
229 | (4) |
|
Validating and Opening the Input Files |
|
|
233 | (2) |
|
|
235 | (1) |
|
|
236 | (8) |
|
|
244 | (1) |
|
|
244 | (1) |
|
|
245 | (32) |
|
|
245 | (5) |
|
|
250 | (17) |
|
|
250 | (5) |
|
Parsing Positive and Negative Numeric Arguments |
|
|
255 | (1) |
|
Using a Regular Expression to Match an Integer with an Optional Sign |
|
|
256 | (4) |
|
Parsing and Validating the Command-Line Arguments |
|
|
260 | (2) |
|
|
262 | (1) |
|
Counting the Total Lines and Bytes in a File |
|
|
262 | (2) |
|
Finding the Starting Line to Print |
|
|
264 | (1) |
|
Finding the Starting Byte to Print |
|
|
265 | (1) |
|
Testing the Program with Large Input Files |
|
|
266 | (1) |
|
|
267 | (8) |
|
Counting All the Lines and Bytes in a File |
|
|
267 | (1) |
|
|
268 | (1) |
|
|
269 | (2) |
|
|
271 | (2) |
|
Benchmarking the Solution |
|
|
273 | (2) |
|
|
275 | (1) |
|
|
275 | (2) |
|
|
277 | (26) |
|
|
278 | (3) |
|
|
281 | (15) |
|
|
282 | (6) |
|
Finding the Input Sources |
|
|
288 | (3) |
|
Reading the Fortune Files |
|
|
291 | (2) |
|
Randomly Selecting a Fortune |
|
|
293 | (2) |
|
Printing Records Matching a Pattern |
|
|
295 | (1) |
|
|
296 | (5) |
|
|
301 | (1) |
|
|
301 | (2) |
|
|
303 | (26) |
|
|
303 | (3) |
|
|
306 | (15) |
|
Defining and Validating the Arguments |
|
|
307 | (11) |
|
|
318 | (3) |
|
|
321 | (5) |
|
|
326 | (1) |
|
|
326 | (3) |
|
|
329 | (32) |
|
|
330 | (2) |
|
|
332 | (17) |
|
|
333 | (3) |
|
|
336 | (5) |
|
Formatting the Long Listing |
|
|
341 | (2) |
|
Displaying Octal Permissions |
|
|
343 | (3) |
|
|
346 | (3) |
|
|
349 | (6) |
|
Notes from the Testing Underground |
|
|
355 | (3) |
|
|
358 | (1) |
|
|
359 | (2) |
Epilogue |
|
361 | (2) |
Index |
|
363 | |