Open
Description
Hey there ! I wrote a lib I want to test with cucumber. My lib use some struct that has some lifetimes, like this :
pub struct Intersection<'a> {
time: f64,
object: &'a Shape,
}
And I need to store these kinds of values in cucumber world. So, obvious solution was to create a world object with lifetime, like this :
#[derive(Debug)]
pub enum WorldItem<'a> {
Tuple(Tuple),
Double(f64),
Color(Color),
Canvas(Canvas),
PPM(String),
Matrix(Matrix),
Ray(Ray),
Shape(Shape),
Intersect(Intersection<'a>),
Interset(Intersections<'a>),
Hit(Option<Intersection<'a>>),
Light(PointLight),
Material(Material),
}
#[derive(Debug, World)]
#[world(init = Self::new)]
pub struct CucumberWorld<'a> {
all_entries: HashMap<String, WorldItem<'a>>,
}
But it doesn't work, and the message is weird :
error[E0106]: missing lifetime specifier
--> tests/world/mod.rs:26:12
|
26 | pub struct CucumberWorld<'a> {
| ^^^^^^^^^^^^^ expected named lifetime parameter
|
help: consider introducing a named lifetime parameter
|
26 | pub struct CucumberWorld<'a><'a><'a> {
| ++++
I also have a bunch of errors like this :
error: `impl` item signature doesn't match `trait` item signature
--> tests/world/mod.rs:24:17
|
24 | #[derive(Debug, World)]
| ^^^^^ found `fn(&'1 CucumberThenCucumberWorld) -> (cucumber::step::Location, fn() -> Regex, for<'a> fn(&'a mut world::CucumberWorld<'1>, cucumber::step::Context) -> Pin<Box<(dyn futures::Future<Output = ()> + 'a)>>)`
|
::: /Users/averell/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cucumber-0.20.2/src/codegen.rs:58:5
|
58 | fn inner(&self) -> (step::Location, LazyRegex, Step<W>);
| -------------------------------------------------------- expected `fn(&'1 CucumberThenCucumberWorld) -> (cucumber::step::Location, fn() -> Regex, for<'a> fn(&'a mut world::CucumberWorld<'a>, cucumber::step::Context) -> Pin<Box<(dyn futures::Future<Output = ()> + 'a)>>)`
|
= note: expected signature `fn(&'1 CucumberThenCucumberWorld) -> (cucumber::step::Location, fn() -> Regex, for<'a> fn(&'a mut world::CucumberWorld<'a>, cucumber::step::Context) -> Pin<Box<(dyn futures::Future<Output = ()> + 'a)>>)`
found signature `fn(&'1 CucumberThenCucumberWorld) -> (cucumber::step::Location, fn() -> Regex, for<'a> fn(&'a mut world::CucumberWorld<'1>, cucumber::step::Context) -> Pin<Box<(dyn futures::Future<Output = ()> + 'a)>>)`
= help: the lifetime requirements from the `impl` do not correspond to the requirements in the `trait`
= help: verify the lifetime relationships in the `trait` and `impl` between the `self` argument, the other inputs and its output
= note: this error originates in the derive macro `World` (in Nightly builds, run with -Z macro-backtrace for more info)
How can I create a world with lifetime ? Is there a way ? If not, any workaround ?