@@ -608,24 +608,24 @@ With `unpack`, this could be consolidated into
608
608
``` scala
609
609
object walk {
610
610
case class Config [SkipType ](path : Path ,
611
- skip : SkipType = _ => false ,
611
+ skip : SkipType => Boolean = ( _ : T ) => false ,
612
612
preOrder : Boolean = true ,
613
613
followLinks : Boolean = false ,
614
614
maxDepth : Int = Int .MaxValue ,
615
615
includeTarget : Boolean = false )
616
616
617
- def apply (unpack config : Config [os.Path => Boolean ]): IndexedSeq [Path ] = {
617
+ def apply (unpack config : Config [os.Path ]): IndexedSeq [Path ] = {
618
618
stream(config* ).toArray[Path ].toIndexedSeq
619
619
}
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 )] = {
621
621
stream.attrs(config* )
622
622
.toArray[(Path , os.StatInfo )].toIndexedSeq
623
623
}
624
624
object stream {
625
- def apply (unpack config : Config [os.Path => Boolean ]): Generator [Path ] = {
625
+ def apply (unpack config : Config [os.Path ]): Generator [Path ] = {
626
626
attrs(path, (p, _) => skip(p), preOrder, followLinks, maxDepth, includeTarget).map(_._1)
627
627
}
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 )] = ???
629
629
}
630
630
}
631
631
```
@@ -635,8 +635,8 @@ Things to note:
635
635
1 . The different ` def ` s can all share the same ` unpack config: Config ` parameter to share
636
636
the common parameters
637
637
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
640
640
subtle differences accounted for by the type parameter
641
641
642
642
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)
664
664
def downloadStream (unpack config : RequestConfig , unpack asyncConfig : AsyncConfig ) = doSomethingWith(config)
665
665
```
666
666
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
+
667
671
### Nested and Adjacent Unpacks
668
672
669
673
There can be multiple hops, e.g. ` downloadSimple ` unpacks ` RequestConfig ` , and ` RequestConfig `
0 commit comments