error: lifetime may not live long enough
--> tests/compile_fail/node_map_escape_scope.rs:14:9
|
12 | let escaped_map = graph.scope(|ctx| {
| ---- return type of closure `impl Mapping<<gotgraph::graph::Context<'_, &gotgraph::vec_graph::VecGraph<i32, &str>> as gotgraph::graph::Graph>::NodeIx, i32>` contains a lifetime `'2`
| |
| has type `&'1 gotgraph::graph::Context<'_, &gotgraph::vec_graph::VecGraph<i32, &str>>`
13 | let node_map = ctx.init_node_map(|_, &data| data * 2);
14 | node_map // ERROR: node map cannot escape the scope
| ^^^^^^^^ returning this value requires that `'1` must outlive `'2`
|
= note: requirement occurs because of the type `NodeTag<'_, NodeIx>`, which makes the generic argument `'_` invariant
= note: the struct `NodeTag<'scope, I>` is invariant over the parameter `'scope`
= help: see <https://doc.rust-lang.org/nomicon/subtyping.html> for more information about variance
error: lifetime may not live long enough
--> tests/compile_fail/node_map_escape_scope.rs:14:9
|
12 | let escaped_map = graph.scope(|ctx| {
| ---- return type of closure is impl Mapping<<gotgraph::graph::Context<'4, &gotgraph::vec_graph::VecGraph<i32, &str>> as gotgraph::graph::Graph>::NodeIx, i32>
| |
| has type `&gotgraph::graph::Context<'3, &gotgraph::vec_graph::VecGraph<i32, &str>>`
13 | let node_map = ctx.init_node_map(|_, &data| data * 2);
14 | node_map // ERROR: node map cannot escape the scope
| ^^^^^^^^ returning this value requires that `'3` must outlive `'4`