Skip to content

Commit d79d61e

Browse files
authored
Rollup merge of rust-lang#145915 - coolreader18:stabilize-fmt_from_fn, r=dtolnay
Stabilize `fmt::from_fn` Resolves rust-lang#146705, pending its FCP. As discussed in that tracking issue and rust-lang#117729, this splits `fmt::from_fn` out from the `debug_closure_helpers` feature.
2 parents 04535f2 + 8461089 commit d79d61e

File tree

3 files changed

+10
-13
lines changed

3 files changed

+10
-13
lines changed

alloc/src/fmt.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,7 @@ pub use core::fmt::{DebugAsHex, FormattingOptions, Sign};
602602
pub use core::fmt::{DebugList, DebugMap, DebugSet, DebugStruct, DebugTuple};
603603
#[stable(feature = "rust1", since = "1.0.0")]
604604
pub use core::fmt::{Formatter, Result, Write};
605-
#[unstable(feature = "debug_closure_helpers", issue = "117729")]
605+
#[stable(feature = "fmt_from_fn", since = "CURRENT_RUSTC_VERSION")]
606606
pub use core::fmt::{FromFn, from_fn};
607607
#[stable(feature = "rust1", since = "1.0.0")]
608608
pub use core::fmt::{LowerExp, UpperExp};

core/src/fmt/builders.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,13 +1210,12 @@ impl<'a, 'b: 'a> DebugMap<'a, 'b> {
12101210
}
12111211
}
12121212

1213-
/// Creates a type whose [`fmt::Debug`] and [`fmt::Display`] impls are provided with the function
1214-
/// `f`.
1213+
/// Creates a type whose [`fmt::Debug`] and [`fmt::Display`] impls are
1214+
/// forwarded to the provided closure.
12151215
///
12161216
/// # Examples
12171217
///
12181218
/// ```
1219-
/// #![feature(debug_closure_helpers)]
12201219
/// use std::fmt;
12211220
///
12221221
/// let value = 'a';
@@ -1227,21 +1226,19 @@ impl<'a, 'b: 'a> DebugMap<'a, 'b> {
12271226
/// assert_eq!(format!("{}", wrapped), "'a'");
12281227
/// assert_eq!(format!("{:?}", wrapped), "'a'");
12291228
/// ```
1230-
#[unstable(feature = "debug_closure_helpers", issue = "117729")]
1229+
#[stable(feature = "fmt_from_fn", since = "CURRENT_RUSTC_VERSION")]
12311230
#[must_use = "returns a type implementing Debug and Display, which do not have any effects unless they are used"]
12321231
pub fn from_fn<F: Fn(&mut fmt::Formatter<'_>) -> fmt::Result>(f: F) -> FromFn<F> {
12331232
FromFn(f)
12341233
}
12351234

1236-
/// Implements [`fmt::Debug`] and [`fmt::Display`] using a function.
1235+
/// Implements [`fmt::Debug`] and [`fmt::Display`] via the provided closure.
12371236
///
12381237
/// Created with [`from_fn`].
1239-
#[unstable(feature = "debug_closure_helpers", issue = "117729")]
1240-
pub struct FromFn<F>(F)
1241-
where
1242-
F: Fn(&mut fmt::Formatter<'_>) -> fmt::Result;
1238+
#[stable(feature = "fmt_from_fn", since = "CURRENT_RUSTC_VERSION")]
1239+
pub struct FromFn<F>(F);
12431240

1244-
#[unstable(feature = "debug_closure_helpers", issue = "117729")]
1241+
#[stable(feature = "fmt_from_fn", since = "CURRENT_RUSTC_VERSION")]
12451242
impl<F> fmt::Debug for FromFn<F>
12461243
where
12471244
F: Fn(&mut fmt::Formatter<'_>) -> fmt::Result,
@@ -1251,7 +1248,7 @@ where
12511248
}
12521249
}
12531250

1254-
#[unstable(feature = "debug_closure_helpers", issue = "117729")]
1251+
#[stable(feature = "fmt_from_fn", since = "CURRENT_RUSTC_VERSION")]
12551252
impl<F> fmt::Display for FromFn<F>
12561253
where
12571254
F: Fn(&mut fmt::Formatter<'_>) -> fmt::Result,

core/src/fmt/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pub use num_buffer::{NumBuffer, NumBufferTrait};
3939

4040
#[stable(feature = "debug_builders", since = "1.2.0")]
4141
pub use self::builders::{DebugList, DebugMap, DebugSet, DebugStruct, DebugTuple};
42-
#[unstable(feature = "debug_closure_helpers", issue = "117729")]
42+
#[stable(feature = "fmt_from_fn", since = "CURRENT_RUSTC_VERSION")]
4343
pub use self::builders::{FromFn, from_fn};
4444

4545
/// The type returned by formatter methods.

0 commit comments

Comments
 (0)