Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2019
99
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. use std::sync::Arc;
  3.  
  4. trait IsSend {
  5. fn is_send(&self);
  6. }
  7.  
  8. impl<T: Send + 'static> IsSend for T {
  9. fn is_send(&self){
  10. println!("TypeId of T: {:?}", TypeId::of::<T>());
  11. }
  12. }
  13.  
  14. fn main() -> Result<(),Box<dyn std::error::Error>> {
  15. println!("TypeId of i32: {:?}", TypeId::of::<i32>());
  16. println!("TypeId of Arc<i32>: {:?}", TypeId::of::<Arc<i32>>());
  17.  
  18. let i = Arc::new(43);
  19. i.is_send(); // (!!) no compiler error although Rc is not Send
  20. Ok(())
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement