Skip to content

Instantly share code, notes, and snippets.

@emilk
Last active April 30, 2022 17:34
Show Gist options
  • Save emilk/6c5fa499cc09e7b142e8c6bb7374cd32 to your computer and use it in GitHub Desktop.
Save emilk/6c5fa499cc09e7b142e8c6bb7374cd32 to your computer and use it in GitHub Desktop.

Emil's Rust Style Guide

If you are only using it in one function, put the use statement in that function. This improves locality, making it easier to read and move the code.

When importing a trait to use it's trait methods, do this: use Trait as _;. That lets the reader know why you imported it, even though it seems unused.

Prefer anyhow::Result<_> over Result<_, anyhow::Error>; Don't do use anyhow::Result; - be explicit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment