Inserts this `HostFunc` into a `Store`, returning the `Func` pointing to it. # Unsafety Can only be inserted into stores with a matching `T` relative to when this `HostFunc` was first created.
(self: &Arc<Self>, store: &mut StoreOpaque)
| 2694 | /// Can only be inserted into stores with a matching `T` relative to when |
| 2695 | /// this `HostFunc` was first created. |
| 2696 | pub unsafe fn to_func(self: &Arc<Self>, store: &mut StoreOpaque) -> Result<Func, OutOfMemory> { |
| 2697 | self.validate_store(store); |
| 2698 | let (funcrefs, modules) = store.func_refs_and_modules(); |
| 2699 | let funcref = funcrefs.push_arc_host(self.clone(), modules)?; |
| 2700 | // SAFETY: this funcref was just pushed within the store, so it's safe |
| 2701 | // to say this store owns it. |
| 2702 | Ok(unsafe { Func::from_vm_func_ref(store.id(), funcref) }) |
| 2703 | } |
| 2704 | |
| 2705 | /// Inserts this `HostFunc` into a `Store`, returning the `Func` pointing to |
| 2706 | /// it. |
no test coverage detected