The oxygen in both compounds is bound and is not the cause of the rust. Dissolved gasses including oxygen gas (ie not from the H2O molecule) as well as the ions from dissolved solids (like salt) are what causes the corrosion attributed to water. Metals corrode slower submerged in "dead" water (ie no dissolved oxygen, like that found in a pond overloaded with algae) than standing in air due to the different amount of available oxygen.