Guest User

Untitled

a guest
Apr 25th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. enum GraphError<T> {
  2. Invalid(T),
  3. }
  4.  
  5. trait Graph<T> {
  6. type Vertex;
  7. type Err = GraphError<Self::Vertex>;
  8.  
  9. fn foo(&self) -> Result<(), Self::Err>;
  10. }
  11.  
  12. // ----------------------
  13.  
  14. use std::result::Result as stdResult;
  15.  
  16. type Result<T> = stdResult<T, GraphError<usize>>;
  17.  
  18. impl<T> Graph<T> for SimpleGraph<T> {
  19. type Vertex = usize;
  20.  
  21. fn foo(&self) -> Result<()> {
  22. unimplemented!();
  23. }
  24. // note: expected type `fn(&simple_graph::SimpleGraph<T>) -> std::result::Result<(), <SimpleGraph<T> as Graph<T>>::Err>`
  25. // found type `fn(&simple_graph::SimpleGraph<T>) -> std::result::Result<(), GraphError<usize>>
  26. }
Add Comment
Please, Sign In to add comment