You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
According to Rust official developer recommendations, we can add for some struct, enum, trait or function. But its description is a bit vague, so it is difficult to specify exactly where to add #[must_use].
We need a concise rule that does not give false positives, to serve as a rule for adding #[must_use].
If some functions are added but others are omitted, then this is an ERROR, so I proposed in the PR #284 to first remove the use of #[must_use], and then mark all the missing functions after determining the rules.
Here are some discussions on how to make this rule:
We can observe how must_use is used in different code bases. As listed above, the standard library has some places using it, while the official hashbrown project rarely uses it:
For pure functions, whenever they are called, their return values will be used, so mark them;
For functions with side effects, we do not mark them by default;
But if their return values are likely to be used in common use cases, then we add them;
For auxiliary structures(or enum and trait), they are often used as return values (such as the mark on core::iter::Map), if the usage is similar, then also mark it;
The rest are not marked for the time being. If there is a special use case, you can submit a PR and explain the reason for adding it. (Of course, you can also attach the reason to #[must_use = "<the reason>"])
The text was updated successfully, but these errors were encountered:
Cause #287 is merged but the patch version is not bumped (It should be, for adding #[must_use] is a breaking change.), we have not yet fully resolved this issue.
Before we updated to 0.1.0, we run the cargo semver-checks would fail cause 0.0.19 should be bump to 0.0.20 or 0.1.0 (for adding #[must_use] is a breaking change).
According to Rust official developer recommendations, we can add for some struct, enum, trait or function. But its description is a bit vague, so it is difficult to specify exactly where to add
#[must_use]
.We need a concise rule that does not give false positives, to serve as a rule for adding
#[must_use]
.If some functions are added but others are omitted, then this is an ERROR, so I proposed in the PR #284 to first remove the use of
#[must_use]
, and then mark all the missing functions after determining the rules.Here are some discussions on how to make this rule:
#[must_use]
functions in the standard library rust-lang/rust#48926We can observe how must_use is used in different code bases. As listed above, the standard library has some places using it, while the official hashbrown project rarely uses it:
My brief opinion is:
core::iter::Map
), if the usage is similar, then also mark it;#[must_use = "<the reason>"]
)The text was updated successfully, but these errors were encountered: