Use - instead of * for unordered list
This commit is contained in:
parent
b4b540ced2
commit
9d38e985c5
@ -36,10 +36,10 @@ options.
|
|||||||
|
|
||||||
### Indentation and line width
|
### Indentation and line width
|
||||||
|
|
||||||
* Use spaces, not tabs.
|
- Use spaces, not tabs.
|
||||||
* Each level of indentation must be 4 spaces (that is, all indentation
|
- Each level of indentation must be 4 spaces (that is, all indentation
|
||||||
outside of string literals and comments must be a multiple of 4).
|
outside of string literals and comments must be a multiple of 4).
|
||||||
* The maximum width for a line is 100 characters.
|
- The maximum width for a line is 100 characters.
|
||||||
|
|
||||||
#### Block indent
|
#### Block indent
|
||||||
|
|
||||||
|
@ -2,11 +2,11 @@
|
|||||||
|
|
||||||
[Introduction](README.md)
|
[Introduction](README.md)
|
||||||
|
|
||||||
* [Items](items.md)
|
- [Items](items.md)
|
||||||
* [Statements](statements.md)
|
- [Statements](statements.md)
|
||||||
* [Expressions](expressions.md)
|
- [Expressions](expressions.md)
|
||||||
* [Types and Bounds](types.md)
|
- [Types and Bounds](types.md)
|
||||||
* [Other style advice](advice.md)
|
- [Other style advice](advice.md)
|
||||||
* [`Cargo.toml` conventions](cargo.md)
|
- [`Cargo.toml` conventions](cargo.md)
|
||||||
* [Guiding principles and rationale](principles.md)
|
- [Guiding principles and rationale](principles.md)
|
||||||
* [Nightly-only syntax](nightly.md)
|
- [Nightly-only syntax](nightly.md)
|
||||||
|
@ -18,14 +18,14 @@ if y {
|
|||||||
|
|
||||||
## Names
|
## Names
|
||||||
|
|
||||||
* Types shall be `UpperCamelCase`,
|
- Types shall be `UpperCamelCase`,
|
||||||
* Enum variants shall be `UpperCamelCase`,
|
- Enum variants shall be `UpperCamelCase`,
|
||||||
* Struct fields shall be `snake_case`,
|
- Struct fields shall be `snake_case`,
|
||||||
* Function and method names shall be `snake_case`,
|
- Function and method names shall be `snake_case`,
|
||||||
* Local variables shall be `snake_case`,
|
- Local variables shall be `snake_case`,
|
||||||
* Macro names shall be `snake_case`,
|
- Macro names shall be `snake_case`,
|
||||||
* Constants (`const`s and immutable `static`s) shall be `SCREAMING_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 (such as `crate`),
|
- When a name is forbidden because it is a reserved word (such as `crate`),
|
||||||
either use a raw identifier (`r#crate`) or use a trailing underscore
|
either use a raw identifier (`r#crate`) or use a trailing underscore
|
||||||
(`crate_`). Don't misspell the word (`krate`).
|
(`crate_`). Don't misspell the word (`krate`).
|
||||||
|
|
||||||
|
@ -63,10 +63,10 @@ Write an empty block as `{}`.
|
|||||||
|
|
||||||
Write a block on a single line if:
|
Write a block on a single line if:
|
||||||
|
|
||||||
* it is either used in expression position (not statement position) or is an
|
- it is either used in expression position (not statement position) or is an
|
||||||
unsafe block in statement position,
|
unsafe block in statement position,
|
||||||
* it contains a single-line expression and no statements, and
|
- it contains a single-line expression and no statements, and
|
||||||
* it contains no comments
|
- it contains no comments
|
||||||
|
|
||||||
For a single-line block, put spaces after the opening brace and before the
|
For a single-line block, put spaces after the opening brace and before the
|
||||||
closing brace.
|
closing brace.
|
||||||
|
@ -478,9 +478,9 @@ example, `a::*` comes before `b::a` but `a::b` comes before `a::*`. E.g.,
|
|||||||
|
|
||||||
Tools must make the following normalisations, recursively:
|
Tools must make the following normalisations, recursively:
|
||||||
|
|
||||||
* `use a::self;` -> `use a;`
|
- `use a::self;` -> `use a;`
|
||||||
* `use a::{};` -> (nothing)
|
- `use a::{};` -> (nothing)
|
||||||
* `use a::{b};` -> `use a::b;`
|
- `use a::{b};` -> `use a::b;`
|
||||||
|
|
||||||
Tools must not otherwise merge or un-merge import lists or adjust glob imports
|
Tools must not otherwise merge or un-merge import lists or adjust glob imports
|
||||||
(without an explicit option).
|
(without an explicit option).
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
# Nightly
|
||||||
|
|
||||||
This chapter documents style and formatting for nightly-only syntax. The rest of the style guide documents style for stable Rust syntax; nightly syntax only appears in this chapter. Each section here includes the name of the feature gate, so that searches (e.g. `git grep`) for a nightly feature in the Rust repository also turn up the style guide section.
|
This chapter documents style and formatting for nightly-only syntax. The rest of the style guide documents style for stable Rust syntax; nightly syntax only appears in this chapter. Each section here includes the name of the feature gate, so that searches (e.g. `git grep`) for a nightly feature in the Rust repository also turn up the style guide section.
|
||||||
|
|
||||||
Style and formatting for nightly-only syntax should be removed from this chapter and integrated into the appropriate sections of the style guide at the time of stabilization.
|
Style and formatting for nightly-only syntax should be removed from this chapter and integrated into the appropriate sections of the style guide at the time of stabilization.
|
||||||
|
@ -3,27 +3,27 @@
|
|||||||
When deciding on style guidelines, the style team follows these guiding
|
When deciding on style guidelines, the style team follows these guiding
|
||||||
principles (in rough priority order):
|
principles (in rough priority order):
|
||||||
|
|
||||||
* readability
|
- readability
|
||||||
* scan-ability
|
- scan-ability
|
||||||
* avoiding misleading formatting
|
- avoiding misleading formatting
|
||||||
* accessibility - readable and editable by users using the widest
|
- accessibility - readable and editable by users using the widest
|
||||||
variety of hardware, including non-visual accessibility interfaces
|
variety of hardware, including non-visual accessibility interfaces
|
||||||
* readability of code in contexts without syntax highlighting or IDE
|
- readability of code in contexts without syntax highlighting or IDE
|
||||||
assistance, such as rustc error messages, diffs, grep, and other
|
assistance, such as rustc error messages, diffs, grep, and other
|
||||||
plain-text contexts
|
plain-text contexts
|
||||||
|
|
||||||
* aesthetics
|
- aesthetics
|
||||||
* sense of 'beauty'
|
- sense of 'beauty'
|
||||||
* consistent with other languages/tools
|
- consistent with other languages/tools
|
||||||
|
|
||||||
* specifics
|
- specifics
|
||||||
* compatibility with version control practices - preserving diffs,
|
- compatibility with version control practices - preserving diffs,
|
||||||
merge-friendliness, etc.
|
merge-friendliness, etc.
|
||||||
* preventing rightward drift
|
- preventing rightward drift
|
||||||
* minimising vertical space
|
- minimising vertical space
|
||||||
|
|
||||||
* application
|
- application
|
||||||
* ease of manual application
|
- ease of manual application
|
||||||
* ease of implementation (in `rustfmt`, and in other tools/editors/code generators)
|
- ease of implementation (in `rustfmt`, and in other tools/editors/code generators)
|
||||||
* internal consistency
|
- internal consistency
|
||||||
* simplicity of formatting rules
|
- simplicity of formatting rules
|
||||||
|
@ -2,17 +2,17 @@
|
|||||||
|
|
||||||
## Single line formatting
|
## Single line formatting
|
||||||
|
|
||||||
* `[T]` no spaces
|
- `[T]` no spaces
|
||||||
* `[T; expr]`, e.g., `[u32; 42]`, `[Vec<Foo>; 10 * 2 + foo()]` (space after colon, no spaces around square brackets)
|
- `[T; expr]`, e.g., `[u32; 42]`, `[Vec<Foo>; 10 * 2 + foo()]` (space after colon, no spaces around square brackets)
|
||||||
* `*const T`, `*mut T` (no space after `*`, space before type)
|
- `*const T`, `*mut T` (no space after `*`, space before type)
|
||||||
* `&'a T`, `&T`, `&'a mut T`, `&mut T` (no space after `&`, single spaces separating other words)
|
- `&'a T`, `&T`, `&'a mut T`, `&mut T` (no space after `&`, single spaces separating other words)
|
||||||
* `unsafe extern "C" fn<'a, 'b, 'c>(T, U, V) -> W` or `fn()` (single spaces around keywords and sigils, and after commas, no trailing commas, no spaces around brackets)
|
- `unsafe extern "C" fn<'a, 'b, 'c>(T, U, V) -> W` or `fn()` (single spaces around keywords and sigils, and after commas, no trailing commas, no spaces around brackets)
|
||||||
* `!` gets treated like any other type name, `Name`
|
- `!` gets treated like any other type name, `Name`
|
||||||
* `(A, B, C, D)` (spaces after commas, no spaces around parens, no trailing comma unless it is a one-tuple)
|
- `(A, B, C, D)` (spaces after commas, no spaces around parens, no trailing comma unless it is a one-tuple)
|
||||||
* `<Baz<T> as SomeTrait>::Foo::Bar` or `Foo::Bar` or `::Foo::Bar` (no spaces around `::` or angle brackets, single spaces around `as`)
|
- `<Baz<T> as SomeTrait>::Foo::Bar` or `Foo::Bar` or `::Foo::Bar` (no spaces around `::` or angle brackets, single spaces around `as`)
|
||||||
* `Foo::Bar<T, U, V>` (spaces after commas, no trailing comma, no spaces around angle brackets)
|
- `Foo::Bar<T, U, V>` (spaces after commas, no trailing comma, no spaces around angle brackets)
|
||||||
* `T + T + T` (single spaces between types, and `+`).
|
- `T + T + T` (single spaces between types, and `+`).
|
||||||
* `impl T + T + T` (single spaces between keyword, types, and `+`).
|
- `impl T + T + T` (single spaces between keyword, types, and `+`).
|
||||||
|
|
||||||
Do not put space around parentheses used in types, e.g., `(Foo)`
|
Do not put space around parentheses used in types, e.g., `(Foo)`
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user