Skip to content

Commit d9311b6

Browse files
cuviperjieyouxuworkingjubileetgross35
authored
Apply suggestions from code review
Co-authored-by: 许杰友 Jieyou Xu (Joe) <39484203+jieyouxu@users.noreply.github.com> Co-authored-by: Jubilee <workingjubilee@gmail.com> Co-authored-by: Trevor Gross <t.gross35@gmail.com>
1 parent 8ab93f9 commit d9311b6

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

content/Rust-1.88.0.md

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ For more information, see the original [unstable announcement](https://blog.rust
3434

3535
### Let chains
3636

37-
This feature allows `&&`-chaining `let` statements inside `if` and `while` conditions, even intermingling with boolean expressions, so there is less distinction between `if`/`if let` and `while`/`while let` anymore. The patterns inside the `let` sub-expressions can be irrefutable or refutable, and bindings are usable in later parts of the chain as well as the body.
37+
This feature allows `&&`-chaining `let` statements inside `if` and `while` conditions, even intermingling with boolean expressions, so there is less distinction between `if`/`if let` and `while`/`while let`. The patterns inside the `let` sub-expressions can be irrefutable or refutable, and bindings are usable in later parts of the chain as well as the body.
3838

3939
For example, [this actual snippet](https://github.com/rust-lang/rust/blob/28f1c807911c63f08d98e7b468cfcf15a441e34b/compiler/rustc_ast_passes/src/feature_gate.rs#L327-L338) from the compiler combines multiple conditions which would have required nesting `if let` and `if` blocks before:
4040

@@ -50,11 +50,13 @@ For example, [this actual snippet](https://github.com/rust-lang/rust/blob/28f1c8
5050
}
5151
```
5252

53-
Let chains are only available in the Rust 2024 edition, as this feature depends on the [`if let` temporary scope](https://doc.rust-lang.org/edition-guide/rust-2024/temporary-if-let-scope.html) change for more consistent drop order. Earlier efforts tried to work with all editions, but some difficult edges cases threatened the integrity of the implementation. 2024 made it feasible, so please upgrade your crate's edition if you'd like to use this feature!
53+
Let chains are only available in the Rust 2024 edition, as this feature depends on the [`if let` temporary scope](https://doc.rust-lang.org/edition-guide/rust-2024/temporary-if-let-scope.html) change for more consistent drop order.
54+
Earlier efforts tried to work with all editions, but some difficult edge cases threatened the integrity of the implementation. 2024 made it feasible, so please upgrade your crate's edition if you'd like to use this feature!
5455

5556
### Naked functions
5657

57-
Rust now supports writing naked functions with no compiler-generated epilogue and prologue, allowing full control over the generated assembly for a particular function. This is a more ergonomic alternative to defining functions in a `global_asm!` block. A naked function is marked with the `#[unsafe(naked)]` attribute, and its body consists of a single `naked_asm!` call, for example:
58+
Rust now supports writing naked functions with no compiler-generated epilogue and prologue, allowing full control over the generated assembly for a particular function. This is a more ergonomic alternative to defining functions in a `global_asm!` block. A naked function is marked with the `#[unsafe(naked)]` attribute, and its body consists of a single `naked_asm!` call.
59+
For example:
5860

5961
```rust
6062
#[unsafe(naked)]
@@ -69,15 +71,15 @@ pub unsafe extern "sysv64" fn wrapping_add(a: u64, b: u64) {
6971

7072
The handwritten assembly block defines the _entire_ function body: unlike non-naked functions, the compiler does not add any special handling for arguments or return values. Naked functions are used in low-level settings like Rust's [`compiler-builtins`](https://github.com/rust-lang/compiler-builtins), operating systems, and embedded applications.
7173

72-
Look for a more detailed post soon on [Inside Rust](https://blog.rust-lang.org/inside-rust/)!
74+
Look for a more detailed post on this soon!
7375

7476
### Boolean configuration
7577

7678
The `cfg` predicate language now supports boolean literals, `true` and `false`, acting as a configuration that is always enabled or disabled, respectively. This works in Rust [conditional compilation](https://doc.rust-lang.org/reference/conditional-compilation.html) with `cfg` and `cfg_attr` attributes and the built-in `cfg!` macro, and also in Cargo `[target]` tables in both [configuration](https://doc.rust-lang.org/cargo/reference/config.html#target) and [manifests](https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#platform-specific-dependencies).
7779

78-
If you are familiar with set theory, you might already be using empty sets like `cfg(all())` for enabled and `cfg(any())` for disabled, but this meaning is rather implicit and easy to get backwards. The boolean literals offer a more direct way to say what you mean.
80+
If you are familiar with set theory, you might already be using empty sets like `cfg(all())` for enabled and `cfg(any())` for disabled, but this meaning is rather implicit and easy to get backwards. `cfg(true)` and `cfg(false)` offer a more direct way to say what you mean.
7981

80-
See [RFC 3695](https://rust-lang.github.io/rfcs/3695-cfg-boolean-literals.html) for more!
82+
See [RFC 3695](https://rust-lang.github.io/rfcs/3695-cfg-boolean-literals.html) for more background!
8183

8284
### Stabilized APIs
8385

@@ -97,8 +99,12 @@ These previously stable APIs are now stable in const contexts:
9799

98100
- [`NonNull<T>::replace`](https://doc.rust-lang.org/stable/std/ptr/struct.NonNull.html#method.replace)
99101
- [`<*mut T>::replace`](https://doc.rust-lang.org/stable/std/primitive.pointer.html#method.replace)
100-
- [`std::ptr::swap_nonoverlapping`](https://github.com/rust-lang/rust/pull/137280)
101-
- [`Cell::{replace, get, get_mut, from_mut, as_slice_of_cells}`](https://github.com/rust-lang/rust/pull/137928)
102+
- [`std::ptr::swap_nonoverlapping`](https://doc.rust-lang.org/stable/std/ptr/fn.swap_nonoverlapping.html)
103+
- [`Cell::replace`](https://doc.rust-lang.org/stable/std/cell/struct.Cell.html#method.replace)
104+
- [`Cell::get`](https://doc.rust-lang.org/stable/std/cell/struct.Cell.html#method.get)
105+
- [`Cell::get_mut`](https://doc.rust-lang.org/stable/std/cell/struct.Cell.html#method.get_mut)
106+
- [`Cell::from_mut`](https://doc.rust-lang.org/stable/std/cell/struct.Cell.html#method.from_mut)
107+
- [`Cell::as_slice_of_cells`](https://doc.rust-lang.org/stable/std/cell/struct.Cell.html#method.as_slice_of_cells)
102108

103109
### Other changes
104110

0 commit comments

Comments
 (0)