Any numba equivalent for casting a raw pointer to a StructRef, Dict, List etc?

Seems an example is in order then:

_func_from_address and other helpful intrinsics defined here

Usage:

from numba import njit, types, f8
from numba.experimental.function_type import _get_wrapper_address
from numba.core import cgutils
from numba.extending import intrinsic
# --------------------------------
# : _func_from_address implementation
@intrinsic
def _func_from_address(typingctx, func_type_ref, addr):
    '''Recovers a function from FunctionType and address '''
    func_type = func_type_ref.instance_type
    def codegen(context, builder, sig, args):
        _, addr = args

        sfunc = cgutils.create_struct_proxy(func_type)(context, builder)

        llty = context.get_value_type(types.voidptr)
        addr_ptr = builder.inttoptr(addr,llty)

        sfunc.addr = addr_ptr
        return sfunc._getvalue()
    sig = func_type(func_type_ref, addr)
    return sig, codegen

# -----------------------------------
# : example
@njit
def foo(a,b):
    return a + b

my_fn_type = types.FunctionType(f8(f8,f8))
foo_addr = _get_wrapper_address(foo, f8(f8,f8))

@njit
def apply_whatever(addr, a, b):
    f = _func_from_address(my_fn_type, addr)
    return f(a,b)

print("Should be 4.0: is ", apply_whatever(foo_addr, 1,3))
Should be 4.0: is  4.0