summaryrefslogtreecommitdiffstats
path: root/CODING_GUIDELINES.md
blob: 6084017f4b007fd51716b3cf74e0609d6b8f4168 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# Coding Guidelines

## Code Style

Follow [Rust coding guidelines](https://github.com/rust-dev-tools/fmt-rfcs/blob/master/guide/guide.md).
When adding new feature or adding an API try to adhere to
[Rust API Guidelines](https://rust-lang.github.io/api-guidelines/about.html).
Avoid using unsafe code.

## Code formatting

Always use rustfmt before you commit as your code won't pass CI pipeline if
rustfmt is not applied. We adhere to default settings.

```console
$ cargo fmt
```


## Code analysis

Clippy is used to catch common mistakes and we run it as part of our CI
pipeline.

```console
$ cargo clippy
```


## Code testing

Ideally, all code should be unit tested. Unit tests should be in module file or
if the file or tests are very long in separate file `tests.rs` in the same
directory asĀ `mod.rs`.

## Error handling

Error handling suggestions follow the
[Rust book guidance](https://doc.rust-lang.org/book/ch09-00-error-handling.html).
Errors should be handled with [Result](https://doc.rust-lang.org/std/result/).