pub fn from_url(string: String) -> SourceId {
        let mut parts = string.splitn(2, '+');
        let kind = parts.next().unwrap();
        let url = parts.next().unwrap();

        match kind {
            "git" => {
                let mut url = url.to_url().unwrap();
                let mut reference = GitReference::Branch("master".to_string());
                let pairs = url.query_pairs().unwrap_or(Vec::new());
                for &(ref k, ref v) in pairs.iter() {
                    match &k[..] {
                        // map older 'ref' to branch
                        "branch" |
                        "ref" => reference = GitReference::Branch(v.clone()),

                        "rev" => reference = GitReference::Rev(v.clone()),
                        "tag" => reference = GitReference::Tag(v.clone()),
                        _ => {}
                    }
                }
                url.query = None;
                let precise = mem::replace(&mut url.fragment, None);
                SourceId::for_git(&url, reference)
                         .with_precise(precise)
            },
            "registry" => {
                let url = url.to_url().unwrap();
                SourceId::new(Kind::Registry, url)
                         .with_precise(Some("locked".to_string()))
            }
            "path" => {
                let url = url.to_url().unwrap();
                SourceId::new(Kind::Path, url)
            }
            _ => panic!("Unsupported serialized SourceId")
        }
    }
/// Parses a source URL and returns the corresponding ID.
///
/// ## Example
///
/// ```
/// use cargo::core::SourceId;
/// SourceId::from_url("git+https://github.com/alexcrichton/\
///                     libssh2-static-sys#80e71a3021618eb05\
///                     656c58fb7c5ef5f12bc747f".to_string());
/// ```
Parses a source URL and returns the corresponding ID.
Parses a source URL and returns the corresponding ID .
pub fn from_url(string: String) -> SourceId {
        let mut parts = string.splitn(2, '+');
        let kind = parts.next().unwrap();
        let url = parts.next().unwrap();
        match kind {
            "git" => {
                let mut url = url.to_url().unwrap();
                let mut reference = GitReference::Branch("master".to_string());
                let pairs = url.query_pairs().unwrap_or(Vec::new());
                for &(ref k, ref v) in pairs.iter() {
                    match &k[..] {
                        // map older 'ref' to branch
                        "branch" |
                        "ref" => reference = GitReference::Branch(v.clone()),
                        "rev" => reference = GitReference::Rev(v.clone()),
                        "tag" => reference = GitReference::Tag(v.clone()),
                        _ => {}
                    }
                }
                url.query = None;
                let precise = mem::replace(&mut url.fragment, None);
                SourceId::for_git(&url, reference)
                         .with_precise(precise)
            },
            "registry" => {
                let url = url.to_url().unwrap();
                SourceId::new(Kind::Registry, url)
                         .with_precise(Some("locked".to_string()))
            }
            "path" => {
                let url = url.to_url().unwrap();
                SourceId::new(Kind::Path, url)
            }
            _ => panic!("Unsupported serialized SourceId")
        }
    }
pub fn from_url ( string : String ) -> SourceId { let mut parts = string . splitn ( 2 , '+' ) ; let kind = parts . next ( ) . unwrap ( ) ; let url = parts . next ( ) . unwrap ( ) ; match kind { " " => { let mut url = url . to_url ( ) . unwrap ( ) ; let mut reference = GitReference :: Branch ( " " . to_string ( ) ) ; let pairs = url . query_pairs ( ) . unwrap_or ( Vec :: new ( ) ) ; for & ( ref k , ref v ) in pairs . iter ( ) { match & k [ .. ] { // map older 'ref' to branch " " | " " => reference = GitReference :: Branch ( v . clone ( ) ) , " " => reference = GitReference :: Rev ( v . clone ( ) ) , " " => reference = GitReference :: Tag ( v . clone ( ) ) , _ => { } } } url . query = None ; let precise = mem :: replace ( & mut url . fragment , None ) ; SourceId :: for_git ( & url , reference ) . with_precise ( precise ) } , " " => { let url = url . to_url ( ) . unwrap ( ) ; SourceId :: new ( Kind :: Registry , url ) . with_precise ( Some ( " " . to_string ( ) ) ) } " " => { let url = url . to_url ( ) . unwrap ( ) ; SourceId :: new ( Kind :: Path , url ) } _ => panic ! ( " " ) } }
Parses a source URL and returns the corresponding ID.
Parses a source URL and returns the corresponding ID .
string
String
string
String
example
None