From a78643d864f70c42be430a4120b8db92f674af58 Mon Sep 17 00:00:00 2001 From: uku Date: Thu, 26 Dec 2024 16:42:12 +0100 Subject: [PATCH] feat: add rustfmt config --- flake.nix | 2 +- rustfmt.toml | 2 ++ src/cache.rs | 3 +-- src/discord.rs | 13 ++++++------- src/main.rs | 13 ++++++------- 5 files changed, 16 insertions(+), 17 deletions(-) create mode 100644 rustfmt.toml diff --git a/flake.nix b/flake.nix index acd1655..f71466a 100644 --- a/flake.nix +++ b/flake.nix @@ -36,7 +36,7 @@ devShells.default = pkgs.mkShell { packages = with pkgs; [ clippy - rustfmt + (rustfmt.override { asNightly = true; }) rust-analyzer redis diff --git a/rustfmt.toml b/rustfmt.toml new file mode 100644 index 0000000..44b6aab --- /dev/null +++ b/rustfmt.toml @@ -0,0 +1,2 @@ +group_imports = "StdExternalCrate" +imports_granularity = "Crate" diff --git a/src/cache.rs b/src/cache.rs index 8629998..1b31c11 100644 --- a/src/cache.rs +++ b/src/cache.rs @@ -3,8 +3,7 @@ use std::collections::HashMap; use anyhow::Result; use bb8::Pool; use bb8_redis::RedisConnectionManager; -use redis::FromRedisValue; -use redis::{AsyncCommands, Client, ConnectionLike}; +use redis::{AsyncCommands, Client, ConnectionLike, FromRedisValue}; use redis_macros::ToRedisArgs; use serde::{Deserialize, Serialize}; use uuid::Uuid; diff --git a/src/discord.rs b/src/discord.rs index 9b09090..dd8770e 100644 --- a/src/discord.rs +++ b/src/discord.rs @@ -1,15 +1,14 @@ use std::sync::Arc; -use axum::extract::State; -use axum::http::StatusCode; -use axum::response::Redirect; -use axum::{extract::Query, response::IntoResponse}; +use axum::{ + extract::{Query, State}, + http::StatusCode, + response::{IntoResponse, Redirect}, +}; use serde::{Deserialize, Serialize}; use serenity::all::{CreateInvite, Http}; -use crate::config::EnvCfg; -use crate::AppState; -use crate::{util::IntoAppError, RouteResponse}; +use crate::{config::EnvCfg, util::IntoAppError, AppState, RouteResponse}; const VERIF_URL: &str = "https://challenges.cloudflare.com/turnstile/v0/siteverify"; diff --git a/src/main.rs b/src/main.rs index 72d9145..ced5a59 100644 --- a/src/main.rs +++ b/src/main.rs @@ -10,16 +10,15 @@ mod util; use std::sync::{Arc, LazyLock}; -use axum::routing::get; -use axum::{middleware, Router}; -use reqwest::header::{HeaderMap, USER_AGENT}; -use reqwest::StatusCode; +use axum::{middleware, routing::get, Router}; +use reqwest::{ + header::{HeaderMap, USER_AGENT}, + StatusCode, +}; use tokio::signal::unix::{signal, SignalKind}; use tower_http::trace::TraceLayer; -use crate::cache::Storage; -use crate::config::EnvCfg; -use crate::util::AppError; +use crate::{cache::Storage, config::EnvCfg, util::AppError}; const VERSION: &str = env!("CARGO_PKG_VERSION");