thunder icon indicating copy to clipboard operation
thunder copied to clipboard

Lifetime parameters on functions cause `thunderclap` attribute to panic

Open Pzixel opened this issue 6 years ago • 2 comments

For example, it's not clear how to run app with more than one parameter:

/// App
#[thunderclap]
impl App {
    /// run
    fn run<'a, 'b>(token: &'a str, listening_address: &'b str) {
        println!("Hello {}, my address is {}", token, listening_address);
    }
}
error[E0599]: no function or associated item named `run` found for type `clap::App<'_, '_>` in the current scope
  --> src\main.rs:28:1
   |
28 | #[thunderclap]
   | ^^^^^^^^^^^^^^ function or associated item not found in `clap::App<'_, '_>`

error: aborting due to previous error

Pzixel avatar Jun 22 '18 08:06 Pzixel

Hey, you don't need to specify the lifetime parameters on that function. If you look at the thor example you'll see that the hello function takes a name: &str but because it is never returned from that function the lifetime is very clear.

I'll rename this issue because this is a bug in how thunder parses user code and I think it can't handle lifetime parameters on functions and there should be at least some sort of error message that is more helpful to the user.

spacekookie avatar Jun 22 '18 19:06 spacekookie

@spacekookie i thought you cannot not specify lifetime parameters because they lifetimes cannot be elised. Sorry, the error message misled me.

Pzixel avatar Jun 22 '18 19:06 Pzixel