From 8c9998eab7b11b3531e9bf35714ea66d09b17d86 Mon Sep 17 00:00:00 2001 From: David Pedersen Date: Mon, 11 Jul 2022 09:41:41 +0200 Subject: [PATCH] Don't derive debug impl for `Resource` (#1153) We don't actually require `B` to be `Debug` but the derived impl does. --- axum-extra/src/routing/resource.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/axum-extra/src/routing/resource.rs b/axum-extra/src/routing/resource.rs index 98105fac..48fcba01 100644 --- a/axum-extra/src/routing/resource.rs +++ b/axum-extra/src/routing/resource.rs @@ -6,7 +6,7 @@ use axum::{ routing::{delete, get, on, post, MethodFilter}, Router, }; -use std::convert::Infallible; +use std::{convert::Infallible, fmt}; use tower_service::Service; /// A resource which defines a set of conventional CRUD routes. @@ -47,7 +47,6 @@ use tower_service::Service; /// let app = Router::new().merge(users); /// # let _: Router = app; /// ``` -#[derive(Debug)] pub struct Resource { pub(crate) name: String, pub(crate) router: Router, @@ -187,6 +186,15 @@ impl From> for Router { } } +impl fmt::Debug for Resource { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("Resource") + .field("name", &self.name) + .field("router", &self.router) + .finish() + } +} + #[cfg(test)] mod tests { #[allow(unused_imports)]