std::fmt::FormatterFn -> std::fmt::FromFn · patricklam/verify-rust-std@262a4f6 (original) (raw)

`@@ -1018,7 +1018,8 @@ impl<'a, 'b: 'a> DebugMap<'a, 'b> {

`

1018

1018

`}

`

1019

1019

`}

`

1020

1020

``

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.

``

1022

1023

`///

`

1023

1024

`/// # Examples

`

1024

1025

`///

`

`@@ -1030,17 +1031,25 @@ impl<'a, 'b: 'a> DebugMap<'a, 'b> {

`

1030

1031

`/// assert_eq!(format!("{}", value), "a");

`

1031

1032

`/// assert_eq!(format!("{:?}", value), "'a'");

`

1032

1033

`///

`

1033

``

`-

/// let wrapped = fmt::FormatterFn(|f| write!(f, "{value:?}"));

`

``

1034

`+

/// let wrapped = fmt::from_fn(|f| write!(f, "{value:?}"));

`

1034

1035

`/// assert_eq!(format!("{}", wrapped), "'a'");

`

1035

1036

`/// assert_eq!(format!("{:?}", wrapped), "'a'");

`

1036

1037

```` /// ```

````

1037

1038

`#[unstable(feature = "debug_closure_helpers", issue = "117729")]

`

1038

``

`-

pub struct FormatterFn(pub F)

`

``

1039

`+

pub fn from_fn<F: Fn(&mut fmt::Formatter<'_>) -> fmt::Result>(f: F) -> FromFn {

`

``

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)

`

1039

1048

`where

`

1040

1049

`F: Fn(&mut fmt::Formatter<'_>) -> fmt::Result;

`

1041

1050

``

1042

1051

`#[unstable(feature = "debug_closure_helpers", issue = "117729")]

`

1043

``

`-

impl fmt::Debug for FormatterFn

`

``

1052

`+

impl fmt::Debug for FromFn

`

1044

1053

`where

`

1045

1054

`F: Fn(&mut fmt::Formatter<'_>) -> fmt::Result,

`

1046

1055

`{

`

`@@ -1050,7 +1059,7 @@ where

`

1050

1059

`}

`

1051

1060

``

1052

1061

`#[unstable(feature = "debug_closure_helpers", issue = "117729")]

`

1053

``

`-

impl fmt::Display for FormatterFn

`

``

1062

`+

impl fmt::Display for FromFn

`

1054

1063

`where

`

1055

1064

`F: Fn(&mut fmt::Formatter<'_>) -> fmt::Result,

`

1056

1065

`{

`