Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does class! support generic types? #210

Open
AndyT-MS opened this issue Mar 23, 2021 · 1 comment
Open

Does class! support generic types? #210

AndyT-MS opened this issue Mar 23, 2021 · 1 comment

Comments

@AndyT-MS
Copy link

I'd like to create a generic type which implements a COM interface, but if class! supports that then I can't seem to figure out the syntax. Seems like this would be the way to do it, but it gives me a syntax error at the < saying that a : is expected.

com::class! {
    class MyHandler<F: Fn()> : IMyHandler
    {
        func: F,
    }
    // ... impl that calls func ...
}

I tried putting the <F: Fn()> in various other places as well, which all seemed less likely to be correct, and unsurprisingly none of them worked either. I'm figuring that class! probably just doesn't currently support this, but I'm hoping to confirm that I'm not just missing something.

@russcam
Copy link
Contributor

russcam commented Jul 16, 2021

class! macro does not support generic types or lifetime parameters. The fn that parses the stream expects only an Ident token

let name = input.parse::<Ident>()?;

but would also need to handle tokens for generic types and lifetime parameters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants