blob: 490339c9d2fbfad34e3db98a69d002bdfd4ed3f6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# Annotating types with `#[must-use]`
`bindgen` can be instructed to annotate certain types with
[`#[must_use]`](https://doc.rust-lang.org/reference/attributes/diagnostics.html#the-must_use-attribute).
Some libraries have a common error type, returned by lots of their functions,
which needs to be checked after every call. In these cases it's useful to add `#[must_use]` to this type, so the Rust
compiler emits a warning when the check is missing.
### Library
* [`bindgen::Builder::must_use_type`](https://docs.rs/bindgen/latest/bindgen/struct.Builder.html#method.must_use_type)
### Command Line
* `--must-use-type <regex>`
### Annotations
```c
/** <div rustbindgen mustusetype></div> */
struct ErrorType {
// ...
};
...
```
|