-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Unable to create Formatter #46591
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
Comments
I don't think the solution is necessarily to create a formatter, but other ways of making the formatter available. In this case you are using For example a more general helper like this can be used, it's a helper function and type called format!("{}", Fmt(|f| self.display(f, data))); |
I also would like to be able to create a formatter. Because I want to receive format string from user. I.e. at runtime receive a format string from Are there any obstacles for adding a constructor? |
I just hit the same obstacle. I have a struct that can be rendered to string in different ways, and |
format is utility crate to make it easier to work with the Formatter.
|
What is the philosophy behind hiding ways to build a formatter? Why do we need to use a utility crate or hacky ways when the standard library can for instance build a formatter from a buffer? If we have a good reason, then yeah, let's maintain a utility crate. If we don't, then maybe we should consider exposing ways to build a formatter? |
Closing now that there is a libs-team ACP for this: rust-lang/libs-team#280. |
Issue
There is currently no (obvious) way to create a
Formatter
.Example scenario
In my case, this is a problem because I'd like to display an element that requires informations from external data; I'd thus like to do something like this:
However, there is currently no way to create a
Formatter
, so I had to use a little hack instead:I also noticed there is an existing issue about it, which requests the following thing:
Meta
The text was updated successfully, but these errors were encountered: