Skip to content

Commit

Permalink
Rollup merge of rust-lang#62683 - c410-f3r:fn-attrs-doc, r=Centril
Browse files Browse the repository at this point in the history
Chapter for `param_attrs`

Most the information was taken from the RFC.

cc rust-lang#60406
  • Loading branch information
Mark-Simulacrum authored Jul 16, 2019
2 parents ae26723 + 5ad4901 commit c9be624
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/doc/unstable-book/src/language-features/param-attrs.md
Original file line number Diff line number Diff line change
@@ -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()
}
```

0 comments on commit c9be624

Please sign in to comment.