Skip to content

Commit

Permalink
Coding style: add a section on list ordering.
Browse files Browse the repository at this point in the history
I've been keeping a lot of things (such as `Cargo.toml` package lists and `mod` declarations) in alphabetical order. This adds that preference to the style guide, so other contributors are aware of it.
  • Loading branch information
jrvanwhy committed Aug 22, 2023
1 parent 110af62 commit e1ab203
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
12 changes: 6 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,31 +32,31 @@ libtock_temperature = { path = "apis/temperature" }
libtock_build_scripts = { path = "build_scripts"}

[profile.dev]
panic = "abort"
lto = true
debug = true
lto = true
panic = "abort"

[profile.release]
panic = "abort"
lto = true
debug = true
lto = true
panic = "abort"

[workspace]
exclude = ["tock"]
members = [
"apis/adc",
"apis/air_quality",
"apis/alarm",
"apis/gpio",
"apis/ambient_light",
"apis/buttons",
"apis/buzzer",
"apis/console",
"apis/gpio",
"apis/leds",
"apis/low_level_debug",
"apis/ninedof",
"apis/proximity",
"apis/temperature",
"apis/ambient_light",
"panic_handlers/debug_panic",
"panic_handlers/small_panic",
"platform",
Expand Down
15 changes: 15 additions & 0 deletions doc/Style.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
Coding Style
============

## List Ordering

Source code tends to contain many lists whose order is unimportant, such as
dependency lists in `Cargo.toml` and `mod` declarations in `.rs` files. When
there isn't a better reason to prefer a particular order, these lists should be
in alphabetical order.

Benefits:

1. When lists become long, this makes it easier to search for a particular
entry.
2. Always adding new entries at the bottom of the list results in merge
conflicts whenever two PRs add entries to the same list. Putting them in
alphabetical order decreases the probability of merge conflicts.

## Naming Conventions

Many things in `libtock-rs` live outside Rust's namespacing system, and can
Expand Down

0 comments on commit e1ab203

Please sign in to comment.