Common newbie mistakes or bad practices

Some additional ones I have seen:

  • In a CLI program, intermingling I/O, argument parsing, etc. with actual domain logic. Domain logic should have its own module or even crate for clean re-usability.
  • Again, w.r.t. CLI, parsing arguments manually, or even trying to configure clap manually, instead of using structopt to create a strongly-typed input/config struct.
  • Thinking of error handling as an "afterthought" or as some additional annoyance instead of designing with Result and ?-bubbling upfront.
  • Overusing slice indexing when iterators would be cleaner/faster, or the converse, overusing iterators where indexing would be easier on borrowck.
10 Likes