If it is still in the foot then of course remove it unless it is in too far than you would go to the emergency room. If it is not in there then clean the wound. Go to your doctor and make sure to get a tetanus shot.
What you need is to go to the doctor and get a tetanus shot. The rusty nail could cause an infection in your foot and cause big problems. It's best to prevent it before it starts.