@@ -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
@@ -361,15 +366,7 @@ fn resolved_path(w: &mut fmt::Formatter, did: DefId, path: &clean::Path,
361366 }
362367 }
363368 }
364-
365- match href ( did) {
366- Some ( ( url, shortty, fqp) ) => {
367- write ! ( w, "<a class='{}' href='{}' title='{}'>{}</a>" ,
368- shortty, url, fqp. join( "::" ) , last. name) ?;
369- }
370- _ => write ! ( w, "{}" , last. name) ?,
371- }
372- write ! ( w, "{}" , last. params) ?;
369+ write ! ( w, "{}{}" , HRef :: new( did, & last. name) , last. params) ?;
373370 Ok ( ( ) )
374371}
375372
@@ -435,6 +432,24 @@ fn tybounds(w: &mut fmt::Formatter,
435432 }
436433}
437434
435+ impl < ' a > HRef < ' a > {
436+ pub fn new ( did : DefId , text : & ' a str ) -> HRef < ' a > {
437+ HRef { did : did, text : text }
438+ }
439+ }
440+
441+ impl < ' a > fmt:: Display for HRef < ' a > {
442+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
443+ match href ( self . did ) {
444+ Some ( ( url, shortty, fqp) ) => {
445+ write ! ( f, "<a class='{}' href='{}' title='{}'>{}</a>" ,
446+ shortty, url, fqp. join( "::" ) , self . text)
447+ }
448+ _ => write ! ( f, "{}" , self . text) ,
449+ }
450+ }
451+ }
452+
438453impl fmt:: Display for clean:: Type {
439454 fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
440455 match * self {
0 commit comments