Advertisement
Guest User

Untitled

a guest
Sep 16th, 2019
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. #![feature(nll)]
  2.  
  3. use std::cell::UnsafeCell;
  4. use std::rc::Rc;
  5.  
  6. type Invariant<T> = UnsafeCell<T>;
  7. type Covariant<T> = T;
  8.  
  9. type Wrapper<T> = Invariant<T>;
  10. //type Wrapper<T> = Covariant<T>;
  11.  
  12. trait AsSelf<'slf> {
  13. type Ref: ?Sized;
  14.  
  15. fn as_self(&'slf self) -> &Self::Ref;
  16. }
  17.  
  18. struct Foo<'a>(Wrapper<&'a str>);
  19.  
  20. impl<'slf, 'd: 'slf> AsSelf<'slf> for Foo<'d> {
  21. type Ref = Foo<'slf>;
  22.  
  23. fn as_self(&'slf self) -> &'d Self::Ref {
  24. self
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement