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:
commit
c9be624c26
27
src/doc/unstable-book/src/language-features/param-attrs.md
Normal file
27
src/doc/unstable-book/src/language-features/param-attrs.md
Normal 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()
|
||||
}
|
||||
```
|
Loading…
Reference in New Issue
Block a user