Nested imports with use

Minimum Rust version: 1.25

A new way to write use statements has been added to Rust: nested importgroups. If you’ve ever written a set of imports like this:

2. #![allow(unused_variables)]
3. fn main() {
4. use std::fs::File;
5. use std::io::Read;
6. use std::path::{Path, PathBuf};
7. }

You can now write this:

2. #![allow(unused_variables)]
3. fn main() {
4. mod foo {
5. // on one line
6. use std::{fs::File, io::Read, path::{Path, PathBuf}};
7. }

9. mod bar {
10. // with some more breathing room
11. use std::{
12. fs::File,
13. io::Read,
14. path::{
15. Path,
16. PathBuf
17. }
18. };
19. }
20. }

This can reduce some repetition, and make things a bit more clear.