11use dialoguer:: { theme:: ColorfulTheme , Select } ;
22
33fn vec_from_str ( s : String ) -> Vec < String > {
4- s. split ( "," ) . map ( |s| s. trim ( ) . into ( ) ) . collect ( )
4+ s. split ( ',' ) . map ( |s| s. trim ( ) . into ( ) ) . collect ( )
55}
66
77#[ derive( Default ) ]
@@ -25,7 +25,7 @@ impl App {
2525 fn get_config ( & self ) -> String {
2626 match & self . typ {
2727 AppTyp :: Site => {
28- if self . apt . len ( ) > 0 {
28+ if ! self . apt . is_empty ( ) {
2929 format ! (
3030 "ID={}\n MAIN={}\n AUTORESTART={}\n RAM={}\n APT={}\n TYPE=site\n VERSION=latest" ,
3131 self . subdomain,
@@ -42,7 +42,7 @@ impl App {
4242 }
4343 }
4444 AppTyp :: Bot => {
45- if self . apt . len ( ) > 0 {
45+ if ! self . apt . is_empty ( ) {
4646 format ! ( "NAME={}\n AVATAR={}\n MAIN={}\n AUTORESTART={}\n RAM={}\n APT={}\n TYPE=bot\n VERSION=latest" , self . name, self . avatar, self . main, self . autorestart, self . ram, self . apt. join( "," ) )
4747 } else {
4848 format ! ( "NAME={}\n AVATAR={}\n MAIN={}\n AUTORESTART={}\n RAM={}\n TYPE=bot\n VERSION=latest" , self . name, self . avatar, self . main, self . autorestart, self . ram)
@@ -60,7 +60,7 @@ pub fn init() -> std::io::Result<()> {
6060 let typ = Select :: with_theme ( & ColorfulTheme :: default ( ) )
6161 . with_prompt ( "Type" )
6262 . default ( 0 )
63- . items ( & vec ! [ "Bot" , "Site" ] )
63+ . items ( & [ "Bot" , "Site" ] )
6464 . interact ( ) ?;
6565 let mut app: App = Default :: default ( ) ;
6666 match typ {
@@ -96,7 +96,7 @@ pub fn init() -> std::io::Result<()> {
9696 . with_prompt ( "APT Packages" )
9797 . allow_empty ( true )
9898 . interact_text ( ) ?;
99- if apt. len ( ) > 0 {
99+ if ! apt. is_empty ( ) {
100100 app. apt = vec_from_str ( apt) ;
101101 }
102102 std:: fs:: write ( "discloud.config" , app. get_config ( ) ) ?;
0 commit comments