Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement