From 837b550238aa671a591ccf282dddeab29cadb206 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 18 May 2024 04:49:42 +0200 Subject: Merging upstream version 1.71.1+dfsg1. Signed-off-by: Daniel Baumann --- src/doc/style-guide/src/principles.md | 2 +- src/doc/style-guide/src/statements.md | 37 +++++++++++++++++++++++------------ src/doc/style-guide/src/types.md | 2 +- 3 files changed, 27 insertions(+), 14 deletions(-) (limited to 'src/doc/style-guide') diff --git a/src/doc/style-guide/src/principles.md b/src/doc/style-guide/src/principles.md index 216689731..2d203f264 100644 --- a/src/doc/style-guide/src/principles.md +++ b/src/doc/style-guide/src/principles.md @@ -6,7 +6,7 @@ following principles (in rough priority order): * readability - scan-ability - avoiding misleading formatting - - accessibility - readable and editable by users using the the widest + - accessibility - readable and editable by users using the widest variety of hardware, including non-visual accessibility interfaces - readability of code in contexts without syntax highlighting or IDE assistance, such as rustc error messages, diffs, grep, and other diff --git a/src/doc/style-guide/src/statements.md b/src/doc/style-guide/src/statements.md index 4ab1c36f9..671e6d31a 100644 --- a/src/doc/style-guide/src/statements.md +++ b/src/doc/style-guide/src/statements.md @@ -138,18 +138,31 @@ Otherwise, the `else` keyword and opening brace should be placed on the next lin For example: ```rust -let Some(x) = abcdef() - .foo( - "abc", - some_really_really_really_long_ident, - "ident", - "123456", - ) - .bar() - .baz() - .qux("fffffffffffffffff") -else { - foo_bar() +fn main() { + let Some(x) = abcdef() + .foo( + "abc", + some_really_really_really_long_ident, + "ident", + "123456", + ) + .bar() + .baz() + .qux("fffffffffffffffff") + else { + return + }; + + let Some(x) = some_really_really_really_really_really_really_really_really_really_long_name + else { + return; + }; + + let Some(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) = + bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb + else { + return; + }; } ``` diff --git a/src/doc/style-guide/src/types.md b/src/doc/style-guide/src/types.md index 25861ddab..ae456ef21 100644 --- a/src/doc/style-guide/src/types.md +++ b/src/doc/style-guide/src/types.md @@ -6,7 +6,7 @@ * `[T; expr]`, e.g., `[u32; 42]`, `[Vec; 10 * 2 + foo()]` (space after colon, no spaces around square brackets) * `*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) -* `unsafe extern "C" fn<'a, 'b, 'c>(T, U, V) -> W` or `fn()` (single spaces around keyowrds 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) * `!` should be 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) * ` as SomeTrait>::Foo::Bar` or `Foo::Bar` or `::Foo::Bar` (no spaces around `::` or angle brackets, single spaces around `as`) -- cgit v1.2.3