File tree 1 file changed +2
-8
lines changed
1 file changed +2
-8
lines changed Original file line number Diff line number Diff line change 3
3
//! [1]: https://doc.rust-lang.org/nightly/cargo/reference/registry-web-api.html#search
4
4
5
5
use std:: cmp;
6
- use std:: iter:: repeat;
7
6
8
7
use anyhow:: Context as _;
9
8
use url:: Url ;
@@ -35,7 +34,7 @@ pub fn search(
35
34
. map ( |krate| format ! ( "{} = \" {}\" " , krate. name, krate. max_version) )
36
35
. collect :: < Vec < String > > ( ) ;
37
36
38
- let description_margin = names. iter ( ) . map ( |s| s. len ( ) + 4 ) . max ( ) . unwrap_or_default ( ) ;
37
+ let description_margin = names. iter ( ) . map ( |s| s. len ( ) ) . max ( ) . unwrap_or_default ( ) + 4 ;
39
38
40
39
let description_length = cmp:: max ( 80 , 128 - description_margin) ;
41
40
@@ -53,12 +52,7 @@ pub fn search(
53
52
54
53
for ( name, description) in names. into_iter ( ) . zip ( descriptions) {
55
54
let line = match description {
56
- Some ( desc) => {
57
- let space = repeat ( ' ' )
58
- . take ( description_margin - name. len ( ) )
59
- . collect :: < String > ( ) ;
60
- name + & space + "# " + & desc
61
- }
55
+ Some ( desc) => format ! ( "{name: <description_margin$}# {desc}" ) ,
62
56
None => name,
63
57
} ;
64
58
let mut fragments = line. split ( query) . peekable ( ) ;
You can’t perform that action at this time.
0 commit comments