Skip to content

Type 'Collection.IndexDistance' (aka 'Int') in conformance requirement does not refer to a generic parameter or associated type #55

Open
@hufkens

Description

When using the latest Xcode (9.3) I get this error:

RandomKit/Sources/RandomKit/Extensions/Swift/Collection+RandomKit.swift:90:73: Type 'Collection.IndexDistance' (aka 'Int') in conformance requirement does not refer to a generic parameter or associated type

in:

extension Collection where Self: RandomRetrievableInRange, IndexDistance: RandomToValue {

    /// Returns a random element of `self`, or `nil` if `self` is empty.
    public func uncheckedRandom<R: RandomGenerator>(in range: Range<Index>, using randomGenerator: inout R) -> Iterator.Element {
        let upper = range.upperBound
        let lower = range.lowerBound
        let elementIndex = IndexDistance.random(to: distance(from: lower, to: upper), using: &randomGenerator)
        return self[index(lower, offsetBy: elementIndex)]
    }

}

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions