@@ -57,6 +57,11 @@ pub struct TyParamBounds<'a>(pub &'a [clean::TyParamBound]);
5757pub struct CommaSep < ' a , T : ' a > ( pub & ' a [ T ] ) ;
5858pub struct AbiSpace ( pub Abi ) ;
5959
60+ pub struct HRef < ' a > {
61+ pub did : DefId ,
62+ pub text : & ' a str ,
63+ }
64+
6065impl < ' a > VisSpace < ' a > {
6166 pub fn get ( self ) -> & ' a Option < clean:: Visibility > {
6267 let VisSpace ( v) = self ; v
@@ -363,15 +368,7 @@ fn resolved_path(w: &mut fmt::Formatter, did: DefId, path: &clean::Path,
363368 }
364369 }
365370 }
366-
367- match href ( did) {
368- Some ( ( url, shortty, fqp) ) => {
369- write ! ( w, "<a class='{}' href='{}' title='{}'>{}</a>" ,
370- shortty, url, fqp. join( "::" ) , last. name) ?;
371- }
372- _ => write ! ( w, "{}" , last. name) ?,
373- }
374- write ! ( w, "{}" , last. params) ?;
371+ write ! ( w, "{}{}" , HRef :: new( did, & last. name) , last. params) ?;
375372 Ok ( ( ) )
376373}
377374
@@ -437,6 +434,24 @@ fn tybounds(w: &mut fmt::Formatter,
437434 }
438435}
439436
437+ impl < ' a > HRef < ' a > {
438+ pub fn new ( did : DefId , text : & ' a str ) -> HRef < ' a > {
439+ HRef { did : did, text : text }
440+ }
441+ }
442+
443+ impl < ' a > fmt:: Display for HRef < ' a > {
444+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
445+ match href ( self . did ) {
446+ Some ( ( url, shortty, fqp) ) => {
447+ write ! ( f, "<a class='{}' href='{}' title='{}'>{}</a>" ,
448+ shortty, url, fqp. join( "::" ) , self . text)
449+ }
450+ _ => write ! ( f, "{}" , self . text) ,
451+ }
452+ }
453+ }
454+
440455impl fmt:: Display for clean:: Type {
441456 fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
442457 match * self {
0 commit comments