pub(crate) fn auto_import(ctx: AssistCtx) -> Option<Assist> {
    let auto_import_assets = AutoImportAssets::new(&ctx)?;
    let proposed_imports = auto_import_assets.search_for_imports(ctx.db);
    if proposed_imports.is_empty() {
        return None;
    }

    let assist_group_name = if proposed_imports.len() == 1 {
        format!("Import `{}`", proposed_imports.iter().next().unwrap())
    } else {
        auto_import_assets.get_import_group_message()
    };
    let mut group = ctx.add_assist_group(assist_group_name);
    for import in proposed_imports {
        group.add_assist(AssistId("auto_import"), format!("Import `{}`", &import), |edit| {
            edit.target(auto_import_assets.syntax_under_caret.text_range());
            insert_use_statement(
                &auto_import_assets.syntax_under_caret,
                &import,
                edit.text_edit_builder(),
            );
        });
    }
    group.finish()
}
// Assist: auto_import
//
// If the name is unresolved, provides all possible imports for it.
//
// ```
// fn main() {
//     let map = HashMap<|>::new();
// }
// # pub mod std { pub mod collections { pub struct HashMap { } } }
// ```
// ->
// ```
// use std::collections::HashMap;
//
// fn main() {
//     let map = HashMap::new();
// }
// # pub mod std { pub mod collections { pub struct HashMap { } } }
// ```
auto_import
If the name is unresolved, provides all possible imports for it.


auto_import If the name is unresolved provides all possible imports for it .
pub(crate) fn auto_import(ctx: AssistCtx) -> Option<Assist> {
    let auto_import_assets = AutoImportAssets::new(&ctx)?;
    let proposed_imports = auto_import_assets.search_for_imports(ctx.db);
    if proposed_imports.is_empty() {
        return None;
    }
    let assist_group_name = if proposed_imports.len() == 1 {
        format!("Import `{}`", proposed_imports.iter().next().unwrap())
    } else {
        auto_import_assets.get_import_group_message()
    };
    let mut group = ctx.add_assist_group(assist_group_name);
    for import in proposed_imports {
        group.add_assist(AssistId("auto_import"), format!("Import `{}`", &import), |edit| {
            edit.target(auto_import_assets.syntax_under_caret.text_range());
            insert_use_statement(
                &auto_import_assets.syntax_under_caret,
                &import,
                edit.text_edit_builder(),
            );
        });
    }
    group.finish()
}
pub ( crate ) fn auto_import ( ctx : AssistCtx ) -> Option < Assist > { let auto_import_assets = AutoImportAssets :: new ( & ctx ) ? ; let proposed_imports = auto_import_assets . search_for_imports ( ctx . db ) ; if proposed_imports . is_empty ( ) { return None ; } let assist_group_name = if proposed_imports . len ( ) == 1 { format ! ( " " proposed_imports iter ( ) next ( ) unwrap ( ) ) } else { auto_import_assets . get_import_group_message ( ) } ; let mut group = ctx . add_assist_group ( assist_group_name ) ; for import in proposed_imports { group . add_assist ( AssistId ( " " ) , format ! ( " " import ) , | edit | { edit . target ( auto_import_assets . syntax_under_caret . text_range ( ) ) ; insert_use_statement ( & auto_import_assets . syntax_under_caret , & import , edit . text_edit_builder ( ) , ) ; } ) ; } group . finish ( ) }
Assist: auto_import
If the name is unresolved, provides all possible imports for it.
Assist : auto_import If the name is unresolved provides all possible imports for it .
ctx
AssistCtx
pub mod std { pub mod collections { pub struct hashmap { } } }
```
>
```
use std::collections::HashMap.

fn main() {
let map = HashMap::new();
}
` ` ` > ` ` ` use std :: collections :: HashMap . fn main () { let map = HashMap :: new () ; }
pub mod std { pub mod collections { pub struct hashmap { } } }
None