print! macro with an empty format string has no effect.
if blocks with trivial conditions such as
if true and
if false are
suspicious and require an audit. Such conditions are probably debugging
remnants and should not make it into your source tree.
To check if a
str ends with a given character, use
starts_with instead of
_.chars().next() == Some(c).
The length of
CStrings may be calculated with
.as_bytes().len(), which is
safe and performant, as compared to
libc::strlen, which is an unsafe
Option::is_none are functions that tell us what is
contained within an
Option type without unwrapping or pattern-matching on it.
To "peek" into a
Result type in a similar manner, one could convert an
Result into an
Option by calling
Result::err and then use
Result already has functions
that let us peek into the state of the enum: