summaryrefslogtreecommitdiffstats
path: root/src/doc/style-guide/src/advice.md
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/doc/style-guide/src/advice.md34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/doc/style-guide/src/advice.md b/src/doc/style-guide/src/advice.md
new file mode 100644
index 000000000..ab4b92b0a
--- /dev/null
+++ b/src/doc/style-guide/src/advice.md
@@ -0,0 +1,34 @@
+# Other style advice
+
+## Expressions
+
+Prefer to use Rust's expression oriented nature where possible;
+
+```rust
+// use
+let x = if y { 1 } else { 0 };
+// not
+let x;
+if y {
+ x = 1;
+} else {
+ x = 0;
+}
+```
+
+## Names
+
+ * Types shall be `UpperCamelCase`,
+ * Enum variants shall be `UpperCamelCase`,
+ * Struct fields shall be `snake_case`,
+ * Function and method names shall be `snake_case`,
+ * Local variables shall be `snake_case`,
+ * Macro names shall be `snake_case`,
+ * Constants (`const`s and immutable `static`s) shall be `SCREAMING_SNAKE_CASE`.
+ * When a name is forbidden because it is a reserved word (e.g., `crate`), use a
+ trailing underscore to make the name legal (e.g., `crate_`), or use raw
+ identifiers if possible.
+
+### Modules
+
+Avoid `#[path]` annotations where possible.