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 #215 #735
Fixed #215 #735
Conversation
Thanks for the PR! Do I understand correctly that there are now two enums for the write mode? We'd have just one, ideally. Also, it's no longer possible to set the write mode to |
Firstly, no problem since this is something I want for my projects as well. To answer some of your questions:
|
I'd say we drop the In that case we should be able to re-use |
If we are going to drop variants, we should take the opportunity and check that they are all needed so that we only need to make this change once. |
The other ones all have their use, I think. |
I was looking at how to go about removing the second enum and found that WriteMode implements |
Yea, because it shouldn't ever be used by users of the binary. |
How can this function be maintained across the |
It cannot. I guess we'll have to remove the |
Ok, no problem. Right now what I did with default is to make a variant so that if both the config and the argument are default it will use Replace but if there is a argument it will prefer that, however in filemap.rs there is a match against WriteMode, how should I implement the case where Default is the mode? Which should never happen in the execution of the program, a |
You can use |
Got it, that is what I ended up writing since it also ends up as a panic. Should I put those changes as a new commit or rebase the current one? |
A rebase would be cleanest, I think. |
Should I keep WriteMode in lib.rs or move it to config since at this point using |
Both make sense to me. Either way is fine! |
Opps... Forgot to change tests... Many of them use Return |
@@ -113,6 +113,24 @@ configuration_option_enum! { ReportTactic: | |||
Never, | |||
} | |||
|
|||
configuration_option_enum! { WriteMode: | |||
// Used internally to represent when no option is given |
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.
Nit: could you use 4 space indents 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.
I guess rustfmt doesn't change the indents...
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.
Not inside these macro thingies (yet).
Ok so many of the tests use the Return option, not quite sure how to handle this, any ideas? |
Yea, that's the rough bit. The basic idea I had was to have a public function that returns a The binary could use that function to either write the results to stdout or file, depending on This is actually a change I've been wanting to do for a while, so I wouldn't mind finishing up your PR (by making a PR for your branch). If you're willing to give it a try, that'd be even cooler. Let me know. |
I would be fine with the branch idea, at the end all I want is for the feature to be there. However I did think of doing a check on the run function so that it panics if anyone uses return there, not sure if that is a good way around it though, however the tests never run correctly on my machine(Windows 8), even when they pass in Travis. |
That function also sounds like a nice abstraction on the |
Ah, that may be #617. I'm not sure how to fix that as I'm not on a Windows machine myself.. I'll try to make a PR to your branch tonight. Thanks for your changes! |
No problem! Thank you very much for your comments |
I'll just create a PR to your master branch ;-) |
Just a note, I just realized that |
Agreed! |
Created a pull request for your branch here: https://github.com/svmnotn/rustfmt/pull/1. |
Hmmm, one unintended consequence seems to be that write modes are now case sensitive. That's probably not what we want. |
yeah... I ran into that while testing but I think so are line endings and everything using the derived fromStr (I think, I need to test that) |
Just tested, line endings are also case sensitive |
The line endings option, you mean? |
yes, sorry I was looking at the code, I'll branch off and see if maybe I can PR that in. Hopefully it will be less problematic ;) |
#739 fixes the issue pointed out by @marcusklaas |
@marcusklaas is this landable now? @svmnotn needs a rebase |
The code is a hack.
That is the best way of putting it, but it works.
I did think of maybe re-writing how WriteMode works as it seems, to me at lest, that not all the features are implemented/documented. That or I might have understood all of it, I'm pretty new at Rust.