Injuries suck ! Frustrating ! A big downer especially if we have a race coming up or even if we have just got back into training again.
But unfortunately it happens and sometimes they are not even related to training (like me that just recently injured my elbow playing basketball with my Juniors) and the first thing we do is to see all the negative sides of it : "I can't run what am I going to do ???" "My race is over !!" And on and on we go .... to a downhill spiral that can even lead you to quit the sport for a while.
What we should do instead is to start a different approach and see what things we CAN do ! We all have deficiencies and that could be on the sport specific (swim, bike and run) or general health that we could give a bit more attention to it. But I know that all we want to do is the thing we CANT do !! That's just human nature, not much we can do about it ! If swimming is your least favorite of all 3, and you injure our shoulder for example, I bet all you want to do is to swimming !!!
So we have to be proactive! First relax, do not panic and see all the great things you can gain from doing things we usually neglect ! Either lack of time or just lazy :)
I will give you a couple examples here so you can have an idea.
One of my athletes recently injured his foot so he can't run so my approach was immediately to tell him : "Hey if you can't run let's focus on your swim and bike now, turning you into an Uber biker and faster swimmer!" That approach is a positive one that actually excites the athlete while letting him dealing with his foot injury in a better way without rushing to get back running.
If you can't swim you can do the same with your bike and run and even if you can't bike and run, you can focus on swimming, core strength, joint mobility and muscle elasticity that I know we can all benefit from it !
There's always something we can do ! We just need to find it and get it going ! We do not need to stop training because even if you can not do any exercise at all, you can always work on your mental strength and gentle mobility and stretch !
Don't let the funk of the injury bring you down ! Find the positive out of it and stay happy !