Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions library/src/scala/collection/generic/IsIterable.scala
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import caps.unsafe.untrackedCaptures
* is to provide a generic extension method `mapReduce` for any type that extends
* or can be converted to `Iterable`, such as `String`.
*
* ```
* ```scala sc:compile
* import scala.collection.generic.IsIterable
*
* extension [Repr, I <: IsIterable[Repr]](coll: Repr)(using it: I)
Expand All @@ -51,9 +51,9 @@ import caps.unsafe.untrackedCaptures
* res
* }
*
* // See it in action!
* List(1, 2, 3).mapReduce(_ * 2)(_ + _) // res0: Int = 12
* "Yeah, well, you know, that's just, like, your opinion, man.".mapReduce(x => 1)(_ + _) // res1: Int = 59
* // See it in action!
* val res0 = List(1, 2, 3).mapReduce(_ * 2)(_ + _) // res0: Int = 12
* val res1 = "Yeah, well, you know, that's just, like, your opinion, man.".mapReduce(x => 1)(_ + _) // res1: Int = 59
* ```
*
* The extension method takes a receiver `coll` of type `Repr`, where
Expand All @@ -79,7 +79,10 @@ import caps.unsafe.untrackedCaptures
* the implicit value for any `IterableOps`, as for `List` in the previous example.
* Similarly, the instance for `String` was available because the library provides an `IsSeq[String]`.
*
* ```scala sc-name:iterableops-import sc-hidden
* import scala.collection.IterableOps
* ```
* ```scala sc-compile-with:iterableops-import
* implicit val rangeRepr: IsIterable[Range] { type A = Int; type C = IndexedSeq[Int] } =
* new IsIterable[Range] {
* type A = Int
Expand Down
3 changes: 3 additions & 0 deletions library/src/scala/collection/generic/IsIterableOnce.scala
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ import caps.unsafe.untrackedCaptures
* framework in their implementation.
*
* Example usage,
* ```scala sc-name:import-buildfrom sc-hidden
* import scala.collection.BuildFrom
* ```
* ```scala sc-compile-with:import-buildfrom
* extension [Repr, I <: IsIterableOnce[Repr]](coll: Repr)(using it: I) {
* final def filterMap[B, That](f: it.A => Option[B])(using bf: BuildFrom[Repr, B, That]): That = {
* val b = bf.newBuilder(coll)
Expand Down
Loading