Advertisement
Guest User

Untitled

a guest
Oct 14th, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. trait Base {
  2. type Item;
  3. type Item2;
  4. }
  5.  
  6. trait Service {
  7. type R;
  8. type E;
  9. type C: Base<Item = Self::R, Item2 = Self::E>;
  10. }
  11.  
  12. fn create() -> impl Service {
  13. struct BaseImpl {}
  14. impl Base for BaseImpl {
  15. type Item = u64;
  16. type Item2 = String;
  17. }
  18.  
  19. struct ServiceImpl {}
  20. impl Service for ServiceImpl {
  21. type R = u64;
  22. type E = String;
  23. type C = BaseImpl;
  24. }
  25.  
  26. ServiceImpl {}
  27. }
  28.  
  29. struct S1<T: Service> {
  30. service: T,
  31. }
  32.  
  33. struct S2<T: Service> {
  34. s1: S1<T>,
  35. }
  36.  
  37. fn main() {
  38. let s1 = S1 { service: create() };
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement