Skip to content

Commit 0ac02b5

Browse files
committed
did some cargo clippy
1 parent 97a164b commit 0ac02b5

File tree

3 files changed

+10
-16
lines changed

3 files changed

+10
-16
lines changed

src/cli.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ pub struct ParsedArgs {
99
pub file: String, // file to read/write
1010
pub force: bool, // if true, overwrites file
1111
pub log: bool, // if true, logs to file
12-
pub evil_mode: bool,
1312
}
1413

1514
impl ParsedArgs {
@@ -19,7 +18,6 @@ impl ParsedArgs {
1918
file,
2019
force: false,
2120
log: false,
22-
evil_mode: false,
2321
}
2422
}
2523
}
@@ -72,7 +70,6 @@ pub fn get_dash_args(args: &[String], start_index: usize, args_struct: &mut Pars
7270
} else if ['l'].contains(&char_part_arg) {
7371
args_struct.log = true;
7472
} else if char_part_arg == 'e' {
75-
args_struct.evil_mode = true;
7673
unsafe {
7774
EASY_MODE = false;
7875
}
@@ -83,7 +80,7 @@ pub fn get_dash_args(args: &[String], start_index: usize, args_struct: &mut Pars
8380
};
8481
unsafe { TOGGLE_CASE = num }
8582
} else if char_part_arg == 't' {
86-
let number: i32 = match arg.split_once("=") {
83+
let number: i32 = match arg.split_once('=') {
8784
Some(n) => match n.1.parse() {
8885
Ok(value) => value,
8986
Err(error) => error::error(0, error),

src/keywords.rs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ impl Keyword {
6161
keywords.insert("createfile".to_string(), TokenType::CreateFile);
6262
keywords.insert("deletefile".to_string(), TokenType::DeleteFile);
6363
if num != 0 {
64-
for (key, value) in keywords.clone().iter() {
64+
for (key, value) in &keywords.clone() {
6565
keywords.remove(key);
66-
keywords.insert(toggle_case(key.to_string(), num), value.clone());
66+
keywords.insert(toggle_case(key, num), value.clone());
6767
}
6868
}
6969
Self { keywords }
@@ -83,22 +83,19 @@ impl Default for Keyword {
8383
}
8484
}
8585

86-
fn toggle_case(string: String, num: i32) -> String {
86+
fn toggle_case(string: &str, num: i32) -> String {
8787
println!("{}", string.len() + num as usize % 10);
88-
let mut num = match string.len() as i32 - num {
89-
nums if nums <= 0 => num,
90-
nums => nums,
88+
let num: usize = match string.len() as i32 - num {
89+
nums if nums <= 0 => num as usize % 50,
90+
nums => nums as usize % 50,
9191
};
92-
num = num % 50;
9392
let mut new_string = String::new();
94-
let mut count = 0;
95-
for c in string.chars() {
93+
for (count, c) in string.chars().enumerate() {
9694
if count % num == 0 {
9795
new_string.push(c.to_uppercase().next().unwrap());
9896
} else {
9997
new_string.push(c);
10098
}
101-
count += 1;
10299
}
103100
new_string
104101
}

src/token.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,9 +231,9 @@ impl TokenType {
231231
Self::StrToNum => {
232232
let string = match string {
233233
strings if string.starts_with("0x") => {
234-
strings.to_owned().trim().to_owned()
234+
strings.clone().trim().to_owned()
235235
}
236-
strings => format!("0x{}", strings.trim()).to_owned(),
236+
strings => format!("0x{}", strings.trim()),
237237
};
238238
let number: FloatLiteral = match string.parse() {
239239
Ok(value) => value,

0 commit comments

Comments
 (0)