Advertisement
Guest User

Untitled

a guest
Oct 14th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 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. fn create_config() -> impl Service {
  30. let mut srv = create();
  31. srv
  32. }
  33.  
  34. struct S1<T: Service> {
  35. service: T,
  36. }
  37.  
  38. fn new_service() -> S1<impl Service> {
  39. S1 {
  40. service: create_config(),
  41. }
  42. }
  43.  
  44. impl<S: Service> S1<S> {
  45. fn new() -> S1<impl Service> {
  46. S1 {
  47. service: create_config(),
  48. }
  49. }
  50. }
  51.  
  52. fn main() {
  53. //let s = S1::new();
  54. let s = new_service();
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement