SHARE
TWEET

Untitled

a guest Aug 22nd, 2019 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. trait IsSend  {
  2.     fn is_send(&self);    
  3. }
  4.  
  5. impl<T: Send + 'static> IsSend for T {
  6.     fn is_send(&self){
  7.         println!("T = {:?}", std::any::TypeId::of::<T>())
  8.     }
  9. }
  10.  
  11. fn main() -> Result<(),Box<dyn std::error::Error>> {
  12.      println!("TypeId for Rc<i32>: {:?}", std::any::TypeId::of::<std::rc::Rc<i32>>());
  13.      println!("TypeId for i32: {:?}", std::any::TypeId::of::<i32>());
  14.  
  15.      let i = std::rc::Rc::new(43i32);
  16.      i.is_send(); // (!!) no compiler error although Rc is not Send
  17.      Ok(())
  18. }
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