"Rusting", or more chemically correct "oxidation", is a rection with oxygen in the atmosphere. Iron reacts with oxygen and turns into iron oxide, the reddish-brown substance commonly referred to as "rust".
In space there is no atmosphere with any oxygen to react with, so any iron in space would not rust.
This, however, assumes that there is really no oxygen in space. When a spacecraft is in a low orbit around Earth, there are still small traces of atmosphere it flies through. These small traces could bond to any iron and cause it to rust, although far, far slower than on ground level. Another source of oxygen are any rocket engines. Most rocket engines run on some liquid fuel and liquid oxygen. A leak of the latter could cause corrosion to any iron which gets exposed to it.
By the way: The lack of oxidation in vacuum also has another interesting effect which could be either a blessing or a curse for space construction: It allows you to cold-weld. Pure, non-oxidized metals have an interesting property: When they touch, they stick and form a single piece. That means you could break a piece of metal into two, put the parts together again, and they would fuse without a trace. This effect is hard to reproduce on earth, because the moment you break a piece of metal, the exposed area comes into contact with oxygen and a nano-scale corrosion layer forms immediately which prevents cold-welding. But it works in an artificial pure vacuum environment.
For space construction, this could be a blessing because it makes it much easier to put large structures together. Just move two girders together and they fuse the moment they touch. No welding, screws or bolts required. But it could also be a curse, because it is easy for accidental welding to occur. Any surfaces which are designed to touch and separate again (like mechanical gears or joints) need to be coated to avoid accidental cold-welding from happening. Exposing such parts to an oxygen-atmosphere for a short duration could be enough, though.