Rollup merge of #136502 - yotamofek:pr/fmt-from-fn-must-use, r=dtolnay
Mark `std::fmt::from_fn` as `#[must_use]` While working on #135494 I managed to shoot my own foot a few times by forgetting to actually use the result of `fmt::from_fn`, so I think a `#[must_use]` could be appropriate! Didn't have a good message to put in the attr so left it blank, still unstable so we can come back to it I guess? cc #117729 (and a huge +1 for getting it stabilized, it's very useful IMHO)
This commit is contained in:
commit
ba420062f1
1 changed files with 1 additions and 0 deletions
|
@ -1228,6 +1228,7 @@ impl<'a, 'b: 'a> DebugMap<'a, 'b> {
|
|||
/// assert_eq!(format!("{:?}", wrapped), "'a'");
|
||||
/// ```
|
||||
#[unstable(feature = "debug_closure_helpers", issue = "117729")]
|
||||
#[must_use = "returns a type implementing Debug and Display, which do not have any effects unless they are used"]
|
||||
pub fn from_fn<F: Fn(&mut fmt::Formatter<'_>) -> fmt::Result>(f: F) -> FromFn<F> {
|
||||
FromFn(f)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue