Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upPropagate formatting parameters to each components for more types #421
Conversation
|
r? @kvark |
|
sad |
| @@ -63,13 +63,21 @@ impl<T: Eq, U> Eq for Box2D<T, U> {} | |||
|
|
|||
| impl<T: fmt::Debug, U> fmt::Debug for Box2D<T, U> { | |||
| fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | |||
| write!(f, "Box2D({:?}, {:?})", self.min, self.max) | |||
This comment has been minimized.
This comment has been minimized.
kvark
Apr 2, 2020
Member
this should be raised at a lower level, i.e. the "proper" way to go here is unnecessary verbose :/
I could imagine something like write!(f, "Box2D({:~?}, {:~?})", self.min, self.max) that would propagate the f parameters automatically. Could you raise that issue upstream?
This comment has been minimized.
This comment has been minimized.
nical
Apr 2, 2020
Author
Collaborator
I agree with you, I think that the feature worth it though.
Could you raise that issue upstream?
I don't have the steam to champion an RFC for this at the moment, I'm asking around to see if I could get away requesting a feature like that directly as a github issue.
In the process @nox pointed out that for simple Debug formats we can do:
f.debug_tuple("Box2D")
.field(&self.min)
.field(&self.max)
.finish()This is a bit nicer although it only works for Debug (no equivalent Display helpers), and won't work for Rect({size} at {origin}) as far as I can tell.
Would you prefer that I convert the debug impls that I can to this syntax or keep the more verbose but consistent way?
In any case I'd like to land this in some form of another without waiting for a potentital future version of the standard library.
This comment has been minimized.
This comment has been minimized.
kvark
Apr 2, 2020
Member
Converting the debug seems like an improvement to me, not a blocker to land this though.
Also, perhaps RFC isn't necessary the first step, but rather opening an issue saying that there is a problem here.
This comment has been minimized.
This comment has been minimized.
nical
Apr 2, 2020
Author
Collaborator
I converted the debug impls to use debug_tuple where applicable and filed rust-lang/rust#70710
|
@bors-servo r=kvark |
|
|
|
|
|
Honestly I would just not implement |
nical commentedApr 2, 2020
Following up on #419, ensure the Debug and Display implementations propagate formatting parameters for more of euclid's types.
This allows people to control, for example, the number of digits in the formatting syntax like
println!("{:.3?}", rect);.