Function rocket::mtls::x509::der_parser::asn1_rs::nom::lib::std::fmt::from_fn

source ·
pub fn from_fn<F>(f: F) -> FromFn<F>
where F: Fn(&mut Formatter<'_>) -> Result<(), Error>,
🔬This is a nightly-only experimental API. (debug_closure_helpers)
Available on crate feature mtls only.
Expand description

Creates a type whose fmt::Debug and fmt::Display impls are provided with the function f.

§Examples

#![feature(debug_closure_helpers)]
use std::fmt;

let value = 'a';
assert_eq!(format!("{}", value), "a");
assert_eq!(format!("{:?}", value), "'a'");

let wrapped = fmt::from_fn(|f| write!(f, "{value:?}"));
assert_eq!(format!("{}", wrapped), "'a'");
assert_eq!(format!("{:?}", wrapped), "'a'");