def copy_struct(dst, src, repl=None):
    """
    Copy structure from *src* to *dst* with replacement from *repl*.
    """
    if repl is None:
        repl = {}
    repl = repl.copy()
    # copy data from src or use those in repl
    for k in src._datamodel._fields:
        v = repl.pop(k, getattr(src, k))
        setattr(dst, k, v)
    # use remaining key-values in repl
    for k, v in repl.items():
        setattr(dst, k, v)
    return dst

    Copy structure from *src* to *dst* with replacement from *repl*.
    
numba/core/cgutils.py