Make a paste from salt and lemon juice and gently apply the mixture to the stained area. Please note, it is always best to test an acidic substance like lemon juice on a small hidden area of your carpet to make sure it does not cause bleaching.
Gently blot the area with a damp sponge to help the mixture penetrate into the stain, then blot again with a clean dry towel. You should begin seeing the rust come up onto the towel. Continue this method until you can no longer see the stain, and finish by rinsing the area with cool water and blotting up the moisture completely.