doku icon indicating copy to clipboard operation
doku copied to clipboard

Generic types

Open Patryk27 opened this issue 4 years ago • 0 comments

Our current derive macro doesn't understand generic types, e.g.:

struct Response<T> {
    body: T,
    pagination: Pagination,
}

... forcing users to implement the Document trait by hand:

impl<T: Document> Document for Response<T> {
    /* ... */
}

Adding support for generic types will boil down to making #[derive(Doku)] understand generics and adding automatic : Document bound for all of the type parameters (with an opt-out switch):

struct Wrapper<'a, B: Foo, C, const D: usize>
where
    B: Bar
{
    /* ... */
}

// should generate, more or less:

impl<'a, B: Foo, C, const D: usize> Wrapper<'a, B, C, D>
where
    B: Bar + Document
    C: Document
{
    /* ... */
}

Patryk27 avatar Sep 18 '21 11:09 Patryk27