View all comments
Feature gate: #![feature(debug_closure_helpers)]
This is a tracking issue for adding helpers to core::fmt that can use closures for formatting values.
ACP: rust-lang/libs-team#288
Public API
// core::fmt
impl DebugList<'_, '_> {
fn entry_with<F>(&mut self, entry_fmt: F) -> &mut Self
where
F: FnOnce(&mut Formatter) -> fmt::Result;
}
impl DebugMap<'_, '_> {
fn key_with<F>(&mut self, key_fmt: F) -> &mut Self
where
F: FnOnce(&mut Formatter) -> fmt::Result;
fn value_with<F>(&mut self, value_fmt: F) -> &mut Self
where
F: FnOnce(&mut Formatter) -> fmt::Result;
}
impl DebugSet<'_, '_> {
fn entry_with<F>(&mut self, entry_fmt: F) -> &mut Self
where
F: FnOnce(&mut Formatter) -> fmt::Result;
}
impl DebugStruct<'_, '_> {
fn field_with<F>(&mut self, name: &str, field_fmt: F) -> &mut Self
where
F: FnOnce(&mut Formatter) -> fmt::Result;
}
impl DebugTuple<'_, '_> { // also DebugSet
fn field_with<F>(&mut self, field_fmt: F) -> &mut Self
where
F: FnOnce(&mut Formatter) -> fmt::Result;
}
Steps / History
Unresolved Questions
View all comments
Feature gate:
#![feature(debug_closure_helpers)]This is a tracking issue for adding helpers to
core::fmtthat can use closures for formatting values.ACP: rust-lang/libs-team#288
Public API
Steps / History
fmt::Debughelpers #117730FormatterFn/FromFn/from_fnto separate tracking issue: Tracking Issue forfmt_from_fn#146705debug_closure_helpers#146099Unresolved Questions
{orig_method}_with, for exampleDebugStruct::field_with()is likeDebugStruct::field().FormatterFntype was renamed toFromFn(and wrapped infrom_fn(), the helper methods kept their original names.DebugMapstruct gotkey_with()andvalue_with(), but notentry_with()-- is it worth adding that?entry_with; see ReplaceDebug::{key_with, value_with}withDebugMap::entry_withlibs-team#563 (comment)FormatterFn<F>place a trait bound onFso that call sites can be tidier?Footnotes
https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html ↩