8000 More content · Dengjianping/blog.rust-lang.org@97aca5f · GitHub
[go: up one dir, main page]

Skip to content

Commit 97aca5f

Browse files
More content
1 parent f8c11e0 commit 97aca5f

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

posts/2022-08-11-Rust-1.63.0.md

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,35 @@ We recommend that new APIs use these types instead of the previous type aliases
9494
[`BorrowedFd`]: https://doc.rust-lang.org/stable/std/os/unix/io/struct.BorrowedFd.html
9595
[`OwnedFd`]: https://doc.rust-lang.org/stable/std/os/unix/io/struct.OwnedFd.html
9696

97+
### `const` Mutex, RwLock, Condvar initialization
98+
99+
The [`Condvar::new`], [`Mutex::new`], and [`RwLock::new`] functions are now
100+
callable in `const` contexts, which allows avoiding the use of crates like
101+
`lazy_static` for creating global statics with `Mutex`, `RwLock`, or `Condvar`
102+
values. This builds on the [work in 1.62] to enable thinner and faster mutexes
103+
on Linux.
104+
105+
[work in 1.62]: https://blog.rust-lang.org/2022/06/30/Rust-1.62.0.html#thinner-faster-mutexes-on-linux
106+
97107
### Turbofish for generics in functions with `impl Trait`
98108

99-
The turbofish notation (`foo::<u32>()`) can be used to specify the types for explicit type
100-
parameters (`fn foo<T: Copy>`) even when `impl Trait` is used in the argument types.
101-
Specifying the type of an `impl Trait` argument via turbofish is still not possible.
109+
For a function signature like `fn foo<T>(value: T, f: impl FnOnce())`, it was an
110+
error to specify the concrete type of `T` via turbofish: `foo::<u32>(3, || {})`
111+
would fail with:
112+
113+
```text
114+
error[E0632]: cannot provide explicit generic arguments when `impl Trait` is used in argument position
115+
--> src/lib.rs:4:11
116+
|
117+
4 | foo::<u32>(3, 3);
118+
| ^^^ explicit generic argument not allowed
119+
|
120+
= note: see issue #83701 <https://github.com/rust-lang/rust/issues/83701> for more information
121+
```
122+
123+
In 1.63, this restriction is relaxed, and the explicit type of the generic can be specified.
124+
However, the `impl Trait` parameter, despite desugaring to a generic, remains
125+
opaque and cannot be specified via turbofish.
102126

103127
### Non-lexical lifetimes migration complete
104128

0 commit comments

Comments
 (0)
0