carllerche / tower-web

A fast, boilerplate free, web framework for Rust
MIT License
981 stars 51 forks source link

Can't derive debug over a generic Response #190

Open 0xpr03 opened 5 years ago

0xpr03 commented 5 years ago

The Response derive isn't handing down debug derives.

For example the following won't work:

#[derive(Debug, Response)]
pub struct ApiResponse<T>
where
    T: Serialize + Debug,
{
    pub value: Option<T>,
    pub msg: Option<String>,
}

Will throw

error[E0277]: `T` doesn't implement `std::fmt::Debug`
   --> src/models.rs:122:17
    |
122 | #[derive(Debug, Response)]
    |                 ^^^^^^^^ `T` cannot be formatted using `{:?}` because it doesn't implement `std::fmt::Debug`

I was told that serde is handling this via attributes which tower-web probably also would have to implement.

0xpr03 commented 5 years ago

Note: the above example won't compile, even without Debug-Derive as tower-web seems to require debug internally, which T doesn't receive.

carllerche commented 5 years ago

Thanks for the report 👍