carllerche / tower-web

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

Does this crate support `Response`s with type parameters? #134

Closed phrohdoh closed 5 years ago

phrohdoh commented 5 years ago

I'd like to be able to use the following generic structs:

#[derive(Response)]
pub struct SingleResponse<T> where T: Serialize {
    pub item: T
}

#[derive(Response)]
pub struct MultiResponse<T> where T: Serialize {
    pub items: Vec<T>
}

But I get the following compilation error:

 --> src/services/api/mod.rs:8:10
  |
8 | #[derive(Response)]
  |          ^^^^^^^^ expected 1 type argument

Is what I want to do possible, and if so how?

carllerche commented 5 years ago

It should! I will investigate.

carllerche commented 5 years ago

144 should fix this.

You shouldn't need the bound on the struct.