def string_replacer(old, new):
    """
    Returns a rewrite function that does a literal string match and replace.
    """
    def rewriter(val):
        if isinstance(val, str) and val == old:
            return new
    return rewriter