Skip to content

Commit c5a48d1

Browse files
BoxyUwUtraviscross
authored andcommitted
Document inferred const args
1 parent 7a4b344 commit c5a48d1

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

src/items/generics.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,27 @@ fn generic<const B: bool>() {
227227
}
228228
```
229229

230+
r[items.generics.const.inferred]
231+
232+
r[items.generics.const.inferred.syntax]
233+
```grammar,items
234+
InferredConst ->
235+
`_`
236+
| `(` InferredConst `)`
237+
```
238+
239+
r[items.generics.const.inferred.intro]
240+
The inferred const asks the compiler to infer the const argument if possible based on the surrounding information available.
241+
242+
```rust
243+
fn make_buf() -> [u8; 1024] {
244+
[0x1; _]
245+
}
246+
```
247+
248+
r[items.generics.const.inferred.constraint]
249+
It cannot be used in item signatures.
250+
230251
r[items.generics.where]
231252
## Where clauses
232253

src/paths.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ GenericArgsConst ->
6565
| LiteralExpression
6666
| `-` LiteralExpression
6767
| SimplePathSegment
68+
| InferredConst
6869
6970
GenericArgsBinding ->
7071
IDENTIFIER GenericArgs? `=` Type

0 commit comments

Comments
 (0)