-
Notifications
You must be signed in to change notification settings - Fork 606
pretty print improvements #1851
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
base: main
Are you sure you want to change the base?
Conversation
this also improves performance and simplifies pretty-printing
see apache#1850 all the tests are skipped at the moment, we will enable them as we implement more pretty printing
- Refactor DisplayCommaSeparated to accept any iterable type. - Update indented_list to work with iterators. - Improve formatting in the Insert display implementation
src/display_utils.rs
Outdated
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||
let mut first = true; | ||
for t in self.0 { | ||
for t in self.0.clone() { |
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.
was the clone needed here, we seem to only call fmt
on t
?
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.
Yes, we are never actually cloning anything expensive here, but we need to add the Clone
generic bound in order to be able to use the IntoIterator
trait.
This .clone()
concretely always clones
- either just a reference (to a slice)
- or an iterator object (but not the underlying structure being iterated on)
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.
@iffyio , I can roll it back to the non-generic version, and just implement comma separation manually in the Values Display impl, if you want.
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.
Yeah I think it might be better to make it explicit, with the new impl seems like it wouldn't be obvious if we were to go on to later clone something expensive accidentally
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.
@iffyio : I reverted the generic indented_list
implementation and reworked the Values Display implementation not to use it.
da1499a
to
064132c
Compare
064132c
to
75ec6b9
Compare
this is a first PR for #1850
mainly implementing pretty printing for insert update and delete statements