rust/src/test/ui/issues/issue-55796.rs
2019-05-29 00:57:31 -04:00

27 lines
773 B
Rust

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 cannot infer
}
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 cannot infer
}
}
fn main() {}