Protocol

RangeExpression

A type that can be used to slice a collection.

Declaration

protocol RangeExpression

Overview

A type that conforms to RangeExpression can convert itself to a Range<Bound> of indices within a given collection.

Topics

Associated Types

associatedtype Bound

The type for which the expression describes a range.

Required.

Instance Methods

func contains(Self.Bound) -> Bool

Returns a Boolean value indicating whether the given element is contained within the range expression.

Required.

func relative<C>(to: C) -> Range<Self.Bound>

Returns the range of indices described by this range expression within the given collection.

Required.

See Also

Range Expressions

struct PartialRangeUpTo

A partial half-open interval up to, but not including, an upper bound.

struct PartialRangeThrough

A partial interval up to, and including, an upper bound.

struct PartialRangeFrom

A partial interval extending upward from a lower bound.

enum UnboundedRange_

A range expression that represents the entire range of a collection.