SHARE
TWEET

Untitled

a guest Oct 23rd, 2019 96 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #![allow(dead_code)]
  2. #![allow(unused_variables)]
  3. #![allow(unused_imports)]
  4.  
  5. trait Diff<'da> {
  6.     type Target: 'da;
  7.     fn diff(&'da self, other: &'da Self) -> Edit<'da, Self::Target>;
  8. }
  9.  
  10. enum Edit<'da, T> {
  11.     Copy,
  12.     Change(&'da T),
  13. }
  14.  
  15. struct A<'a>(&'a u32);
  16.  
  17. struct EditedA<'da, 'a>(Edit<'da, A<'a>>);
  18.  
  19. impl<'da, 'a> Diff<'da> for A<'a> {
  20.     type Target = &'a u32;
  21.  
  22.     fn diff(&'da self, other: &'da Self) -> Edit<'da, Self::Target> {
  23.         Edit::Change(&other.0)
  24.     }
  25. }
  26.  
  27. fn main() {
  28.     A(&32).diff(&A(&22));
  29. }
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
 
Top