summaryrefslogtreecommitdiffstats
path: root/tests/ui/lifetimes/issue-55796.rs
blob: a7b27a99929a739aaec706ce1436d7b67d595820 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
pub trait EdgeTrait<N> {
    fn target(&self) -> N;
}

pub trait Graph<'a> {
    type Node;
    type Edge: EdgeTrait<Self::Node>;
    type NodesIter: Iterator<Item = Self::Node> + 'a;
    type EdgesIter: Iterator<Item = Self::Edge> + 'a;

    fn nodes(&'a self) -> Self::NodesIter;
    fn out_edges(&'a self, u: &Self::Node) -> Self::EdgesIter;
    fn in_edges(&'a self, u: &Self::Node) -> Self::EdgesIter;

    fn out_neighbors(&'a self, u: &Self::Node) -> Box<dyn Iterator<Item = Self::Node>> {
        Box::new(self.out_edges(u).map(|e| e.target()))
        //~^ ERROR lifetime may not live long enough
    }

    fn in_neighbors(&'a self, u: &Self::Node) -> Box<dyn Iterator<Item = Self::Node>> {
        Box::new(self.in_edges(u).map(|e| e.target()))
        //~^ ERROR lifetime may not live long enough
    }
}

fn main() {}