Don't derive debug impl for Resource (#1153)

We don't actually require `B` to be `Debug` but the derived impl does.
This commit is contained in:
David Pedersen 2022-07-11 09:41:41 +02:00 committed by GitHub
parent bed0b83421
commit 8c9998eab7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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<axum::body::Body> = app;
/// ```
#[derive(Debug)]
pub struct Resource<B = Body> {
pub(crate) name: String,
pub(crate) router: Router<B>,
@ -187,6 +186,15 @@ impl<B> From<Resource<B>> for Router<B> {
}
}
impl<B> fmt::Debug for Resource<B> {
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)]