Trait SortAndFormatImports

Source
pub trait SortAndFormatImports {
    type Error;

    // Required method
    fn sort_and_format_imports<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
}
Expand description

Our trait for sorting and formatting imports in a crate or workspace. The goal:

  • If src/imports.rs exists, parse it with RA-AP-syntax
  • Gather all use statements
  • Group them by prefix, so e.g. pub(crate) use std::collections::HashMap; pub(crate) use std::collections::HashSet; becomes pub(crate) use std::collections::{HashMap, HashSet};
  • Sort them in alphabetical order
  • Preserve comments Then rewrite imports.rs with the new grouping.

Required Associated Types§

Required Methods§

Source

fn sort_and_format_imports<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Sorts & formats the imports for either a single crate or an entire workspace.

Implementors§

Source§

impl SortAndFormatImports for CrateHandle

Source§

impl<P, H> SortAndFormatImports for Workspace<P, H>
where P: for<'async_trait> From<PathBuf> + for<'async_trait> AsRef<Path> + for<'async_trait> Clone + for<'async_trait> Send + for<'async_trait> Sync + 'async_trait, H: CrateHandleInterface<P> + SortAndFormatImports<Error = CrateError> + Send + Sync,