[swift-users] error: value of type 'Self.SubSequence' has no member 'Distance'
Daniel Eggert
danieleggert at me.com
Sat Dec 26 12:31:43 CST 2015
> On 24 Dec 2015, at 03:11, Dmitri Gribenko <gribozavr at gmail.com> wrote:
>
> On Wed, Dec 23, 2015 at 3:24 PM, Daniel Eggert via swift-users
> <swift-users at swift.org> wrote:
>> I have an array of String and need to call withCString on each one and then pass the resulting array of UnsafePointer<Int8> to a C api. The unsafe pointer is only valid within the scope of withCString.
>>
>> So I built the following, but the compiler doesn’t like it:
>>
>> % swift scopedReduceAndApply.swift
>> scopedReduceAndApply.swift:18:16: error: value of type 'Self.SubSequence' has no member 'Distance'
>> return tail.scopedReduceAndApply(f, g: g, list: ll)
>> ^~~~ ~~~~~~~~~~~~~~~~~~~~
>>
>> What is ‘Distance’ and why doesn’t SubSequence of CollectionType have it?
>
> That's just a bad error message.
>
>> extension CollectionType where SubSequence : CollectionType {
>
> I think you need this constraint to be propagated all the way down,
> for recursive calls, so you need:
>
> extension CollectionType where SubSequence == Self
>
> Or, if you want to allow the toplevel type to differ:
>
> extension CollectionType
> where
> SubSequence : CollectionType,
> SubSequence.SubSequence == SubSequence
Thanks. That did the trick.
/Daniel
More information about the swift-users
mailing list