Open
Description
Problem:
struct PG
{
engine: &mut Engine, -- lifetime error here
names: Vec<String>
}
Q_OBJECT! { PG:
slot fn parse(String);
}
To fix the code, I use a lifetime parameter for PG
:
struct PG<'a>
{
engine: &'a mut Engine, // works :)
names: Vec<String>
}
Q_OBJECT! { PG<'a>: // but now this is broken :(
slot fn parse(String);
}
This is what the compiler says:
src/main.rs:52:16: 52:18 error: use of undeclared lifetime name `'a` [E0261]
src/main.rs:52 Q_OBJECT! { PG<'a>:
^~
And if I don't use the lifetime parameter in the macro:
src/main.rs:52:13: 52:15 error: wrong number of lifetime parameters: expected 1, found 0 [E0107]
src/main.rs:52 Q_OBJECT! { PG:
^~
Apparently, the macro understands the type just fine, but can't find the definition of 'a
. It should be as in impl
, where the parameter is defined before used:
impl<'a> PG<'a>
I'm trying to find how to fix this, or how to improve Q_OBJECT, but no success so far.