If you left your snapback out in the rain and outside for too long, then it would probably get ruined. However, if you are wearing it during rainfall, then it is not going to get ruined.
In this case, all you need to do is take it inside afterward and allow it to air dry. After which, it should be just fine and ready to go.