@@ -3,7 +3,7 @@ use std::process::exit;
33use crate :: error;
44pub static mut EASY_MODE : bool = false ;
55pub static mut TOGGLE_CASE : i32 = 0 ;
6- #[ derive( PartialEq , Debug ) ]
6+ #[ derive( PartialEq , Eq , Debug ) ]
77pub struct ParsedArgs {
88 pub repl : bool , // inerative mode
99 pub file : String , // file to read/write
@@ -23,24 +23,24 @@ impl ParsedArgs {
2323}
2424
2525pub fn get_string_args ( args : & [ String ] ) -> ( usize , ParsedArgs ) {
26- let mut to_return: ParsedArgs = ParsedArgs :: new ( false , String :: from ( "" ) ) ;
26+ let mut to_return: ParsedArgs = ParsedArgs :: new ( false , String :: new ( ) ) ;
2727 let mut index: usize = 1 ; // start at 1 because index 0 is the program name
2828 if args. len ( ) < 2 {
2929 // if there are no arguments run in repl mode with no file
30- return ( 0 , ParsedArgs :: new ( true , String :: from ( "" ) ) ) ;
30+ return ( 0 , ParsedArgs :: new ( true , String :: new ( ) ) ) ;
3131 } else if args[ 1 ] . ends_with ( ".umpl" ) {
3232 // make sure it's a .umpl file
3333 to_return. file = args[ 1 ] . to_string ( ) ; // if it is, then set file to the file name
3434 to_return. repl = false ; // and set repl to false
3535 index += 1 ; // and increment index
3636 let file_len = to_return. file . strip_suffix ( ".umpl" ) . unwrap ( ) . len ( ) ; // get the length of the file name without the .umpl
37- if args. len ( ) > 2 && args[ 2 ] == format ! ( "{}" , file_len ) {
37+ if args. len ( ) > 2 && args[ 2 ] == format ! ( "{file_len}" ) {
3838 unsafe {
3939 EASY_MODE = true ;
4040 }
4141 index += 1 ; // and increment index
4242 } else if args. len ( ) > 2 && args[ 2 ] == "show_length" {
43- println ! ( "{}" , file_len ) ; // print the length of the file name without the .umpl
43+ println ! ( "{file_len}" ) ; // print the length of the file name without the .umpl
4444 exit ( 1 ) ;
4545 }
4646 } else {
@@ -80,13 +80,10 @@ pub fn get_dash_args(args: &[String], start_index: usize, args_struct: &mut Pars
8080 } ;
8181 unsafe { TOGGLE_CASE = num as i32 } ;
8282 } else if char_part_arg == 't' {
83- let number: i32 = match arg. split_once ( '=' ) {
84- Some ( n) => match n. 1 . parse ( ) {
85- Ok ( value) => value,
86- Err ( error) => error:: error ( 0 , error) ,
87- } ,
88- _ => error:: error ( 0 , "option t requires an =number" ) ,
89- } ;
83+ let number: i32 = arg. split_once ( '=' ) . map_or_else ( || error:: error ( 0 , "option t requires an =number" ) , |n| match n. 1 . parse ( ) {
84+ Ok ( value) => value,
85+ Err ( error) => error:: error ( 0 , error) ,
86+ } ) ;
9087 unsafe {
9188 TOGGLE_CASE = number;
9289 }
0 commit comments