@@ -265,9 +265,9 @@ fn strip_generics_from_path_segment(segment: Vec<char>) -> Result<String, Malfor
265265 }
266266}
267267
268- pub fn strip_generics_from_path ( path_str : & str ) -> Result < String , MalformedGenerics > {
268+ pub fn strip_generics_from_path ( path_str : & str ) -> Result < Box < str > , MalformedGenerics > {
269269 if !path_str. contains ( [ '<' , '>' ] ) {
270- return Ok ( path_str. to_string ( ) ) ;
270+ return Ok ( path_str. into ( ) ) ;
271271 }
272272 let mut stripped_segments = vec ! [ ] ;
273273 let mut path = path_str. chars ( ) . peekable ( ) ;
@@ -322,7 +322,11 @@ pub fn strip_generics_from_path(path_str: &str) -> Result<String, MalformedGener
322322
323323 let stripped_path = stripped_segments. join ( "::" ) ;
324324
325- if !stripped_path. is_empty ( ) { Ok ( stripped_path) } else { Err ( MalformedGenerics :: MissingType ) }
325+ if !stripped_path. is_empty ( ) {
326+ Ok ( stripped_path. into ( ) )
327+ } else {
328+ Err ( MalformedGenerics :: MissingType )
329+ }
326330}
327331
328332/// Returns whether the first doc-comment is an inner attribute.
@@ -336,7 +340,7 @@ pub fn inner_docs(attrs: &[ast::Attribute]) -> bool {
336340/// Simplified version of the corresponding function in rustdoc.
337341/// If the rustdoc version returns a successful result, this function must return the same result.
338342/// Otherwise this function may return anything.
339- fn preprocess_link ( link : & str ) -> String {
343+ fn preprocess_link ( link : & str ) -> Box < str > {
340344 let link = link. replace ( '`' , "" ) ;
341345 let link = link. split ( '#' ) . next ( ) . unwrap ( ) ;
342346 let link = link. trim ( ) ;
@@ -345,7 +349,7 @@ fn preprocess_link(link: &str) -> String {
345349 let link = link. strip_suffix ( "{}" ) . unwrap_or ( link) ;
346350 let link = link. strip_suffix ( "[]" ) . unwrap_or ( link) ;
347351 let link = if link != "!" { link. strip_suffix ( '!' ) . unwrap_or ( link) } else { link } ;
348- strip_generics_from_path ( link) . unwrap_or_else ( |_| link. to_string ( ) )
352+ strip_generics_from_path ( link) . unwrap_or_else ( |_| link. into ( ) )
349353}
350354
351355/// Keep inline and reference links `[]`,
@@ -365,7 +369,7 @@ pub fn may_be_doc_link(link_type: LinkType) -> bool {
365369
366370/// Simplified version of `preprocessed_markdown_links` from rustdoc.
367371/// Must return at least the same links as it, but may add some more links on top of that.
368- pub ( crate ) fn attrs_to_preprocessed_links ( attrs : & [ ast:: Attribute ] ) -> Vec < String > {
372+ pub ( crate ) fn attrs_to_preprocessed_links ( attrs : & [ ast:: Attribute ] ) -> Vec < Box < str > > {
369373 let ( doc_fragments, _) = attrs_to_doc_fragments ( attrs. iter ( ) . map ( |attr| ( attr, None ) ) , true ) ;
370374 let doc = prepare_to_doc_link_resolution ( & doc_fragments) . into_values ( ) . next ( ) . unwrap ( ) ;
371375
0 commit comments