Rollup merge of #62683 - c410-f3r:fn-attrs-doc, r=Centril

Chapter for `param_attrs`

Most the information was taken from the RFC.

cc #60406
This commit is contained in:
Mark Rousskov 2019-07-16 11:38:54 -04:00 committed by GitHub
commit c9be624c26
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -0,0 +1,27 @@
# `param_attrs`
The tracking issue for this feature is: [#60406]
[#60406]: https://github.com/rust-lang/rust/issues/60406
Allow attributes in formal function parameter position so external tools and compiler internals can
take advantage of the additional information that the parameters provide.
Enables finer conditional compilation with `#[cfg(..)]` and linting control of variables. Moreover,
opens the path to richer DSLs created by users.
------------------------
Example:
```rust
#![feature(param_attrs)]
fn len(
#[cfg(windows)] slice: &[u16],
#[cfg(not(windows))] slice: &[u8],
) -> usize
{
slice.len()
}
```