-
Notifications
You must be signed in to change notification settings - Fork 0
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
Fixed --files argument to sort alphabetically #1
base: master
Are you sure you want to change the base?
Conversation
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.
Did you run cargo fmt
?
src/cli_utils.rs
Outdated
@@ -337,14 +337,16 @@ impl<W: Write> Printer<W> { | |||
|
|||
if self.list_files { | |||
self.print_subrow()?; | |||
|
|||
let mut reports: Vec<_> = language.reports.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.
Why clone this?
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.
Because "language" is borrowed and sort_by
function requires mutable access.
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.
You could create a new Vec<&R>
from language.reports
which stores the data type R
and sort that one. You can use .map
and .collect
.
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 don't know if this is how I should do it, if I try like this to get a Vec , it says that the Copy Trait is not implemented.
And I can't use a Vec<&Report> because I would have to change the code below to accept &Report
let (a, b): (Vec<_>, Vec<_>) = reports .iter() .partition(|r| r.stats.blobs.is_empty());
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.
Please use
post code here
to post code instead of pictures.
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.
You want to get a Vec<&Report>
, instead you are trying to take ownership here.
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.
Pushed a commit now with the requested change. I will run fmt
on it after feedback,
Looks good, please send it to upstream and place a link to it here. |
Now if
--files
argument is found it will sort by default alphabetically the name of the files. If--sort
argument is also provided (for exampletokei --files --sort blanks
), the sorting for files will be ignored and it will only sort by given argument.Before:
After:
Should fix XAMPPRocky#1053