Closed
Description
So currently rustfmt
appears to only sort use
statements that are next to each other, but often in our projects we like to neatly organize the use
statements into blocks and sort them according to some scheme. Usually, something like this:
use std::sync::Arc;
use chrono::Utc;
use juniper::{FieldError, FieldResult};
use uuid::Uuid;
use broker::database::PooledConnection;
use super::schema::{Context, Payload};
use super::update::convert_publish_payload;
use crate::models::Event;
So the order here is:
- std (core, alloc would also fit here)
- external crates
- workspace crates (I assume this is not something
rustfmt
can identify, sadly) - this module.
It would be awesome to have both the sorting within the blocks like rustfmt
already currently does and sorting of the categories between the blocks. So, say, a soup like this:
use chrono::Utc;
use super::update::convert_publish_payload;
use juniper::{FieldError, FieldResult};
use uuid::Uuid;
use std::sync::Arc;
use broker::database::PooledConnection;
use super::schema::{Context, Payload};
use crate::models::Event;
Would reformat into the neat code block above. Of course, this could be optional / configurable.
I.e., not having to worry about use
ordering ever again... 😄