fn rewrite_url_link(db: &RootDatabase, def: ModuleDef, target: &str) -> Option<String> {
    if !(target.contains('#') || target.contains(".html")) {
        return None;
    }

    let module = def.module(db)?;
    let krate = module.krate();
    let canonical_path = def.canonical_path(db)?;
    let base = format!("{}/{}", krate.display_name(db)?, canonical_path.replace("::", "/"));

    get_doc_url(db, &krate)
        .and_then(|url| url.join(&base).ok())
        .and_then(|url| {
            get_symbol_filename(db, &def).as_deref().map(|f| url.join(f).ok()).flatten()
        })
        .and_then(|url| url.join(target).ok())
        .map(|url| url.into_string())
}
/// Try to resolve path to local documentation via path-based links (i.e. `../gateway/struct.Shard.html`).
Try to resolve path to local documentation via path-based links .
Try to resolve path to local documentation via path - based links .
fn rewrite_url_link(db: &RootDatabase, def: ModuleDef, target: &str) -> Option<String> {
    if !(target.contains('#') || target.contains(".html")) {
        return None;
    }
    let module = def.module(db)?;
    let krate = module.krate();
    let canonical_path = def.canonical_path(db)?;
    let base = format!("{}/{}", krate.display_name(db)?, canonical_path.replace("::", "/"));
    get_doc_url(db, &krate)
        .and_then(|url| url.join(&base).ok())
        .and_then(|url| {
            get_symbol_filename(db, &def).as_deref().map(|f| url.join(f).ok()).flatten()
        })
        .and_then(|url| url.join(target).ok())
        .map(|url| url.into_string())
}
fn rewrite_url_link ( db : & RootDatabase , def : ModuleDef , target : & str ) -> Option < String > { if ! ( target . contains ( '#' ) || target . contains ( " " ) ) { return None ; } let module = def . module ( db ) ? ; let krate = module . krate ( ) ; let canonical_path = def . canonical_path ( db ) ? ; let base = format ! ( " " krate display_name ( db ) canonical_path replace ( " " " " ) ) ; get_doc_url ( db , & krate ) . and_then ( | url | url . join ( & base ) . ok ( ) ) . and_then ( | url | { get_symbol_filename ( db , & def ) . as_deref ( ) . map ( | f | url . join ( f ) . ok ( ) ) . flatten ( ) } ) . and_then ( | url | url . join ( target ) . ok ( ) ) . map ( | url | url . into_string ( ) ) }
Try to resolve path to local documentation via path-based links (i.e.
Try to resolve path to local documentation via path - based links ( i . e .
db
&RootDatabase
def
ModuleDef
target
&str
db
&RootDatabase
def
ModuleDef
target
&str