General thoughts and notes while reading the book.
echo $?
shows what the last exit status was.
Leading underscore in a variable name let _this
is functional. It tells rust
compiler that you don't intend to use this variable right now. Without the
underscore, the compiler would warn about unused variable.
Tests by default run concurrently. If you would like to run the tests in order,
you can run them on a single thread via: cargo test -- --test-threads=1
Learning to read test output is a skill in itself and takes practice. The preceding test result is trying very hard to show you how the expected output differs from the actual output.
Correctly reporting the exit status is a characteristic of well-behaved command-line programs. The exit value is important because a failed process used in conjunction with another process should cause the combination to fail.
Cyclomatic Complexity
refers to the various ways all the parameters can be
combined.
Use ?
instead of Result::unwrap
to unpack an Ok
value or propagate an
Err
. When doing this omit the final semlicolon to return this value
Learnt how to read files in a variety of ways (strings, bytes).
a str
is an immutable, fixed-length string. The value that will be returned
from the function is dynamically generated at runtime, so I must use String
,
which is a growable, heap-allocated structure.
Learnt how to write output to files, and how to test them temporarily. Also slowly understanding traits and macros I think.