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
Fix Point display to respect formatting parameters #1116
base: dev
Are you sure you want to change the base?
Conversation
This changes Point formatting to match formatting of other geometry types, including Isometry, Scale, and Rotation. Fixes issue dimforge#1115 since it passes through the desired precision formatting parameter.
I think it would be better to just forward to the underlying |
That does seem simpler, thanks. I've made that change. Which other flags were you expecting it to handle when forwarding? From what I can see it looks like the underlying matrix formatting ignores most parameters aside from precision. I'm wondering if it would be worth forwarding |
Ah, if |
write!(f, ", {}", *comp)?; | ||
} | ||
|
||
write!(f, "Point {{")?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather omit this wrapping for concision, personally. It's also unconventional for Display
impls in general.
The Isometry, Scale, Rotation, and Translation types all have similar Display impls that only pass through precision and have similar wrapping with “Typename {“ and “}”. I would prefer omitting the wrapper myself too but would probably want it to be consistent. |
Ah, good call. |
(reporter of the referenced issue here) Hm, I actually liked the concise single-line form of Point, while the new form makes it a bit more verbose. I guess it does make it more consistent with other formats though... |
Ah, have you tried debug printing? It's concise and actually does follow all format specifiers: let point = nalgebra::Point3::new(1.12345678, 2.12345678, 3.12345678);
println!("{point:.4?}"); Gives |
Huh, I haven't! It's actually a bit surprising that Debug formatting in this case looks more like what I'd expect from Display (being more human-readable and all) while Display formatting in this PR is more like what I'd expect from Debug (showing type names and all). |
Conversely, fancy many-line 2D layout with unicode block drawing is worlds apart from what you'd expect in |
Sounds like we're in agreement. For matrix types I'd expect neat block drawing in Display, but type names and such in Debug. In case of |
I've tried to reduce these inconsistencies in #1119. Would appreciate feedback! |
This changes Point Display formatting to match formatting of other geometry types, including Isometry, Scale, and Rotation.
Fixes issue #1115 since it passes through the desired precision formatting parameter.
Example:
Before:
After: