As suggested by others, in that situation I'd have made the bike into a singlespeed so I didn't have to walk.
I had a crank break once, a problem which was unfixable without actually replacing the crank, so ... I rode 5 miles home one-legged!
Another time, I had a saddle clamp bolt break. I put the saddle in my back pocket and rode a couple of miles home standing up.
I had a rear wheel spoke snap on one forum ride and the wheel went so badly out of true that it wouldn't turn. I took the rear mudguard off and removed the back brake blocks and then very gingerly rode 12 miles to Blackpool station to catch a train home.
If my chain was somehow damaged so badly that it couldn't be shortened to a still usable length, I would take one or two of the pieces of spare chain that I always carry and lengthen it!
If the chain got completely destroyed - I'm not sure how that would happen - I would clip my left foot onto the right pedal and use the bike as a scooter!