summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOwen Jacobson <owen@grimoire.ca>2025-08-25 22:38:19 -0400
committerOwen Jacobson <owen@grimoire.ca>2025-08-25 22:38:19 -0400
commit5bc9dc01618421596d65a7046e46559a872c6693 (patch)
tree716d3895b77678adcd9ccab3a4d04ec5eee6eb90
parent25914826e0f256789d943cd25375b2444130ce01 (diff)
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.
-rw-r--r--rustfmt.toml5
-rw-r--r--src/boot/mod.rs2
-rw-r--r--src/conversation/handlers/send/mod.rs2
-rw-r--r--src/empty.rs6
-rw-r--r--src/id.rs3
-rw-r--r--src/setup/required.rs6
-rwxr-xr-xtools/check-format2
-rwxr-xr-xtools/reformat2
8 files changed, 18 insertions, 10 deletions
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
+# <https://github.com/rust-lang/rustfmt/issues/4991> 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