From 5bc9dc01618421596d65a7046e46559a872c6693 Mon Sep 17 00:00:00 2001 From: Owen Jacobson Date: Mon, 25 Aug 2025 22:38:19 -0400 Subject: Group Rust imports by crate. I've been doing this by hand anyways, and this makes it a _ton_ less tedious to maintain. I think it looks nice. This does, however, require nightly - for formatting only. --- rustfmt.toml | 5 +++++ src/boot/mod.rs | 2 +- src/conversation/handlers/send/mod.rs | 2 +- src/empty.rs | 6 ++++-- src/id.rs | 3 +-- src/setup/required.rs | 6 ++++-- tools/check-format | 2 +- tools/reformat | 2 +- 8 files changed, 18 insertions(+), 10 deletions(-) create mode 100644 rustfmt.toml diff --git a/rustfmt.toml b/rustfmt.toml new file mode 100644 index 0000000..26527d9 --- /dev/null +++ b/rustfmt.toml @@ -0,0 +1,5 @@ +# UNSTABLE - this setting can eat comments in `use` blocks. See +# for details. +# +# Yes, this is why the `check-format` and `reformat` tools use `+nightly`. +imports_granularity = "crate" diff --git a/src/boot/mod.rs b/src/boot/mod.rs index e0d35d9..90a957d 100644 --- a/src/boot/mod.rs +++ b/src/boot/mod.rs @@ -1,4 +1,4 @@ -use crate::{event::Event, event::Sequence}; +use crate::event::{Event, Sequence}; pub mod app; pub mod handlers; diff --git a/src/conversation/handlers/send/mod.rs b/src/conversation/handlers/send/mod.rs index 9ec020a..1c8ac63 100644 --- a/src/conversation/handlers/send/mod.rs +++ b/src/conversation/handlers/send/mod.rs @@ -4,10 +4,10 @@ use axum::{ response::{self, IntoResponse}, }; -use crate::conversation::handlers::PathInfo; use crate::{ app::App, clock::RequestedAt, + conversation::handlers::PathInfo, error::{Internal, NotFound}, message::{Body, Message, app::SendError}, token::extract::Identity, diff --git a/src/empty.rs b/src/empty.rs index 2c66051..3126c42 100644 --- a/src/empty.rs +++ b/src/empty.rs @@ -1,5 +1,7 @@ -use axum::http::StatusCode; -use axum::response::{IntoResponse, Response}; +use axum::{ + http::StatusCode, + response::{IntoResponse, Response}, +}; #[derive(Debug)] pub struct Empty; diff --git a/src/id.rs b/src/id.rs index 86cdf8a..d668cc9 100644 --- a/src/id.rs +++ b/src/id.rs @@ -2,8 +2,7 @@ use std::fmt; use rand::{seq::SliceRandom, thread_rng}; use serde::{Deserializer, Serializer}; -use sqlx::encode::IsNull; -use sqlx::{Database, Decode, Encode, Type}; +use sqlx::{Database, Decode, Encode, Type, encode::IsNull}; // Make IDs that: // diff --git a/src/setup/required.rs b/src/setup/required.rs index 2112e4b..7276827 100644 --- a/src/setup/required.rs +++ b/src/setup/required.rs @@ -3,8 +3,10 @@ use axum::{ http::StatusCode, response::{IntoResponse, Response}, }; -use std::pin::Pin; -use std::task::{Context, Poll}; +use std::{ + pin::Pin, + task::{Context, Poll}, +}; use tower::{Layer, Service}; use crate::{app::App, error::Internal}; diff --git a/tools/check-format b/tools/check-format index 3b68537..bd57435 100755 --- a/tools/check-format +++ b/tools/check-format @@ -8,4 +8,4 @@ cd "$(dirname "$0")/.." npx prettier --check . -cargo fmt --all --check +cargo +nightly fmt --all --check diff --git a/tools/reformat b/tools/reformat index 4dfe7c3..00d61ef 100755 --- a/tools/reformat +++ b/tools/reformat @@ -7,4 +7,4 @@ cd "$(dirname "$0")/.." npx prettier --write . -cargo fmt --all +cargo +nightly fmt --all -- cgit v1.2.3