Such workaround is not feasible if test() requires access to both b and 'a'.
And there may be other workarounds for some specific circumstances.
Is it possible for the borrow check to figure out that the match expression in the above case does not mutate anything and the borrowing starts only when required (write()).
Not without some new mechanism like a "macro fn" or annotation that the accesses performed in the function body can be leaked to callers, etc. The signature of a function is a contract that describes what the caller and callee can and cannot assume, and there's currently no way to describe "this function accesses some fields but not others", say.[1]
Things would be too fragile if borrowing considerations leaked by default; changes to the function body which don't conflict with the signature would suddenly cause borrow errors downstream.