I am having my house rebuilt after a fire and, given that the basement floods occasionally (sometimes up to the top in a bad flood), i'm having the breaker box and hot water heater moved to the first floor. they just put in the pluming and elctric lines and they made a small "room" within a room for the hot water heater. On the outside wall of this hot water heater room is where the breaker panel is. It's definitely less than 3 feet from the water heater but it's on the outside wall of the heater cubby so the back of the breaker panel will be very close to the heater (although most likely in a wall once they're done). Is this up to code and, more importantly, is it safe?
It is absolutely safe. There is no clearance issue with regard to a water heater, or even a sink, and an electrical panel. The only issue is with working clearances, and this is an issue regardless of what is around the panel. Based on the letter of the code it is perfectly feasible to have a water heater or sink immediately next to a breaker panel.
Contrary to popular belief, an electrical panel, or most other electrical equipment, will not explode and blow up the house if contact with water is made.
I have seen with my own eyes, basements flooded to the rafters, with the electrical panel completely submerged, and on and working. There are many videos online with small appliances like hair dryers, submerged in a sink full of water while still powered and working....completely under water.