google / google/comprehensive-rust

Android: Add pages explaining the Android Rust code style

Open
#1,064 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Rust
Stars
33.4k
Forks
2.1k
Avg merge
1d 3h
Merged PRs (30d)
10

Description

This means:

- Edition: we currently use the 2021 edition.
- Comments: we prefer line comments over block comments.
- Formatting: we use this [`rustfmt.toml`](https://cs.android.com/android/platform/superproject/+/main:build/soong/scripts/rustfmt.toml).
- Arithmetic: use `wrapping_add` and `checked_add` if you rely on overflow checks.
- Unsafe: you must add safety comments to all `unsafe` blocks, even inside unsafe functions.
- Directory structure: prefer files to inline modules, prefer `foo.rs` over `foo/mod.rs`.
- Macros: prefer functions over macros, use `#[track_caller]` to preserve backtraces for regular functions.
- Unstable features: not allowed in AOSP.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.