Skip to content

Commit c9be624

Browse files
Rollup merge of rust-lang#62683 - c410-f3r:fn-attrs-doc, r=Centril
Chapter for `param_attrs` Most the information was taken from the RFC. cc rust-lang#60406
2 parents ae26723 + 5ad4901 commit c9be624

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# `param_attrs`
2+
3+
The tracking issue for this feature is: [#60406]
4+
5+
[#60406]: https://github.com/rust-lang/rust/issues/60406
6+
7+
Allow attributes in formal function parameter position so external tools and compiler internals can
8+
take advantage of the additional information that the parameters provide.
9+
10+
Enables finer conditional compilation with `#[cfg(..)]` and linting control of variables. Moreover,
11+
opens the path to richer DSLs created by users.
12+
13+
------------------------
14+
15+
Example:
16+
17+
```rust
18+
#![feature(param_attrs)]
19+
20+
fn len(
21+
#[cfg(windows)] slice: &[u16],
22+
#[cfg(not(windows))] slice: &[u8],
23+
) -> usize
24+
{
25+
slice.len()
26+
}
27+
```

0 commit comments

Comments
 (0)