3 The tracking issue for this feature is: [#44494]
5 [#44494]: https://github.com/rust-lang/rust/issues/44494
7 ------------------------
9 The `use_nested_groups` feature allows you to import multiple items from a
10 complex module tree easily, by nesting different imports in the same
11 declaration. For example:
14 #![feature(use_nested_groups)]
15 # #![allow(unused_imports, dead_code)]
36 ## Snippet for the book's new features appendix
38 When stabilizing, add this to
39 `src/doc/book/second-edition/src/appendix-07-newest-features.md`:
41 ### Nested groups in `use` declarations
43 If you have a complex module tree with many different submodules and you need
44 to import a few items from each one, it might be useful to group all the
45 imports in the same declaration to keep your code clean and avoid repeating the
48 The `use` declaration supports nesting to help you in those cases, both with
49 simple imports and glob ones. For example this snippets imports `bar`, `Foo`,
50 all the items in `baz` and `Bar`:
53 # #![feature(use_nested_groups)]
54 # #![allow(unused_imports, dead_code)]
77 When stabilizing, replace the shortcut list in
78 `src/doc/reference/src/items/use-declarations.md` with this updated one:
80 * Simultaneously binding a list of paths with a common prefix, using the
81 glob-like brace syntax `use a::b::{c, d, e::f, g::h::i};`
82 * Simultaneously binding a list of paths with a common prefix and their common
83 parent module, using the `self` keyword, such as `use a::b::{self, c, d::e};`
84 * Rebinding the target name as a new local name, using the syntax `use p::q::r
85 as x;`. This can also be used with the last two features:
86 `use a::b::{self as ab, c as abc}`.
87 * Binding all paths matching a given prefix, using the asterisk wildcard syntax
89 * Nesting groups of the previous features multiple times, such as
90 `use a::b::{self as ab, c d::{*, e::f}};`