@@ -9,14 +9,14 @@ pub fn local_path_and_canonical_url(
9
9
url : & str ,
10
10
cargo_home : Option < & std:: path:: Path > ,
11
11
) -> Result < ( std:: path:: PathBuf , String ) , Error > {
12
- local_path_and_canonical_url_with_hash_kind ( url, cargo_home, HashKind :: Legacy )
12
+ local_path_and_canonical_url_with_hash_kind ( url, cargo_home, & DEFAULT_HASHER_KIND )
13
13
}
14
14
15
15
/// Like [`local_path_and_canonical_url`] but accepts [`HashKind`] for determining the crate index path.
16
16
pub fn local_path_and_canonical_url_with_hash_kind (
17
17
url : & str ,
18
18
cargo_home : Option < & std:: path:: Path > ,
19
- hash_kind : HashKind ,
19
+ hash_kind : & HashKind ,
20
20
) -> Result < ( std:: path:: PathBuf , String ) , Error > {
21
21
let ( dir_name, canonical_url) = url_to_local_dir ( url, hash_kind) ?;
22
22
@@ -101,7 +101,7 @@ pub(crate) const DEFAULT_HASHER_KIND: HashKind = HashKind::Legacy;
101
101
102
102
/// Converts a full url, eg https://github.com/rust-lang/crates.io-index, into
103
103
/// the root directory name where cargo itself will fetch it on disk
104
- fn url_to_local_dir ( url : & str , hash_kind : HashKind ) -> Result < ( String , String ) , Error > {
104
+ fn url_to_local_dir ( url : & str , hash_kind : & HashKind ) -> Result < ( String , String ) , Error > {
105
105
#[ allow( deprecated) ]
106
106
fn legacy_hash_u64 ( url : & str , registry_kind : u64 ) -> u64 {
107
107
use std:: hash:: { Hash , Hasher , SipHasher } ;
@@ -258,11 +258,11 @@ mod test {
258
258
fn http_index_url_matches_cargo ( ) {
259
259
use crate :: sparse:: URL ;
260
260
assert_eq ! (
261
- super :: url_to_local_dir( URL , HashKind :: Legacy ) . unwrap( ) ,
261
+ super :: url_to_local_dir( URL , & HashKind :: Legacy ) . unwrap( ) ,
262
262
( "index.crates.io-6f17d22bba15001f" . to_owned( ) , URL . to_owned( ) , )
263
263
) ;
264
264
assert_eq ! (
265
- super :: url_to_local_dir( URL , HashKind :: Stable ) . unwrap( ) ,
265
+ super :: url_to_local_dir( URL , & HashKind :: Stable ) . unwrap( ) ,
266
266
( "index.crates.io-1949cf8c6b5b557f" . to_owned( ) , URL . to_owned( ) , )
267
267
) ;
268
268
@@ -272,7 +272,7 @@ mod test {
272
272
assert_eq ! (
273
273
super :: url_to_local_dir(
274
274
"https://dl.cloudsmith.io/aBcW1234aBcW1234/embark/rust/cargo/index.git" ,
275
- HashKind :: Legacy
275
+ & HashKind :: Legacy
276
276
)
277
277
. unwrap( ) ,
278
278
(
@@ -283,7 +283,7 @@ mod test {
283
283
assert_eq ! (
284
284
super :: url_to_local_dir(
285
285
"https://dl.cloudsmith.io/aBcW1234aBcW1234/embark/rust/cargo/index.git" ,
286
- HashKind :: Stable
286
+ & HashKind :: Stable
287
287
)
288
288
. unwrap( ) ,
289
289
(
@@ -298,23 +298,23 @@ mod test {
298
298
fn git_url_matches_cargo ( ) {
299
299
use crate :: git:: URL ;
300
300
assert_eq ! (
301
- crate :: dirs:: url_to_local_dir( URL , HashKind :: Legacy ) . unwrap( ) ,
301
+ crate :: dirs:: url_to_local_dir( URL , & HashKind :: Legacy ) . unwrap( ) ,
302
302
( "github.com-1ecc6299db9ec823" . to_owned( ) , URL . to_owned( ) )
303
303
) ;
304
304
assert_eq ! (
305
- crate :: dirs:: url_to_local_dir( URL , HashKind :: Stable ) . unwrap( ) ,
305
+ crate :: dirs:: url_to_local_dir( URL , & HashKind :: Stable ) . unwrap( ) ,
306
306
( "github.com-25cdd57fae9f0462" . to_owned( ) , URL . to_owned( ) )
307
307
) ;
308
308
309
309
// Ensure we actually strip off the irrelevant parts of a url, note that
310
310
// the .git suffix is not part of the canonical url, but *is* used when hashing
311
311
assert_eq ! (
312
- crate :: dirs:: url_to_local_dir( & format!( "registry+{}.git?one=1&two=2#fragment" , URL ) , HashKind :: Legacy )
312
+ crate :: dirs:: url_to_local_dir( & format!( "registry+{}.git?one=1&two=2#fragment" , URL ) , & HashKind :: Legacy )
313
313
. unwrap( ) ,
314
314
( "github.com-c786010fb7ef2e6e" . to_owned( ) , URL . to_owned( ) )
315
315
) ;
316
316
assert_eq ! (
317
- crate :: dirs:: url_to_local_dir( & format!( "registry+{}.git?one=1&two=2#fragment" , URL ) , HashKind :: Stable )
317
+ crate :: dirs:: url_to_local_dir( & format!( "registry+{}.git?one=1&two=2#fragment" , URL ) , & HashKind :: Stable )
318
318
. unwrap( ) ,
319
319
( "github.com-e78ed0bbfe5f35d7" . to_owned( ) , URL . to_owned( ) )
320
320
) ;
0 commit comments