Skip to content

Commit d326d53

Browse files
committed
Chapter for param_attrs
1 parent 7d41ebf commit d326d53

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)