Last active
August 29, 2015 14:03
-
-
Save beccadax/6ae203e687c75273b55e to your computer and use it in GitHub Desktop.
This function creates an index/element tuple generator that actually uses the right indices, but it fails with a *really* weird error.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func realEnumerate<C: Swift.Collection>(collection: C) -> GeneratorOf<(C.IndexType, C.GeneratorType.Element)> { | |
var i: C.IndexType = collection.startIndex | |
return GeneratorOf() { | |
if i < collection.endIndex { | |
// 'i' is flagged in comparison with "'C.IndexType' is not convertible to 'CString'". Whuh? | |
let value = (i, collection[i]) | |
i = i.successor() | |
return value | |
} | |
else { | |
return nil | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Answer on that one: IndexType is not Comparable, which is impossible to tell because most of Collection's definition is missing. Yay for betas!