Tracking Issue for `debug_closure_helpers`
Open
Nobody has claimed this yet.
C-tracking-issue
disposition-merge
finished-final-comment-period
T-libs
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
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.
ACP: https://github.com/rust-lang/libs-team/issues/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
- Implementation: #117730
- Moved
FormatterFn/FromFn/from_fnto separate tracking issue: #146705 - Final comment period (FCP)^1
- Stabilization PR: #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 https://github.com/rust-lang/libs-team/issues/563#issuecomment-2760089572
- Resolved to not add
- Should
FormatterFn<F>place a trait bound onFso that call sites can be tidier?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Read the public API and the completed implementation referenced as #117730, then review stabilization PR #146099 and the resolved questions in this issue. Check the stabilization criteria and final comment period status; done means the API is approved and the stabilization work is merged.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100