-
Notifications
You must be signed in to change notification settings - Fork 14k
Open
Labels
C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCT-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.disposition-mergeThis issue / PR is in PFCP or FCP with a disposition to merge it.This issue / PR is in PFCP or FCP with a disposition to merge it.finished-final-comment-periodThe final comment period is finished for this PR / Issue.The final comment period is finished for this PR / Issue.
Description
Feature gate: #![feature(debug_closure_helpers)]
This is a tracking issue for adding helpers to core::fmt that can use closures for formatting values.
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
- Implementation: Closure-consuming helper functions for
fmt::Debughelpers #117730 - Moved
FormatterFn/FromFn/from_fnto separate tracking issue: Tracking Issue forfmt_from_fn#146705 - Final comment period (FCP)1
- Stabilization PR: Stabilize
debug_closure_helpers#146099
Unresolved Questions
- Naming: Do any strong preferences exist regarding the new method names?
- For now I've named them
{orig_method}_with, for exampleDebugStruct::field_with()is likeDebugStruct::field(). - Resolved: The
FormatterFntype was renamed toFromFn(and wrapped infrom_fn(), the helper methods kept their original names.
- For now I've named them
- The
DebugMapstruct gotkey_with()andvalue_with(), but notentry_with()-- is it worth adding that?- Resolved to not add
entry_with; see ReplaceDebug::{key_with, value_with}withDebugMap::entry_withlibs-team#563 (comment)
- Resolved to not add
- Should
FormatterFn<F>place a trait bound onFso that call sites can be tidier?
Footnotes
ValShaped, wjones127, toymil, maxwase, AhoyISki and 15 more
Metadata
Metadata
Assignees
Labels
C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCT-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.disposition-mergeThis issue / PR is in PFCP or FCP with a disposition to merge it.This issue / PR is in PFCP or FCP with a disposition to merge it.finished-final-comment-periodThe final comment period is finished for this PR / Issue.The final comment period is finished for this PR / Issue.