The gerund "swimming" functions as a noun, representing the action of the sentence and serving as the subject.