Skip to content

Commit ece4e96

Browse files
committed
Auto merge of #2467 - tshepang:rustfmt, r=alexcrichton
run rustfmt on core/source.rs
2 parents 834b834 + 76fb87e commit ece4e96

File tree

1 file changed

+36
-29
lines changed

1 file changed

+36
-29
lines changed

src/cargo/core/source.rs

Lines changed: 36 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ struct SourceIdInner {
6767
canonical_url: Url,
6868
kind: Kind,
6969
// e.g. the exact git revision of the specified branch for a Git Source
70-
precise: Option<String>
70+
precise: Option<String>,
7171
}
7272

7373
impl SourceId {
@@ -115,19 +115,18 @@ impl SourceId {
115115
}
116116
url.query = None;
117117
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+
}
121120
"registry" => {
122121
let url = url.to_url().unwrap();
123122
SourceId::new(Kind::Registry, url)
124-
.with_precise(Some("locked".to_string()))
123+
.with_precise(Some("locked".to_string()))
125124
}
126125
"path" => {
127126
let url = url.to_url().unwrap();
128127
SourceId::new(Kind::Path, url)
129128
}
130-
_ => panic!("Unsupported serialized SourceId")
129+
_ => panic!("Unsupported serialized SourceId"),
131130
}
132131
}
133132

@@ -148,7 +147,7 @@ impl SourceId {
148147
};
149148

150149
format!("git+{}{}{}", url, ref_str, precise_str)
151-
},
150+
}
152151
SourceIdInner { kind: Kind::Registry, ref url, .. } => {
153152
format!("registry+{}", url)
154153
}
@@ -177,19 +176,25 @@ impl SourceId {
177176
Ok(SourceId::for_registry(&try!(RegistrySource::url(config))))
178177
}
179178

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+
}
183188

184189
pub fn is_git(&self) -> bool {
185190
match self.inner.kind {
186191
Kind::Git(_) => true,
187-
_ => false
192+
_ => false,
188193
}
189194
}
190195

191196
/// 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> {
193198
trace!("loading SourceId; {}", self);
194199
match self.inner.kind {
195200
Kind::Git(..) => Box::new(GitSource::new(self, config)),
@@ -219,8 +224,8 @@ impl SourceId {
219224
SourceId {
220225
inner: Arc::new(SourceIdInner {
221226
precise: v,
222-
.. (*self.inner).clone()
223-
}),
227+
..(*self.inner).clone()
228+
})
224229
}
225230
}
226231

@@ -256,7 +261,7 @@ impl Encodable for SourceId {
256261
if self.is_path() {
257262
s.emit_option_none()
258263
} else {
259-
self.to_url().encode(s)
264+
self.to_url().encode(s)
260265
}
261266
}
262267
}
@@ -296,8 +301,12 @@ impl fmt::Display for SourceId {
296301
// to the same repository.
297302
impl PartialEq for SourceIdInner {
298303
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+
}
301310

302311
match (&self.kind, &other.kind) {
303312
(&Kind::Git(ref ref1), &Kind::Git(ref ref2)) => {
@@ -328,7 +337,7 @@ impl Ord for SourceIdInner {
328337
(&Kind::Git(ref ref1), &Kind::Git(ref ref2)) => {
329338
(ref1, &self.canonical_url).cmp(&(ref2, &other.canonical_url))
330339
}
331-
_ => self.kind.cmp(&other.kind)
340+
_ => self.kind.cmp(&other.kind),
332341
}
333342
}
334343
}
@@ -369,47 +378,45 @@ impl GitReference {
369378
}
370379

371380
pub struct SourceMap<'src> {
372-
map: HashMap<SourceId, Box<Source+'src>>
381+
map: HashMap<SourceId, Box<Source + 'src>>,
373382
}
374383

375-
pub type Sources<'a, 'src> = Values<'a, SourceId, Box<Source+'src>>;
384+
pub type Sources<'a, 'src> = Values<'a, SourceId, Box<Source + 'src>>;
376385

377386
pub struct SourcesMut<'a, 'src: 'a> {
378387
inner: IterMut<'a, SourceId, Box<Source + 'src>>,
379388
}
380389

381390
impl<'src> SourceMap<'src> {
382391
pub fn new() -> SourceMap<'src> {
383-
SourceMap {
384-
map: HashMap::new()
385-
}
392+
SourceMap { map: HashMap::new() }
386393
}
387394

388395
pub fn contains(&self, id: &SourceId) -> bool {
389396
self.map.contains_key(id)
390397
}
391398

392-
pub fn get(&self, id: &SourceId) -> Option<&(Source+'src)> {
399+
pub fn get(&self, id: &SourceId) -> Option<&(Source + 'src)> {
393400
let source = self.map.get(id);
394401

395402
source.map(|s| {
396-
let s: &(Source+'src) = &**s;
403+
let s: &(Source + 'src) = &**s;
397404
s
398405
})
399406
}
400407

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)> {
402409
self.map.get_mut(id).map(|s| {
403-
let s: &mut (Source+'src) = &mut **s;
410+
let s: &mut (Source + 'src) = &mut **s;
404411
s
405412
})
406413
}
407414

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)> {
409416
self.get(pkg_id.source_id())
410417
}
411418

412-
pub fn insert(&mut self, id: &SourceId, source: Box<Source+'src>) {
419+
pub fn insert(&mut self, id: &SourceId, source: Box<Source + 'src>) {
413420
self.map.insert(id.clone(), source);
414421
}
415422

0 commit comments

Comments
 (0)