File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed
src/doc/unstable-book/src/language-features Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change
1
+ # ` fn_must_use `
2
+
3
+ The tracking issue for this feature is [ #43302 ] .
4
+
5
+ [ #43302 ] : https://github.com/rust-lang/rust/issues/43302
6
+
7
+ ------------------------
8
+
9
+ The ` fn_must_use ` feature allows functions and methods to be annotated with
10
+ ` #[must_use] ` , indicating that the ` unused_must_use ` lint should require their
11
+ return values to be used (similarly to how types annotated with ` must_use ` ,
12
+ most notably ` Result ` , are linted if not used).
13
+
14
+ ## Examples
15
+
16
+ ``` rust
17
+ #![feature(fn_must_use)]
18
+
19
+ #[must_use]
20
+ fn double (x : i32 ) -> i32 {
21
+ 2 * x
22
+ }
23
+
24
+ fn main () {
25
+ double (4 ); // warning: unused return value of `double` which must be used
26
+
27
+ let _ = double (4 ); // (no warning)
28
+ }
29
+
30
+ ```
You can’t perform that action at this time.
0 commit comments