@@ -28,14 +28,14 @@ pub(crate) const INSTALLER_VERSION: &str = "3";
2828pub ( crate ) const VERSION_FILE : & str = "rust-installer-version" ;
2929
3030#[ derive( Debug ) ]
31- pub struct DirectoryPackage {
32- path : PathBuf ,
31+ pub struct DirectoryPackage < P > {
32+ path : P ,
3333 components : HashSet < String > ,
3434 copy : bool ,
3535}
3636
37- impl DirectoryPackage {
38- pub fn new ( path : PathBuf , copy : bool ) -> Result < Self > {
37+ impl < P : Deref < Target = Path > > DirectoryPackage < P > {
38+ pub fn new ( path : P , copy : bool ) -> Result < Self > {
3939 let file = utils:: read_file ( "installer version" , & path. join ( VERSION_FILE ) ) ?;
4040 let v = file. trim ( ) ;
4141 if v != INSTALLER_VERSION {
@@ -117,8 +117,7 @@ impl DirectoryPackage {
117117}
118118
119119#[ derive( Debug ) ]
120- #[ allow( dead_code) ] // temp::Dir is held for drop.
121- pub ( crate ) struct TarPackage ( DirectoryPackage , temp:: Dir ) ;
120+ pub ( crate ) struct TarPackage ( DirectoryPackage < temp:: Dir > ) ;
122121
123122impl TarPackage {
124123 pub ( crate ) fn compressed < R : Read > (
@@ -142,15 +141,12 @@ impl TarPackage {
142141 unpack_without_first_dir ( & mut archive, & temp_dir, dl_cfg)
143142 . context ( "failed to extract package" ) ?;
144143
145- Ok ( TarPackage (
146- DirectoryPackage :: new ( temp_dir. to_owned ( ) , false ) ?,
147- temp_dir,
148- ) )
144+ Ok ( TarPackage ( DirectoryPackage :: new ( temp_dir, false ) ?) )
149145 }
150146}
151147
152148impl Deref for TarPackage {
153- type Target = DirectoryPackage ;
149+ type Target = DirectoryPackage < temp :: Dir > ;
154150
155151 fn deref ( & self ) -> & Self :: Target {
156152 & self . 0
0 commit comments