Roger Federer believes he was lucky to beat Borna Coric in the Italian Open on Thursday, before withdrawing from the tournament through injury just a day later.