Skip to content

Commit c8cdea7

Browse files
committed
.
1 parent cd0df39 commit c8cdea7

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

content/unpack.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -608,24 +608,24 @@ With `unpack`, this could be consolidated into
608608
```scala
609609
object walk{
610610
case class Config[SkipType](path: Path,
611-
skip: SkipType = _ => false,
611+
skip: SkipType => Boolean = (_: T) => false,
612612
preOrder: Boolean = true,
613613
followLinks: Boolean = false,
614614
maxDepth: Int = Int.MaxValue,
615615
includeTarget: Boolean = false)
616616

617-
def apply(unpack config: Config[os.Path => Boolean]): IndexedSeq[Path] = {
617+
def apply(unpack config: Config[os.Path]): IndexedSeq[Path] = {
618618
stream(config*).toArray[Path].toIndexedSeq
619619
}
620-
def attrs(unpack config: Config[(os.Path, os.StatInfo) => Boolean]): IndexedSeq[(Path, os.StatInfo)] = {
620+
def attrs(unpack config: Config[(os.Path, os.StatInfo)]): IndexedSeq[(Path, os.StatInfo)] = {
621621
stream.attrs(config*)
622622
.toArray[(Path, os.StatInfo)].toIndexedSeq
623623
}
624624
object stream {
625-
def apply(unpack config: Config[os.Path => Boolean]): Generator[Path] = {
625+
def apply(unpack config: Config[os.Path]): Generator[Path] = {
626626
attrs(path, (p, _) => skip(p), preOrder, followLinks, maxDepth, includeTarget).map(_._1)
627627
}
628-
def attrs(unpack config: Config[(os.Path, os.StatInfo) => Boolean]): Generator[(Path, os.StatInfo)] = ???
628+
def attrs(unpack config: Config[(os.Path, os.StatInfo)]): Generator[(Path, os.StatInfo)] = ???
629629
}
630630
}
631631
```
@@ -635,8 +635,8 @@ Things to note:
635635
1. The different `def`s can all share the same `unpack config: Config` parameter to share
636636
the common parameters
637637

638-
2. The `.attrs` method take a `Config[(os.Path, os.StatInfo) => Boolean]`, while the
639-
`.apply` methods take a `Config[os.Path => Boolean]`, as the shared parameters have some
638+
2. The `.attrs` method take a `Config[(os.Path, os.StatInfo)]`, while the
639+
`.apply` methods take a `Config[os.Path]`, as the shared parameters have some
640640
subtle differences accounted for by the type parameter
641641

642642
3. A lot of these methods are forwarders/wrappers for each other, purely for convenience, and
@@ -664,6 +664,10 @@ def downloadAsync(unpack config: RequestConfig, unpack asyncConfig: AsyncConfig)
664664
def downloadStream(unpack config: RequestConfig, unpack asyncConfig: AsyncConfig) = doSomethingWith(config)
665665
```
666666

667+
You can `unpack` a `case class` into a method `def` parameter list as we see in
668+
the `def download` methods above, or into a `case class` parameter list as we see in
669+
`case class RequestConfig` above.
670+
667671
### Nested and Adjacent Unpacks
668672

669673
There can be multiple hops, e.g. `downloadSimple` unpacks `RequestConfig`, and `RequestConfig`

0 commit comments

Comments
 (0)