File tree Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Original file line number Diff line number Diff line change 33//! [1]: https://doc.rust-lang.org/nightly/cargo/reference/registry-web-api.html#search
44
55use std:: cmp;
6- use std:: iter:: repeat;
76
87use anyhow:: Context as _;
98use url:: Url ;
@@ -35,7 +34,8 @@ pub fn search(
3534 . map ( |krate| format ! ( "{} = \" {}\" " , krate. name, krate. max_version) )
3635 . collect :: < Vec < String > > ( ) ;
3736
38- let description_margin = names. iter ( ) . map ( |s| s. len ( ) + 4 ) . max ( ) . unwrap_or_default ( ) ;
37+ let mut description_margin = names. iter ( ) . map ( |s| s. len ( ) ) . max ( ) . unwrap_or_default ( ) ;
38+ description_margin += 4 ;
3939
4040 let description_length = cmp:: max ( 80 , 128 - description_margin) ;
4141
@@ -54,10 +54,12 @@ pub fn search(
5454 for ( name, description) in names. into_iter ( ) . zip ( descriptions) {
5555 let line = match description {
5656 Some ( desc) => {
57- let space = repeat ( ' ' )
58- . take ( description_margin - name. len ( ) )
59- . collect :: < String > ( ) ;
60- name + & space + "# " + & desc
57+ format ! (
58+ "{name: <margin$}# {desc}" ,
59+ name = name,
60+ margin = description_margin,
61+ desc = desc
62+ )
6163 }
6264 None => name,
6365 } ;
You can’t perform that action at this time.
0 commit comments