@@ -265,9 +265,9 @@ fn strip_generics_from_path_segment(segment: Vec<char>) -> Result<String, Malfor
265
265
}
266
266
}
267
267
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 > {
269
269
if !path_str. contains ( [ '<' , '>' ] ) {
270
- return Ok ( path_str. to_string ( ) ) ;
270
+ return Ok ( path_str. into ( ) ) ;
271
271
}
272
272
let mut stripped_segments = vec ! [ ] ;
273
273
let mut path = path_str. chars ( ) . peekable ( ) ;
@@ -322,7 +322,11 @@ pub fn strip_generics_from_path(path_str: &str) -> Result<String, MalformedGener
322
322
323
323
let stripped_path = stripped_segments. join ( "::" ) ;
324
324
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
+ }
326
330
}
327
331
328
332
/// Returns whether the first doc-comment is an inner attribute.
@@ -336,7 +340,7 @@ pub fn inner_docs(attrs: &[ast::Attribute]) -> bool {
336
340
/// Simplified version of the corresponding function in rustdoc.
337
341
/// If the rustdoc version returns a successful result, this function must return the same result.
338
342
/// Otherwise this function may return anything.
339
- fn preprocess_link ( link : & str ) -> String {
343
+ fn preprocess_link ( link : & str ) -> Box < str > {
340
344
let link = link. replace ( '`' , "" ) ;
341
345
let link = link. split ( '#' ) . next ( ) . unwrap ( ) ;
342
346
let link = link. trim ( ) ;
@@ -345,7 +349,7 @@ fn preprocess_link(link: &str) -> String {
345
349
let link = link. strip_suffix ( "{}" ) . unwrap_or ( link) ;
346
350
let link = link. strip_suffix ( "[]" ) . unwrap_or ( link) ;
347
351
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 ( ) )
349
353
}
350
354
351
355
/// Keep inline and reference links `[]`,
@@ -365,7 +369,7 @@ pub fn may_be_doc_link(link_type: LinkType) -> bool {
365
369
366
370
/// Simplified version of `preprocessed_markdown_links` from rustdoc.
367
371
/// 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 > > {
369
373
let ( doc_fragments, _) = attrs_to_doc_fragments ( attrs. iter ( ) . map ( |attr| ( attr, None ) ) , true ) ;
370
374
let doc = prepare_to_doc_link_resolution ( & doc_fragments) . into_values ( ) . next ( ) . unwrap ( ) ;
371
375
0 commit comments