private withfields — function
withfields(f, x; kwargs...)
Replace fields on x with given keyword arguments, run f and then
restore the fields.
Every keyword argument is a mapping (field, value) or (field, (setfn!, value)).
setfn!(x, val) will be used to set the field; if as in the first case none
is given setfield! is used.