Skip to content

Commit 25eea5f

Browse files
committed
Move "Infer arguments" up into the arguments section
1 parent a6e34d8 commit 25eea5f

1 file changed

Lines changed: 20 additions & 20 deletions

File tree

src/types/generics/index.md

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,26 @@ FCW exists for non-value (function) position, see
227227
https://doc.rust-lang.org/nightly/rustc/lints/listing/warn-by-default.html#late-bound-lifetime-arguments
228228
-->
229229
230+
r[generics.arguments.inference]
231+
### Infer arguments
232+
233+
r[generics.arguments.inference.intro]
234+
The placeholder `_` may be used for type or const arguments when the compiler can infer the value.
235+
236+
> [!EXAMPLE]
237+
> ```rust
238+
> let v: Vec<_> = vec![1, 2, 3]; // _ inferred as i32
239+
>
240+
> type T<const N: usize> = [i32; N];
241+
> let x: T<_> = [1]; // _ inferred as 1
242+
> ```
243+
244+
> [!NOTE]
245+
> The `_` placeholder cannot be used for lifetime arguments; use `'_` for elided lifetimes instead.
246+
247+
r[generics.arguments.inference.parentheses]
248+
Infer arguments may be surrounded by any number of matching parentheses.
249+
230250
r[generics.associated]
231251
## Associated item constraints
232252
@@ -303,26 +323,6 @@ They are not permitted in the following positions:
303323
> fn f5() { 0u32.clone::<T = u32>(); }
304324
> ```
305325
306-
r[generics.arguments.inference]
307-
### Infer arguments
308-
309-
r[generics.arguments.inference.intro]
310-
The placeholder `_` may be used for type or const arguments when the compiler can infer the value.
311-
312-
> [!EXAMPLE]
313-
> ```rust
314-
> let v: Vec<_> = vec![1, 2, 3]; // _ inferred as i32
315-
>
316-
> type T<const N: usize> = [i32; N];
317-
> let x: T<_> = [1]; // _ inferred as 1
318-
> ```
319-
320-
> [!NOTE]
321-
> The `_` placeholder cannot be used for lifetime arguments; use `'_` for elided lifetimes instead.
322-
323-
r[generics.arguments.inference.parentheses]
324-
Infer arguments may be surrounded by any number of matching parentheses.
325-
326326
r[generics.const]
327327
## Const generics
328328

0 commit comments

Comments
 (0)