pub fn links(&self, krate: &CrateNum) -> Vec<(String, String)> {
        use crate::html::format::href;
        use crate::html::render::CURRENT_DEPTH;

        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(&(_, _, ExternalLocation::Local)) => {
                                    let depth = CURRENT_DEPTH.with(|l| l.get());
                                    "../".repeat(depth)
                                }
                                Some(&(_, _, ExternalLocation::Remote(ref s))) => s.to_string(),
                                Some(&(_, _, ExternalLocation::Unknown)) | None => {
                                    String::from("https://doc.rust-lang.org/nightly")
                                }
                            };
                            // This is a primitive so the url is done "by hand".
                            let tail = fragment.find('#').unwrap_or_else(|| fragment.len());
                            Some((
                                s.clone(),
                                format!(
                                    "{}{}std/primitive.{}.html{}",
                                    url,
                                    if !url.ends_with('/') { "/" } else { "" },
                                    &fragment[..tail],
                                    &fragment[tail..]
                                ),
                            ))
                        } else {
                            panic!("This isn't a primitive?!");
                        }
                    }
                }
            })
            .collect()
    }
/// Gets links as a vector
///
/// Cache must be populated before call
Gets links as a vector
Cache must be populated before call
Gets links as a vector Cache must be populated before call
pub fn links(&self, krate: &CrateNum) -> Vec<(String, String)> {
        use crate::html::format::href;
        use crate::html::render::CURRENT_DEPTH;
        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(&(_, _, ExternalLocation::Local)) => {
                                    let depth = CURRENT_DEPTH.with(|l| l.get());
                                    "../".repeat(depth)
                                }
                                Some(&(_, _, ExternalLocation::Remote(ref s))) => s.to_string(),
                                Some(&(_, _, ExternalLocation::Unknown)) | None => {
                                    String::from("https://doc.rust-lang.org/nightly")
                                }
                            };
                            // This is a primitive so the url is done "by hand".
                            let tail = fragment.find('#').unwrap_or_else(|| fragment.len());
                            Some((
                                s.clone(),
                                format!(
                                    "{}{}std/primitive.{}.html{}",
                                    url,
                                    if !url.ends_with('/') { "/" } else { "" },
                                    &fragment[..tail],
                                    &fragment[tail..]
                                ),
                            ))
                        } else {
                            panic!("This isn't a primitive?!");
                        }
                    }
                }
            })
            .collect()
    }
pub fn links ( & self , krate : & CrateNum ) -> Vec < ( String , String ) > { use crate :: html :: format :: href ; use crate :: html :: render :: CURRENT_DEPTH ; 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 ( & ( _ , _ , ExternalLocation :: Local ) ) => { let depth = CURRENT_DEPTH . with ( | l | l . get ( ) ) ; " " . repeat ( depth ) } Some ( & ( _ , _ , ExternalLocation :: Remote ( ref s ) ) ) => s . to_string ( ) , Some ( & ( _ , _ , ExternalLocation :: Unknown ) ) | None => { String :: from ( " " ) } } ; // This is a primitive so the url is done "by hand". let tail = fragment . find ( '#' ) . unwrap_or_else ( | | fragment . len ( ) ) ; Some ( ( s . clone ( ) , format ! ( " " url if url ends_with ( '/' ) { " " } else { " " } fragment [ tail ] fragment [ tail ] ) , ) ) } else { panic ! ( " " ) ; } } } } ) . collect ( ) }
Gets links as a vector
Cache must be populated before call
Gets links as a vector Cache must be populated before call
&self
krate
&CrateNum
&self
krate
&CrateNum