google / google/comprehensive-rust
Android: Add pages explaining the Android Rust code style
- 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
Assessment
This issue has not been assessed yet.