error: lifetime may not live long enough
--> tests/compile_fail/edge_map_escape_scope.rs:15:9
|
13 | 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>::EdgeIx, usize>` contains a lifetime `'2`
| |
| has type `&'1 gotgraph::graph::Context<'_, &gotgraph::vec_graph::VecGraph<i32, &str>>`
14 | let edge_map = ctx.init_edge_map(|_, edge| edge.len());
15 | edge_map // ERROR: edge map cannot escape the scope
| ^^^^^^^^ returning this value requires that `'1` must outlive `'2`
|
= note: requirement occurs because of the type `EdgeTag<'_, EdgeIx>`, which makes the generic argument `'_` invariant
= note: the struct `EdgeTag<'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/edge_map_escape_scope.rs:15:9
|
13 | 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>::EdgeIx, usize>
| |
| has type `&gotgraph::graph::Context<'3, &gotgraph::vec_graph::VecGraph<i32, &str>>`
14 | let edge_map = ctx.init_edge_map(|_, edge| edge.len());
15 | edge_map // ERROR: edge map cannot escape the scope
| ^^^^^^^^ returning this value requires that `'3` must outlive `'4`