The gas that forms rust with water and iron is oxygen. Rust is formed when iron reacts with oxygen and water in a process called oxidation.
The reactants in the formation of rust are iron (Fe) and oxygen (O2). When iron reacts with oxygen in the presence of water or moisture, it forms iron oxide, commonly known as rust.
Rusting requires the presence of oxygen, water, and a metal such as iron. The process of rusting, or corrosion, occurs when the metal reacts with oxygen in the presence of water to form iron oxide, which appears as rust.
When iron reacts with water and oxygen, a redox reaction occurs where iron undergoes oxidation to form iron oxide, commonly known as rust. This process is accelerated in the presence of electrolytes, such as salts in water, which promote the flow of electrons, leading to faster corrosion of the iron. Rusting is a form of corrosion that weakens the iron structure over time if left unaddressed.
An iron nail will rust slowly in distilled water when that water has dissolved oxygen. If you get rid of the oxygen by boiling and keep it from getting back in then the iron nail will not rust at all.