These are chat archives for rust-lang/rust

7th
Apr 2017
Sebastian Blei
@iamsebastian
Apr 07 2017 06:12
What do we save, if we do not import all structs/traits of a lib, but just single ones? Do we save execution time? Compile time? Binary size?
Or is it obsolete and just for clean code?
Asking, because API code is growing much. Just, the import lines of models are becoming bigger & bigger.
Aleksey Kladov
@matklad
Apr 07 2017 08:32
@iamsebastian you save you reader's time. It may be difficult to find out where a particular Foo comes from if you have use lib::*; at the beginning of the file. It is usually not a problem if you are reading the file inside of an IDE/smart editor, but it is a problem if you are viewing the file on GitHub.
Other then that, star imports and usual imports are equivalent.

Just, the import lines of models are becoming bigger & bigger.

I think this just happens when the project grows larger. The proper solution imo is to fold imports by default in the editor.

Sebastian Blei
@iamsebastian
Apr 07 2017 08:34
For sure, @matklad. Readability was the main goal, to prevent confusion. But it's a closed, proprietary API and I'm the one-and-only fullstack guy. So I have to decide between readability & readability. :)
But the hint with the folds is clever. I should give it a try in vim.
Andrey Lesnikov
@ozkriff
Apr 07 2017 08:48
i consider giant import lists a code smell
Aleksey Kladov
@matklad
Apr 07 2017 08:54
@ozkriff import certainly are great for detecting certain architectural problems ("why the hell model.rs imports something from view.rs"), but I think that imports tend to grow without an obvious upper limit when the project grows (here's an unnice example from servo: https://github.com/servo/servo/blob/master/components/constellation/constellation.rs). Totally agree that "don't do many imports" is the best solution if feasible :)
Sebastian Blei
@iamsebastian
Apr 07 2017 08:55
Good example. :walking: