I turned on [merge_imports] and ran cargo fmt over a codebase of mine, with mixed results. Since that option is not yet stable, I thought you might be interested in some feedback.
Here is one change it made that I found useful:
-use behavior::Behavior;
-use behavior::NullBehavior;
+use behavior::{Behavior, NullBehavior};
From two lines down to one. Looking good 馃憤
Here is a change I found unnecessary:
-use std::io::{Read, Write};
-use std::thread;
+use std::{
+ io::{Read, Write},
+ thread,
+};
This one went from 2 lines to 4, and became a bit of a maze to read.
The options for merge_imports are true and false. The import porridge is always either too hot or too cold. It would be nice if there were a "just right" option. I can think of a couple possibilities for the specific implementation:
Only merge imported names that do not refer to a module:
use std::io::{Read, Write};
use std::mem;
use std::thread;
Only merge at most a single level of names:
use std::io::{Read, Write};
use std::{mem, thread};
Whichever one is easier to implement or has fewest corner cases is probably the way to go.
In general, with the default options rustfmt has been very valuable to me and saved me a lot of time doing menial formatting. Thanks for working on it! 馃槃
Here is a change I found unnecessary:
-use std::io::{Read, Write}; -use std::thread; +use std::{ + io::{Read, Write}, + thread, +};
I actually liked this result. I think it should be possible to be prevented by a separating line between the two imports, so:
use std::io::{Read, Write};
use std::io::thread;
would remain unchanged due to the separating line. Maybe that always happens, anyway.
Most helpful comment
I actually liked this result. I think it should be possible to be prevented by a separating line between the two imports, so:
would remain unchanged due to the separating line. Maybe that always happens, anyway.