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