Skip to main content

Coding Guidelines

This document describes the coding guidelines for the Databend Rust codebase.

Code formatting​

All code formatting is enforced with rustfmt with a project-specific configuration. Below is an example command:

$ make fmt

Code analysis​

Clippy is used to catch common mistakes and is run as a part of continuous integration. Before submitting your code for review, you can run lint:

$ make lint

Code documentation​

Any public fields, functions, and methods should be documented with Rustdoc.

Please follow the conventions as detailed below for modules, structs, enums, and functions. The single line is used as a preview when navigating Rustdoc. As an example, see the 'Structs' and 'Enums' sections in the collections Rustdoc.

/// [Single line] One line summary description
///
/// [Longer description] Multiple lines, inline code
/// examples, invariants, purpose, usage, etc.
[Attributes] If attributes exist, add after Rustdoc

Example below:

/// Represents (x, y) of a 2-dimensional grid
///
/// A line is defined by 2 instances.
/// A plane is defined by 3 instances.
#[repr(C)]
struct Point {
x: i32,
y: i32,
}

Testing​

Unit tests

$ make unit-test

Stateless tests

$ make stateless-test