| 60 | |
| 61 | #[test] |
| 62 | fn test2() { |
| 63 | let mut list = Vector::new(); |
| 64 | |
| 65 | fn convert<T: Copy>(closure: Closure<T>) -> *const u32 { |
| 66 | let ptr = &closure as *const Closure<T>; |
| 67 | return ptr as *const u32;// as *const u32; |
| 68 | } |
| 69 | |
| 70 | list.push(Box::new(Closure::bind(&invoke, ("hello", 42)))); |
| 71 | list.push(Box::new(Closure::bind(&invoke2, ("worldz", 12, "you are great")))); |
| 72 | |
| 73 | for closure in list.into_iter() { |
| 74 | let func = Box::from_raw::<Closure::<(&str, i32, &str)>>(closure); |
| 75 | func.invoke(); |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | fn invoke2(message: (&str, i32, &str)) { |
| 80 | std::println!("[invoke2] {} {} {}", message.0, message.1, message.2); |