ClosedRange

struct ClosedRange<T: Comparable<T>

An inclusive interval containing both lower and upper.

a..b desugars to this type. Unlike Range, equal bounds contain one value. Integer iteration explicitly tracks exhaustion so a range ending at the maximum integer never needs an overflowing past-the-end sentinel.

Properties

let lower: T

The inclusive lower bound.

let upper: T

The inclusive upper bound.

Methods

func contains(element: T) -> Bool

Tests lower <= element <= upper.

View Source
pub func contains(element: T) -> Bool {
	element >= self.lower && element <= self.upper
}