Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use std::any::TypeId;
- trait IsSend {
- fn is_send(&self);
- }
- impl<T: Send + 'static> IsSend for T {
- fn is_send(&self){
- println!("TypeId of T: {:?}", TypeId::of::<T>());
- }
- }
- fn main() -> Result<(),Box<dyn std::error::Error>> {
- println!("TypeId of i32: {:?}", TypeId::of::<i32>());
- println!("TypeId of Rc<i32>: {:?}", TypeId::of::<std::rc::Rc<i32>>());
- let i = std::rc::Rc::new(43);
- i.is_send(); // (!!) no compiler error although Rc is not Send
- Ok(())
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement