Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tracking Issue for simple_fmt #105054

Open
6 tasks
m-ou-se opened this issue Nov 29, 2022 · 0 comments
Open
6 tasks

Tracking Issue for simple_fmt #105054

m-ou-se opened this issue Nov 29, 2022 · 0 comments
Labels
A-fmt Area: std::fmt C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@m-ou-se
Copy link
Member

m-ou-se commented Nov 29, 2022

Feature gate: #![feature(simple_fmt)]

This is a tracking issue for the simple_fmt method on the Display format trait.

Public API

  pub trait Display {
      fn fmt(&self, f: &mut Formatter) -> Result;
+     fn simple_fmt(&self, f: &mut Formatter) -> Result {
+         self.fmt(f)
+     }
  }

Formatting placeholders without any options, like in format_args!("{}", x), will call the simple_fmt method rather than fmt. This allows for optimized implementations for e.g. <String as Display>::simple_fmt that do not need to pull in code for padding, etc. See #104525 (comment).

Steps / History

Unresolved Questions

  • Do we want this on the other formatting traits too? Or only Display?
  • Do we want to stabilize this at all, to allow crates to override simple_fmt for their own types?
  • Should the method be unsafe, such that the implementation may unsafely assume that the Formatter's options are all set to default?
@m-ou-se m-ou-se added T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. A-fmt Area: std::fmt labels Nov 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-fmt Area: std::fmt C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

1 participant