Skip to content

Add scala.collection.Factory #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 18, 2018
Merged

Add scala.collection.Factory #8

merged 2 commits into from
Apr 18, 2018

Conversation

julienrf
Copy link
Contributor

No description provided.


implicit def fromCanBuildFrom[A, C](implicit cbf: CanBuildFrom[Nothing, A, C]): Factory[A, C] =
new Factory[A, C] {
def fromSpecific(it: TraversableOnce[A]): C = (cbf() ++= it).result()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs special treatment of Stream and LazyList to preserve laziness.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually this works because Stream uses a LazyBuilder. I’ve added a test for that.

@julienrf julienrf merged commit 144d86e into scala:master Apr 18, 2018
@julienrf julienrf deleted the factory branch April 18, 2018 08:38
martijnhoekstra pushed a commit to martijnhoekstra/scala-collection-compat that referenced this pull request Nov 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants