Skip to content

Instantly share code, notes, and snippets.

@jspahrsummers
Created October 5, 2014 04:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jspahrsummers/ef5e64c18b9422673bdc to your computer and use it in GitHub Desktop.
Save jspahrsummers/ef5e64c18b9422673bdc to your computer and use it in GitHub Desktop.
Why does this use of SequenceType cause a compiler error? https://github.com/ReactiveCocoa/ReactiveCocoa/pull/1518
public static func fromSequence<S: SequenceType where S.Generator.Element == T>(sequence: S) -> Producer<T> {
return Producer { consumer in
for value in sequence { // error: cannot convert the expression's type 'S' to type 'S'
consumer.put(.Next(Box(value)))
}
consumer.put(.Completed)
}
}
public static func fromSequence(sequence: SequenceOf<T>) -> Producer<T> {
return Producer { consumer in
for value in sequence {
consumer.put(.Next(Box(value)))
}
consumer.put(.Completed)
}
}
@robrix
Copy link

robrix commented Oct 5, 2014

Was fighting this in Set just last night 😕

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment