SHARE
TWEET

Untitled

a guest Sep 16th, 2019 90 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. use std::cell::RefCell;
  2. use std::rc::Rc;
  3.  
  4. trait Upper {}
  5. trait Lower: Upper {}
  6.  
  7. struct MyStruct {
  8. }
  9.  
  10. impl Lower for MyStruct {
  11. }
  12.  
  13. impl Upper for MyStruct {
  14. }
  15.  
  16. fn main() {
  17.     let object = Rc::new(RefCell::new(MyStruct {}));
  18.     let lower = object as Rc<RefCell<dyn Lower>>;
  19.    
  20.     let upcast: Rc<RefCell<dyn Upper>> = lower;
  21. }
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