From 9346519b0502ad8fd3cff7d77362582a00d215c1 Mon Sep 17 00:00:00 2001 From: cherryblossom000 <31467609+cherryblossom000@users.noreply.github.com> Date: Fri, 16 Apr 2021 20:28:15 +1000 Subject: [PATCH 1/6] Add missing code fence --- src/doc/style-guide/src/expressions.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/doc/style-guide/src/expressions.md b/src/doc/style-guide/src/expressions.md index 0aed8763a0628..de8eba1dc6e7c 100644 --- a/src/doc/style-guide/src/expressions.md +++ b/src/doc/style-guide/src/expressions.md @@ -178,10 +178,12 @@ let f = Foo { Functional record update syntax is treated like a field, but it must never have a trailing comma. Do not put a space after `..`. +```rust let f = Foo { field1, ..an_expr }; +``` ### Tuple literals From 7577e78ce0bb8f0f91c14de8a793b06e3f7a39b0 Mon Sep 17 00:00:00 2001 From: Ivan Tham Date: Wed, 27 May 2020 22:20:26 +0800 Subject: [PATCH 2/6] Use roman 4 letter instead of word Long text without numeric numbers when numeric numbers are used are hard to read. --- src/doc/style-guide/src/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/doc/style-guide/src/README.md b/src/doc/style-guide/src/README.md index 29204603e58d3..6bdb3ae26ace8 100644 --- a/src/doc/style-guide/src/README.md +++ b/src/doc/style-guide/src/README.md @@ -37,8 +37,8 @@ options. ### Indentation and line width * Use spaces, not tabs. -* Each level of indentation must be four spaces (that is, all indentation - outside of string literals and comments must be a multiple of four). +* Each level of indentation must be 4 spaces (that is, all indentation + outside of string literals and comments must be a multiple of 4). * The maximum width for a line is 100 characters. #### Block indent From 2fc1de3c96bcd6a8c7031109c8b4ce134871d329 Mon Sep 17 00:00:00 2001 From: Josh Triplett Date: Fri, 28 Aug 2020 16:42:47 -0700 Subject: [PATCH 3/6] Clarify conditions for single-line blocks Use consistent phrasing, and add an "and". --- src/doc/style-guide/src/expressions.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/doc/style-guide/src/expressions.md b/src/doc/style-guide/src/expressions.md index de8eba1dc6e7c..3068825e0f920 100644 --- a/src/doc/style-guide/src/expressions.md +++ b/src/doc/style-guide/src/expressions.md @@ -64,8 +64,8 @@ Write an empty block as `{}`. Write a block on a single line if: * it is either used in expression position (not statement position) or is an - unsafe block in statement position -* it contains a single-line expression and no statements + unsafe block in statement position, +* it contains a single-line expression and no statements, and * it contains no comments For a single-line block, put spaces after the opening brace and before the From 9539af86c31b05a83cde43bb888a2232decf73d4 Mon Sep 17 00:00:00 2001 From: Josh Triplett Date: Fri, 28 Aug 2020 16:44:34 -0700 Subject: [PATCH 4/6] Clarify guide for unbraced closures: grammatical consistency --- src/doc/style-guide/src/expressions.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/doc/style-guide/src/expressions.md b/src/doc/style-guide/src/expressions.md index 3068825e0f920..1870b194d9d87 100644 --- a/src/doc/style-guide/src/expressions.md +++ b/src/doc/style-guide/src/expressions.md @@ -125,9 +125,9 @@ expression of the closure. Between the `|`s, use function definition syntax, but elide types where possible. Use closures without the enclosing `{}`, if possible. Add the `{}` when you have -a return type, when there are statements, there are comments in the body, or the -body expression spans multiple lines and is a control-flow expression. If using -braces, follow the rules above for blocks. Examples: +a return type, when there are statements, when there are comments in the body, +or when the body expression spans multiple lines and is a control-flow +expression. If using braces, follow the rules above for blocks. Examples: ```rust |arg1, arg2| expr From 9362ae1616e98b08a88dcb806a11a366ed1c6b8b Mon Sep 17 00:00:00 2001 From: Josh Triplett Date: Fri, 28 Aug 2020 16:45:25 -0700 Subject: [PATCH 5/6] Clarify guide for unbraced closures, regarding comments --- src/doc/style-guide/src/expressions.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/doc/style-guide/src/expressions.md b/src/doc/style-guide/src/expressions.md index 1870b194d9d87..0d4b97895cdde 100644 --- a/src/doc/style-guide/src/expressions.md +++ b/src/doc/style-guide/src/expressions.md @@ -125,8 +125,8 @@ expression of the closure. Between the `|`s, use function definition syntax, but elide types where possible. Use closures without the enclosing `{}`, if possible. Add the `{}` when you have -a return type, when there are statements, when there are comments in the body, -or when the body expression spans multiple lines and is a control-flow +a return type, when there are statements, when there are comments inside the +closure, or when the body expression spans multiple lines and is a control-flow expression. If using braces, follow the rules above for blocks. Examples: ```rust From 9ea1180cc7e1ec93d3398c8aefa32dcbff21e989 Mon Sep 17 00:00:00 2001 From: Josh Triplett Date: Fri, 28 Aug 2020 16:46:07 -0700 Subject: [PATCH 6/6] Simplify wording in guide for unbraced closures --- src/doc/style-guide/src/expressions.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/doc/style-guide/src/expressions.md b/src/doc/style-guide/src/expressions.md index 0d4b97895cdde..bf3fe87a0a460 100644 --- a/src/doc/style-guide/src/expressions.md +++ b/src/doc/style-guide/src/expressions.md @@ -126,8 +126,8 @@ but elide types where possible. Use closures without the enclosing `{}`, if possible. Add the `{}` when you have a return type, when there are statements, when there are comments inside the -closure, or when the body expression spans multiple lines and is a control-flow -expression. If using braces, follow the rules above for blocks. Examples: +closure, or when the body expression is a control-flow expression that spans +multiple lines. If using braces, follow the rules above for blocks. Examples: ```rust |arg1, arg2| expr