Rollup merge of #150300 - EFanZh:patch-1, r=dtolnay,tgross35

Constify `fmt::from_fn`

See <https://github.com/rust-lang/rust/issues/117729#issuecomment-3683047620>.
This commit is contained in:
Jonathan Brouwer 2026-01-31 21:42:46 +01:00 committed by GitHub
commit f580ca88ee
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1227,8 +1227,9 @@ impl<'a, 'b: 'a> DebugMap<'a, 'b> {
/// assert_eq!(format!("{:?}", wrapped), "'a'");
/// ```
#[stable(feature = "fmt_from_fn", since = "1.93.0")]
#[rustc_const_stable(feature = "const_fmt_from_fn", since = "CURRENT_RUSTC_VERSION")]
#[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> {
pub const fn from_fn<F: Fn(&mut fmt::Formatter<'_>) -> fmt::Result>(f: F) -> FromFn<F> {
FromFn(f)
}