Rats in compost is a common problem and as is often the case, prevention is better than cure.
Kitchen waste, especially cooked food, should not be added to a compost heap – put it in your Council food waste bin or wormery if you have one. Surplus produce left lying around e.g. old marrows and (unfortunately) sweetcorn before it is harvested will also attract vermin.
Compost from a source infested with rats will contain their urine and faeces, and possibly the organism responsible for Weil’s Disease (Leptospirosis). It should therefore not come directly into contact with you or your fruit and veg.
This organism can survive in water but not in soil so the simplest solution is to spread your compost on bare soil or dig it in and keep it away from crops you are about to eat.
Gloves should be worn when handling compost and all fruit and vegetables washed in clean water before eating.
Care should be taken not to contaminate the water supplies with tools or produce etc, which may have been in contact with infected material.