Skip to content
Switch branches/tags
Go to file
Cannot retrieve contributors at this time

Embark logo

Embark Rust development guidelines

Guidelines and recommendations we use at Embark for developing our Rust 🦀 projects.


This is not meant to be an exhaustive collection and resource of all best practices in Rust, that is best covered by the Rust Book and other references. Instead this is list of specific guidelines and recommendations that we've run into and want to highlight and standardize on within Embark.

001 - Run rustfmt on save

Motivation: We want to keep a consistent code base where we don't have to argue about style, so we use rustfmt on everything and verify on CI that it has been run. So highly recommend everyone to configure their editor to run rustfmt on save as it is more error prone to run it before commit.

With VS Code this should be automatic for our repos, see section.

002 - Prefer synchronization primitives from parking_lot instead of std::sync

Motivation: The parking_lot implementations are smaller, faster, and avoids poisioning errors which makes them more ergonomic and easier to use.

Example old:

use std::sync::{Mutex,RwLock};
let mutex = Mutex::new(1u32);
*mutex.lock().unwrap() += 5;

Example new:

use parking_lot::{Mutex,RwLock};
let mutex = Mutex::new(1u32);
*mutex.lock() += 2;

Todo: Would be great to automatically verify this through something like a custom clippy lint, or even better: have the parking_lot primitives eventually find their way into std.

003 - Opt-in for Clippy and Rust 2018 style warnings for every crate

Motivation: Keeps our code high quality and catches common errors and inefficiencies. We already verify on CI that clippy finds no warnings, and by opting in to warnings in every crate it also enables tools like RLS in VS Code to know that Clippy warnings

Add this to the top of the main file ( or for all of our crates:


Todo: Would be great if we could configure this globally for our workspace instead of for each crate (more error prone). #22.

Development environments

Visual Studio Code

We primarily use VS Code as development environment for Rust.


With VS Code this should be automatic for our repos, see as long as one has the Rust extension installed and our repo contains a .vscode/settings.json with:

As we want to run rustfmt on save, all of our repos should have a .vscode/settings.json with:

    "editor.formatOnSave": true,