Skip to content

Instantly share code, notes, and snippets.

@alexarchambault
Last active August 29, 2015 14:05
Show Gist options
  • Save alexarchambault/2c96317f0654784ba0ee to your computer and use it in GitHub Desktop.
Save alexarchambault/2c96317f0654784ba0ee to your computer and use it in GitHub Desktop.
trait StableColl[CC[Elem]] {
def builder[Elem](): mutable.Builder[Elem, CC[Elem]]
}
object StableColl {
def apply[CC[Elem]](implicit stableColl: StableColl[CC]): StableColl[CC] = stableColl
implicit def stableCollSeq: StableColl[Seq] =
new StableColl[Seq] {
def builder[Elem]() = new mutable.ListBuffer[Elem]
}
implicit def stableCollList: StableColl[List] =
new StableColl[List] {
def builder[Elem]() = new mutable.ListBuffer[Elem]
}
implicit def stableCollIndexedSeq: StableColl[IndexedSeq] =
new StableColl[IndexedSeq] {
def builder[Elem]() = new mutable.ArrayBuffer[Elem]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment