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.rsexists, parse it with RA-AP-syntax - Gather all
usestatements - 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.rswith the new grouping.