@@ -1018,7 +1018,8 @@ impl<'a, 'b: 'a> DebugMap<'a, 'b> {
10181018 }
10191019}
10201020
1021- /// Implements [`fmt::Debug`] and [`fmt::Display`] using a function.
1021+ /// Creates a type whose [`fmt::Debug`] and [`fmt::Display`] impls are provided with the function
1022+ /// `f`.
10221023///
10231024/// # Examples
10241025///
@@ -1030,17 +1031,25 @@ impl<'a, 'b: 'a> DebugMap<'a, 'b> {
10301031/// assert_eq!(format!("{}", value), "a");
10311032/// assert_eq!(format!("{:?}", value), "'a'");
10321033///
1033- /// let wrapped = fmt::FormatterFn (|f| write!(f, "{value:?}"));
1034+ /// let wrapped = fmt::from_fn (|f| write!(f, "{value:?}"));
10341035/// assert_eq!(format!("{}", wrapped), "'a'");
10351036/// assert_eq!(format!("{:?}", wrapped), "'a'");
10361037/// ```
10371038#[ unstable( feature = "debug_closure_helpers" , issue = "117729" ) ]
1038- pub struct FormatterFn < F > ( pub F )
1039+ pub fn from_fn < F : Fn ( & mut fmt:: Formatter < ' _ > ) -> fmt:: Result > ( f : F ) -> FromFn < F > {
1040+ FromFn ( f)
1041+ }
1042+
1043+ /// Implements [`fmt::Debug`] and [`fmt::Display`] using a function.
1044+ ///
1045+ /// Created with [`from_fn`].
1046+ #[ unstable( feature = "debug_closure_helpers" , issue = "117729" ) ]
1047+ pub struct FromFn < F > ( F )
10391048where
10401049 F : Fn ( & mut fmt:: Formatter < ' _ > ) -> fmt:: Result ;
10411050
10421051#[ unstable( feature = "debug_closure_helpers" , issue = "117729" ) ]
1043- impl < F > fmt:: Debug for FormatterFn < F >
1052+ impl < F > fmt:: Debug for FromFn < F >
10441053where
10451054 F : Fn ( & mut fmt:: Formatter < ' _ > ) -> fmt:: Result ,
10461055{
@@ -1050,7 +1059,7 @@ where
10501059}
10511060
10521061#[ unstable( feature = "debug_closure_helpers" , issue = "117729" ) ]
1053- impl < F > fmt:: Display for FormatterFn < F >
1062+ impl < F > fmt:: Display for FromFn < F >
10541063where
10551064 F : Fn ( & mut fmt:: Formatter < ' _ > ) -> fmt:: Result ,
10561065{
0 commit comments