rust_struct_iterable icon indicating copy to clipboard operation
rust_struct_iterable copied to clipboard

struct_iterable doesn't work if struct contains lifetimes

Open arifd opened this issue 2 years ago • 1 comments

Hi! Perfect little crate! But unfortunately this won't work:

use struct_iterable::Iterable;

#[derive(Iterable)]
struct Foo<'a> {
    s: &'a str
}

fn main() {
    let s = "hello";
    let foo = Foo { s };
    for (k, _) in foo.iter() {
        println!("{k}");
    }
}
error[E0726]: implicit elided lifetime not allowed here
 --> src/lib.rs:4:8
  |
4 | struct Foo<'a> {
  |        ^^^ expected lifetime parameter
  |
help: indicate the anonymous lifetime
  |
4 | struct Foo<'_><'a> {
  |           ++++

For more information about this error, try `rustc --explain E0726`.
error: could not compile `arif` (lib) due to previous error

arifd avatar Aug 05 '23 15:08 arifd

Hi Arif! Thank you so much, I'll check the issue, sorry for the late.

decomoraes avatar Aug 28 '23 19:08 decomoraes