SHARE
TWEET

Untitled

a guest Sep 16th, 2019 85 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top