SHARE
TWEET

Untitled

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