Depends where you live and how good your shot is.
Have lived in South Africa for a while had several attempted robberies in that time whiles out riding. Most of them you saw coming and I used to rely on my kick to accelerate away or dive in between traffic on the road. When I got fatter and slower strapped pepper spray to my handlebars.
Have friends who got stabbed, have friends who lost several teeth or got nicely roughed up wouldn’t blame them to cary a gun.
Though the muggers will only bring out bigger firepower one guy got shot of his bike long range. Some others defended themselves and shot assailants biker did time for murder even if it was self defence.
Not everywhere is as safe as uk countryside.