diff options
| author | Zack M. Davis <code@zackmdavis.net> | 2017-09-15 17:11:02 -0700 |
|---|---|---|
| committer | Zack M. Davis <code@zackmdavis.net> | 2017-09-15 17:13:48 -0700 |
| commit | d09db63d2ff0223c8c0cc2626547f9abe1b06a84 (patch) | |
| tree | f2a5d6c15b79ea42badb9891e06f10bbf2c589af | |
| parent | e9569d91cffbb5710a73deaca44fcd4122d23c85 (diff) | |
| download | rust-d09db63d2ff0223c8c0cc2626547f9abe1b06a84.tar.gz rust-d09db63d2ff0223c8c0cc2626547f9abe1b06a84.zip | |
unstable book section for `fn_must_use`
| -rw-r--r-- | src/doc/unstable-book/src/language-features/fn-must-use.md | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/doc/unstable-book/src/language-features/fn-must-use.md b/src/doc/unstable-book/src/language-features/fn-must-use.md new file mode 100644 index 00000000000..71b6cd663a0 --- /dev/null +++ b/src/doc/unstable-book/src/language-features/fn-must-use.md @@ -0,0 +1,30 @@ +# `fn_must_use` + +The tracking issue for this feature is [#43302]. + +[#43302]: https://github.com/rust-lang/rust/issues/43302 + +------------------------ + +The `fn_must_use` feature allows functions and methods to be annotated with +`#[must_use]`, indicating that the `unused_must_use` lint should require their +return values to be used (similarly to how types annotated with `must_use`, +most notably `Result`, are linted if not used). + +## Examples + +```rust +#![feature(fn_must_use)] + +#[must_use] +fn double(x: i32) -> i32 { + 2 * x +} + +fn main() { + double(4); // warning: unused return value of `double` which must be used + + let _ = double(4); // (no warning) +} + +``` |
