Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chapter for param_attrs #62683

Merged
merged 2 commits into from
Jul 16, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()
}
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing a newline here.