SHARE
TWEET

Untitled

a guest Oct 18th, 2019 81 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #![feature(extern_types)]
  2.  
  3. // This type derives `Copy`.
  4. #[derive(Debug, PartialEq)]
  5. struct Ptr<'a, T> {
  6.     pointer: &'a T
  7. }
  8.  
  9. impl<T> Copy for Ptr<'_, T> { }
  10. impl<T> Clone for Ptr<'_, T> { fn clone(&self) -> Self { *self } }
  11.  
  12. extern {
  13.     type OpaqueListContents;
  14. }
  15.  
  16. // This type does not implement `Copy`.
  17. #[repr(C)]
  18. pub struct List<T> {
  19.     len: usize,
  20.     data: [T; 0],
  21.     //opaque: OpaqueListContents,
  22. }
  23.  
  24. // This struct derives `Copy`, and compiles ok.
  25. #[derive(Clone, Copy)]
  26. struct ParamEnv1 {
  27.     x: i32,
  28.     y: &'static List<u32>,
  29. }
  30.  
  31. #[derive(Copy, Clone)]
  32. struct ParamEnv2 {
  33.     x: i32,
  34.     z: Ptr<'static, List<u32>>,
  35. }
  36.  
  37. fn main() {
  38. }
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