You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
OK, so we have our fancy new formatting with its traits and all, but at present it's not obvious as (most commonly) a library developer how to implement its goodness for your own types.
We should have a new section in the std::fmt documentation on "how to implement these traits". I think the general advice should be to use write!. It could have an example like this:
use std::fmt;structVector2D{x:int,y:int,}impl fmt::DefaultforVector2D{fnfmt(obj:&Vector2D,f:&mut fmt::Formatter){write!(f.buf,"({}, {})", obj.x, obj.y)}}
(I still hate the way it's a static method with an explicit first argument rather than a regular method with &self. But ah! there is no syntax to express the other at present.)
This is a very basic example; more will be needed for the adventurous, covering flags, padding and so forth, how f.buf is a Writer which means you're dealing a lot with bytes rather than strings, etc.
This is related to #9806 in that it will make the way toward removing ToStr plainer.
The text was updated successfully, but these errors were encountered:
Add allow-mixed-uninlined-format-args config
Implement `allow-mixed-uninlined-format-args` config param to change the behavior of the `uninlined_format_args` lint. Now it is a part of `style` per [Zulip chat](https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/.60uninlined_format_args.60.20category), and won't propose inlining in case of a mixed usage, e.g. `print!("{} {}", var, 1+2)`. If the user sets `allow-mixed-uninlined-format-args` config param to `false`, the lint would behave like it did before -- proposing to inline args even in the mixed case.
---
changelog: [`uninlined_format_args`]: Added a new config `allow-mixed-uninlined-format-args` to allow the lint, if only some arguments can be inlined
[rust-lang#9865](rust-lang/rust-clippy#9865)
changelog: Moved [`uninlined_format_args`] to `style` (Now warn-by-default)
[rust-lang#9865](rust-lang/rust-clippy#9865)
OK, so we have our fancy new formatting with its traits and all, but at present it's not obvious as (most commonly) a library developer how to implement its goodness for your own types.
We should have a new section in the
std::fmt
documentation on "how to implement these traits". I think the general advice should be to usewrite!
. It could have an example like this:(I still hate the way it's a static method with an explicit first argument rather than a regular method with
&self
. But ah! there is no syntax to express the other at present.)This is a very basic example; more will be needed for the adventurous, covering flags, padding and so forth, how
f.buf
is aWriter
which means you're dealing a lot with bytes rather than strings, etc.This is related to #9806 in that it will make the way toward removing
ToStr
plainer.The text was updated successfully, but these errors were encountered: