#lifetime issues

11 messages · Page 1 of 1 (latest)

indigo tusk
#

code:

#[derive(Clone, Debug, Steel, PartialEq)]
struct ElementContainer {
    element: ElementRef,
}

doing this won't work, because ElementRef needs a lifetime parameter, gives me this error:

error[E0106]: missing lifetime specifier
  --> src/parsing.rs:17:14
   |
17 |     element: ElementRef,
   |              ^^^^^^^^^^ expected named lifetime parameter
   |
help: consider introducing a named lifetime parameter
   |
16 ~ struct ElementContainer<'a> {
17 ~     element: ElementRef<'a>,

making the suggested changes, i get this instead

error[E0726]: implicit elided lifetime not allowed here
  --> src/parsing.rs:16:8
   |
16 | struct ElementContainer<'a> {
   |        ^^^^^^^^^^^^^^^^ expected lifetime parameter
   |
help: indicate the anonymous lifetime
   |
16 | struct ElementContainer<'_><'a> {
   |                        ++++

what should I do?

lone onyx
#

What code generated that second error?

#

It should just be

struct ElementContainer<'a> {
    element: ElementRef<'a>,
}
#

wait what is Steel

indigo tusk
indigo tusk
indigo tusk
lone onyx
#

I'm guessing the derive macro is removing the lifetime. Does it work if you remove Steel?

indigo tusk
#

i will probably have to ask in the steel discord then

lone onyx
#

Yeah, it probably means Steel doesn't work with lifetimes.