Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2019
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. #![feature(existential_type)]
  2. #![feature(impl_trait_in_bindings)]
  3.  
  4. existential type T: Tr;
  5.  
  6. trait Tr {}
  7.  
  8. struct S<M> {
  9. m : M
  10. }
  11.  
  12. impl<M> S<M> {
  13. fn new(m: M) -> Self {
  14. S { m }
  15. }
  16. }
  17.  
  18. impl<M> Tr for S<M> {}
  19.  
  20. pub fn new<F, M>(f: F) -> T
  21. where F: FnOnce() -> S<M>
  22. {
  23. f()
  24. }
  25.  
  26. pub fn new2<M>(m: M) -> impl Tr {
  27. S::new(m)
  28. }
  29.  
  30. fn main() {
  31. println!("Hello, world!");
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement