/// Get links as a vector
///
/// Cache must be populated before call
Get links as a vector
Cache must be populated before call
Get links as a vector Cache must be populated before call
pub fn links(&self, krate: &CrateNum) -> Vec<(String, String)> {
        use html::format::href;
        self.links.iter().filter_map(|&(ref s, did, ref fragment)| {
            match did {
                Some(did) => {
                    if let Some((mut href, ..)) = href(did) {
                        if let Some(ref fragment) = *fragment {
                            href.push_str("#");
                            href.push_str(fragment);
                        }
                        Some((s.clone(), href))
                    } else {
                        None
                    }
                }
                None => {
                    if let Some(ref fragment) = *fragment {
                        let cache = cache();
                        let url = match cache.extern_locations.get(krate) {
                            Some(&(_, ref src, ExternalLocation::Local)) =>
                                src.to_str().expect("invalid file path"),
                            Some(&(_, _, ExternalLocation::Remote(ref s))) => s,
                            Some(&(_, _, ExternalLocation::Unknown)) | None =>
                                "https://doc.rust-lang.org/nightly",
                        };
                        // This is a primitive so the url is done "by hand".
                        Some((s.clone(),
                              format!("{}{}std/primitive.{}.html",
                                      url,
                                      if !url.ends_with('/') { "/" } else { "" },
                                      fragment)))
                    } else {
                        panic!("This isn't a primitive?!");
                    }
                }
            }
        }).collect()
    }
pub fn links ( & self , krate : & CrateNum ) -> Vec < ( String , String ) > { use html :: format :: href ; self . links . iter ( ) . filter_map ( | & ( ref s , did , ref fragment ) | { match did { Some ( did ) => { if let Some ( ( mut href , .. ) ) = href ( did ) { if let Some ( ref fragment ) = * fragment { href . push_str ( " " ) ; href . push_str ( fragment ) ; } Some ( ( s . clone ( ) , href ) ) } else { None } } None => { if let Some ( ref fragment ) = * fragment { let cache = cache ( ) ; let url = match cache . extern_locations . get ( krate ) { Some ( & ( _ , ref src , ExternalLocation :: Local ) ) => src . to_str ( ) . expect ( " " ) , Some ( & ( _ , _ , ExternalLocation :: Remote ( ref s ) ) ) => s , Some ( & ( _ , _ , ExternalLocation :: Unknown ) ) | None => " " , } ; // This is a primitive so the url is done "by hand". Some ( ( s . clone ( ) , format ! ( " " url if url ends_with ( '/' ) { " " } else { " " } fragment ) ) ) } else { panic ! ( " " ) ; } } } } ) . collect ( ) }
Get links as a vector
Cache must be populated before call
Get links as a vector Cache must be populated before call
&self
krate
&CrateNum