Function ide_db::imports::merge_imports::try_normalize_import
source · pub fn try_normalize_import(
use_item: &Use,
style: NormalizationStyle,
) -> Option<Use>
Expand description
Normalizes a use item by:
- Ordering all use trees
- Merging use trees with common prefixes
- Removing redundant braces based on the specified normalization style
(see
NormalizationStyle
doc)
Examples:
Using the “Default” normalization style
foo::{bar::Qux, bar::{self}}
->foo::bar::{self, Qux}
foo::bar::{self}
->foo::bar
{foo::bar}
->foo::bar
Using the “One” normalization style
foo::{bar::Qux, bar::{self}}
->{foo::bar::{self, Qux}}
foo::bar::{self}
->{foo::bar}
foo::bar
->{foo::bar}