# Andre Bogus - How to Write CRaP Rust Code (Highlights) ![rw-book-cover|256](https://readwise-assets.s3.amazonaws.com/static/images/article3.5c705a01b476.png) ## Metadata **Cover**:: https://readwise-assets.s3.amazonaws.com/static/images/article3.5c705a01b476.png **Source**:: #from/readwise **Zettel**:: #zettel/fleeting **Status**:: #x **Authors**:: [[Andre Bogus]] **Full Title**:: How to Write CRaP Rust Code **Category**:: #articles #readwise/articles **Category Icon**:: 📰 **Document Tags**:: #from/pocket #rust **URL**:: [blog.logrocket.com](https://blog.logrocket.com/how-to-write-crap-rust-code/) **Host**:: [[blog.logrocket.com]] **Highlighted**:: [[2020-04-26]] **Created**:: [[2022-09-26]] ## Highlights - #![warn(missing\_doc\_code\_examples)] - Extend your testing toolbox with [quickcheck](https://docs.rs/quickcheck) or [proptest](https://altsysrq.github.io/proptest-book/intro.html). - how to use `[afl](https://github.com/rust-fuzz/afl.rs)` or `[cargo-fuzz](https://github.com/rust-fuzz/cargo-fuzz)` to find failing test inputs. - Learn and work with the tools your system offers. For sampling profilers, the [inferno](https://docs.rs/inferno) docs have very nice directions to get a flamegraph for your code (Kudos to Jon Gjengset). If your application has any sort of concurrency, you may also want to give [coz](https://github.com/plasma-umass/coz) a try. - [DHAT](https://valgrind.org/docs/manual/dh-manual.html) can provide a solid overview of where memory is used. - Does your `HashMap` have fewer than 50 entries most of the time? Use a `Vec<(key, value)>` instead, especially if you can `sort\_by\_key` and `binary\_search\_by\_key` it for lookup. If your `Vec`s have mostly one or two elements, perhaps try a `[SmallVec](https://docs.rs/smallvec)` (or `[tinyvec](https://docs.rs/tinyvec)` if it gives you the same perf).