Turn `url_ref` utility function into method.
authorCorey Farwell <coreyf@rwell.org>
Thu, 5 May 2016 22:40:47 +0000 (18:40 -0400)
committerCorey Farwell <coreyf@rwell.org>
Thu, 5 May 2016 22:40:47 +0000 (18:40 -0400)
src/cargo/core/source.rs

index 2229c33bb6ae694b1f7298b301b1a7d81794feda..0bef76dbae49a57840665e5560bc1288be91d1c8 100644 (file)
@@ -137,7 +137,7 @@ impl SourceId {
             SourceIdInner {
                 kind: Kind::Git(ref reference), ref url, ref precise, ..
             } => {
-                let ref_str = url_ref(reference);
+                let ref_str = reference.url_ref();
 
                 let precise_str = if precise.is_some() {
                     format!("#{}", precise.as_ref().unwrap())
@@ -280,7 +280,7 @@ impl fmt::Display for SourceId {
             }
             SourceIdInner { kind: Kind::Git(ref reference), ref url,
                             ref precise, .. } => {
-                try!(write!(f, "{}{}", url, url_ref(reference)));
+                try!(write!(f, "{}{}", url, reference.url_ref()));
 
                 if let Some(ref s) = *precise {
                     let len = cmp::min(s.len(), 8);
@@ -353,13 +353,6 @@ impl hash::Hash for SourceId {
     }
 }
 
-fn url_ref(r: &GitReference) -> String {
-    match r.to_ref_string() {
-        None => "".to_string(),
-        Some(s) => format!("?{}", s),
-    }
-}
-
 impl GitReference {
     pub fn to_ref_string(&self) -> Option<String> {
         match *self {
@@ -374,6 +367,13 @@ impl GitReference {
             GitReference::Rev(ref s) => Some(format!("rev={}", s)),
         }
     }
+
+    fn url_ref(&self) -> String {
+        match self.to_ref_string() {
+            None => "".to_string(),
+            Some(s) => format!("?{}", s),
+        }
+    }
 }
 
 pub struct SourceMap<'src> {