You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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... 😄
The text was updated successfully, but these errors were encountered:
While this should be possible to implement, there is an existing challenge/class of bugs rustfmt has with maintaining inline comment association while reordering imports.
It may not be strictly necessary to address that comment-import association before implementing this, but would be good to do so if possible because those existing comment issues would definitely be exacerbated by rustfmt reordering entire import blocks.
So currently
rustfmt
appears to only sortuse
statements that are next to each other, but often in our projects we like to neatly organize theuse
statements into blocks and sort them according to some scheme. Usually, something like this:So the order here is:
rustfmt
can identify, sadly)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: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... 😄The text was updated successfully, but these errors were encountered: