@@ -67,7 +67,7 @@ struct SourceIdInner {
67
67
canonical_url : Url ,
68
68
kind : Kind ,
69
69
// e.g. the exact git revision of the specified branch for a Git Source
70
- precise : Option < String >
70
+ precise : Option < String > ,
71
71
}
72
72
73
73
impl SourceId {
@@ -115,19 +115,18 @@ impl SourceId {
115
115
}
116
116
url. query = None ;
117
117
let precise = mem:: replace ( & mut url. fragment , None ) ;
118
- SourceId :: for_git ( & url, reference)
119
- . with_precise ( precise)
120
- } ,
118
+ SourceId :: for_git ( & url, reference) . with_precise ( precise)
119
+ }
121
120
"registry" => {
122
121
let url = url. to_url ( ) . unwrap ( ) ;
123
122
SourceId :: new ( Kind :: Registry , url)
124
- . with_precise ( Some ( "locked" . to_string ( ) ) )
123
+ . with_precise ( Some ( "locked" . to_string ( ) ) )
125
124
}
126
125
"path" => {
127
126
let url = url. to_url ( ) . unwrap ( ) ;
128
127
SourceId :: new ( Kind :: Path , url)
129
128
}
130
- _ => panic ! ( "Unsupported serialized SourceId" )
129
+ _ => panic ! ( "Unsupported serialized SourceId" ) ,
131
130
}
132
131
}
133
132
@@ -148,7 +147,7 @@ impl SourceId {
148
147
} ;
149
148
150
149
format ! ( "git+{}{}{}" , url, ref_str, precise_str)
151
- } ,
150
+ }
152
151
SourceIdInner { kind : Kind :: Registry , ref url, .. } => {
153
152
format ! ( "registry+{}" , url)
154
153
}
@@ -177,19 +176,25 @@ impl SourceId {
177
176
Ok ( SourceId :: for_registry ( & try!( RegistrySource :: url ( config) ) ) )
178
177
}
179
178
180
- pub fn url ( & self ) -> & Url { & self . inner . url }
181
- pub fn is_path ( & self ) -> bool { self . inner . kind == Kind :: Path }
182
- pub fn is_registry ( & self ) -> bool { self . inner . kind == Kind :: Registry }
179
+ pub fn url ( & self ) -> & Url {
180
+ & self . inner . url
181
+ }
182
+ pub fn is_path ( & self ) -> bool {
183
+ self . inner . kind == Kind :: Path
184
+ }
185
+ pub fn is_registry ( & self ) -> bool {
186
+ self . inner . kind == Kind :: Registry
187
+ }
183
188
184
189
pub fn is_git ( & self ) -> bool {
185
190
match self . inner . kind {
186
191
Kind :: Git ( _) => true ,
187
- _ => false
192
+ _ => false ,
188
193
}
189
194
}
190
195
191
196
/// Creates an implementation of `Source` corresponding to this ID.
192
- pub fn load < ' a > ( & self , config : & ' a Config ) -> Box < Source + ' a > {
197
+ pub fn load < ' a > ( & self , config : & ' a Config ) -> Box < Source + ' a > {
193
198
trace ! ( "loading SourceId; {}" , self ) ;
194
199
match self . inner . kind {
195
200
Kind :: Git ( ..) => Box :: new ( GitSource :: new ( self , config) ) ,
@@ -219,8 +224,8 @@ impl SourceId {
219
224
SourceId {
220
225
inner : Arc :: new ( SourceIdInner {
221
226
precise : v,
222
- .. ( * self . inner ) . clone ( )
223
- } ) ,
227
+ ..( * self . inner ) . clone ( )
228
+ } )
224
229
}
225
230
}
226
231
@@ -256,7 +261,7 @@ impl Encodable for SourceId {
256
261
if self . is_path ( ) {
257
262
s. emit_option_none ( )
258
263
} else {
259
- self . to_url ( ) . encode ( s)
264
+ self . to_url ( ) . encode ( s)
260
265
}
261
266
}
262
267
}
@@ -296,8 +301,12 @@ impl fmt::Display for SourceId {
296
301
// to the same repository.
297
302
impl PartialEq for SourceIdInner {
298
303
fn eq ( & self , other : & SourceIdInner ) -> bool {
299
- if self . kind != other. kind { return false }
300
- if self . url == other. url { return true }
304
+ if self . kind != other. kind {
305
+ return false ;
306
+ }
307
+ if self . url == other. url {
308
+ return true ;
309
+ }
301
310
302
311
match ( & self . kind , & other. kind ) {
303
312
( & Kind :: Git ( ref ref1) , & Kind :: Git ( ref ref2) ) => {
@@ -328,7 +337,7 @@ impl Ord for SourceIdInner {
328
337
( & Kind :: Git ( ref ref1) , & Kind :: Git ( ref ref2) ) => {
329
338
( ref1, & self . canonical_url ) . cmp ( & ( ref2, & other. canonical_url ) )
330
339
}
331
- _ => self . kind . cmp ( & other. kind )
340
+ _ => self . kind . cmp ( & other. kind ) ,
332
341
}
333
342
}
334
343
}
@@ -369,47 +378,45 @@ impl GitReference {
369
378
}
370
379
371
380
pub struct SourceMap < ' src > {
372
- map : HashMap < SourceId , Box < Source + ' src > >
381
+ map : HashMap < SourceId , Box < Source + ' src > > ,
373
382
}
374
383
375
- pub type Sources < ' a , ' src > = Values < ' a , SourceId , Box < Source + ' src > > ;
384
+ pub type Sources < ' a , ' src > = Values < ' a , SourceId , Box < Source + ' src > > ;
376
385
377
386
pub struct SourcesMut < ' a , ' src : ' a > {
378
387
inner : IterMut < ' a , SourceId , Box < Source + ' src > > ,
379
388
}
380
389
381
390
impl < ' src > SourceMap < ' src > {
382
391
pub fn new ( ) -> SourceMap < ' src > {
383
- SourceMap {
384
- map : HashMap :: new ( )
385
- }
392
+ SourceMap { map : HashMap :: new ( ) }
386
393
}
387
394
388
395
pub fn contains ( & self , id : & SourceId ) -> bool {
389
396
self . map . contains_key ( id)
390
397
}
391
398
392
- pub fn get ( & self , id : & SourceId ) -> Option < & ( Source + ' src ) > {
399
+ pub fn get ( & self , id : & SourceId ) -> Option < & ( Source + ' src ) > {
393
400
let source = self . map . get ( id) ;
394
401
395
402
source. map ( |s| {
396
- let s: & ( Source + ' src ) = & * * s;
403
+ let s: & ( Source + ' src ) = & * * s;
397
404
s
398
405
} )
399
406
}
400
407
401
- pub fn get_mut ( & mut self , id : & SourceId ) -> Option < & mut ( Source + ' src ) > {
408
+ pub fn get_mut ( & mut self , id : & SourceId ) -> Option < & mut ( Source + ' src ) > {
402
409
self . map . get_mut ( id) . map ( |s| {
403
- let s: & mut ( Source + ' src ) = & mut * * s;
410
+ let s: & mut ( Source + ' src ) = & mut * * s;
404
411
s
405
412
} )
406
413
}
407
414
408
- pub fn get_by_package_id ( & self , pkg_id : & PackageId ) -> Option < & ( Source + ' src ) > {
415
+ pub fn get_by_package_id ( & self , pkg_id : & PackageId ) -> Option < & ( Source + ' src ) > {
409
416
self . get ( pkg_id. source_id ( ) )
410
417
}
411
418
412
- pub fn insert ( & mut self , id : & SourceId , source : Box < Source + ' src > ) {
419
+ pub fn insert ( & mut self , id : & SourceId , source : Box < Source + ' src > ) {
413
420
self . map . insert ( id. clone ( ) , source) ;
414
421
}
415
422
0 commit comments