Advertisement
Guest User

Untitled

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