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

make with generics #16

Closed
demosdemon opened this issue Dec 22, 2023 · 1 comment
Closed

make with generics #16

demosdemon opened this issue Dec 22, 2023 · 1 comment

Comments

@demosdemon
Copy link

Suppose you wanted to write a tower-esque trait using RPITIT:

pub trait LocalService<Request> {
    type Response;
    type Error;

    async fn execute(self, request: Request) -> Result<Self::Response, Self::Error>;
}

This now works, but if I want to use make to add a Send variant, the macro fails:

error: expected `:`
 --> src/example.rs:1:30
  |
1 | #[trait_variant::make(Service<Request>: Send)]
  |                              ^

Omitting the generic parameters yields a different error:

error[E0412]: cannot find type `Request` in this scope
 --> src/example.rs:6:37
  |
6 |     async fn execute(self, request: Request) -> Result<Self::Response, Self::Error>;
  |                                     ^^^^^^^ not found in this scope
  |
help: consider importing one of these items
  |
1 + use core::error::Request;
  |
1 + use std::error::Request;
  |

error[E0107]: missing generics for trait `LocalService`
 --> src/example.rs:2:11
  |
2 | pub trait LocalService<Request> {
  |           ^^^^^^^^^^^^ expected 1 generic argument
  |
note: trait defined here, with 1 generic parameter: `Request`
 --> src/example.rs:2:11
  |
2 | pub trait LocalService<Request> {
  |           ^^^^^^^^^^^^ -------
help: add missing generic argument
  |
2 | pub trait LocalService<Request><Request> {
  |                       +++++++++

error[E0107]: missing generics for trait `Service`
 --> src/example.rs:1:23
  |
1 | #[trait_variant::make(Service: Send)]
  |                       ^^^^^^^ expected 1 generic argument
  |
note: trait defined here, with 1 generic parameter: `Request`
 --> src/example.rs:1:23
  |
1 | #[trait_variant::make(Service: Send)]
  |                       ^^^^^^^
2 | pub trait LocalService<Request> {
  |                        -------
help: add missing generic argument
  |
1 | #[trait_variant::make(Service<Request>: Send)]
  |                              +++++++++
@mx00s
Copy link

mx00s commented May 20, 2024

Should this be closed?

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