Many people are wearing masks when they go outdoors to protect themselves from the coronavirus, and the question was asked whether these masks may be worn outside on Shabbat in a place where there is no Erub. The mask covers the nose and mouth, and is held in place with loops that are fastened around the ears. Is this considered a "garment" which may be worn outside in the public domain on Shabbat, or is such a mask an extraneous accessory, such that wearing it outdoors would violate the prohibition against carrying through a public domain on Shabbat?
An instructive Halachic precedent is perhaps a responsum of the Ben Ish Hai (Rav Yosef Haim of Baghdad, 1833-1909), in his work Rab Pe’alim (2:48), where he addresses the case of an individual who required special glasses outdoors to protect his eyes from the elements. The Ben Ish Hai notes the ruling of the Magen Abraham (Rav Abraham Gombiner, Poland, 1633-1683), in Siman 301, permitting women to go outdoors on Shabbat with a covering attached to their kerchiefs to protect their heads from the rain. This ruling seems to indicate that something worn for the purpose of protection is considered a garment, and may thus be worn on Shabbat. Even though it does not actually provide any sort of medical cure, but merely protects against discomfort, this suffices to permit wearing the garment in a public domain on Shabbat. Therefore, the Ben Ish Hai allowed wearing protective glasses outdoors on Shabbat to avoid discomfort or harm to the eyes.
In the case of a mask, there is perhaps even greater room for leniency, because the mask might be considered an actual form of "medical treatment," in that it protects the body against infection which could cause illness.
There is no reason to forbid wearing a mask out of concern that one might mistakenly take it off and then carry it through the public domain, because to the contrary, specifically while outdoors, one will ensure not to remove the mask. The entire purpose of the mask is to protect one’s face from germs in the air outside, and so we certainly need not worry that somebody might take it off his face outside on Shabbat. Therefore, as long as the mask is properly fastened, such that there is little chance of it falling off, there no need to be concerned that this might lead to carrying the mask in a public domain.
For these reasons, it would seem that one who wishes to wear a mask while outdoors on Shabbat to protect against infection may do so. I consulted with Rabbi Yisrael Bitan, who concurred that one may be lenient in this regard.
Summary: It is permissible to walk outside on Shabbat in a place without an Erub while wearing a mask to protect against infection, as long as it is properly fastened such that it is not likely to fall off.