Skip to content

Commit fa5f23b

Browse files
committed
Apply cargo clippy --fix
1 parent 8d65df5 commit fa5f23b

File tree

5 files changed

+19
-21
lines changed

5 files changed

+19
-21
lines changed

src/leetcode/contest/weekly_263.rs

+15-17
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,12 @@ impl Solution1 {
1212
for ch in s.chars() {
1313
if ch.is_numeric() {
1414
curr_digit = curr_digit * 10 + ch.to_digit(10).unwrap();
15-
} else {
16-
if curr_digit != 0 {
17-
if prev >= curr_digit {
18-
return false;
19-
}
20-
prev = curr_digit;
21-
curr_digit = 0;
15+
} else if curr_digit != 0 {
16+
if prev >= curr_digit {
17+
return false;
2218
}
19+
prev = curr_digit;
20+
curr_digit = 0;
2321
}
2422
}
2523

@@ -45,38 +43,38 @@ impl Bank {
4543

4644
fn transfer(&mut self, account1: i32, account2: i32, money: i64) -> bool {
4745
if !self.accounts.contains_key(&account1) || !self.accounts.contains_key(&account2) {
48-
return false;
46+
false
4947
} else {
5048
let avail = *self.accounts.get(&account1).unwrap_or(&0);
5149
if avail >= money {
5250
self.accounts.entry(account1).and_modify(|b| *b -= money);
5351
self.accounts.entry(account2).and_modify(|b| *b += money);
54-
return true;
52+
true
5553
} else {
56-
return false;
54+
false
5755
}
5856
}
5957
}
6058

6159
fn deposit(&mut self, account: i32, money: i64) -> bool {
6260
if !self.accounts.contains_key(&account) {
63-
return false;
61+
false
6462
} else {
6563
self.accounts.entry(account).and_modify(|b| *b += money);
66-
return true;
64+
true
6765
}
6866
}
6967

7068
fn withdraw(&mut self, account: i32, money: i64) -> bool {
7169
if !self.accounts.contains_key(&account) {
72-
return false;
70+
false
7371
} else {
7472
let avail = *self.accounts.get(&account).unwrap_or(&0);
7573
if avail >= money {
7674
self.accounts.entry(account).and_modify(|b| *b -= money);
77-
return true;
75+
true
7876
} else {
79-
return false;
77+
false
8078
}
8179
}
8280
}
@@ -98,8 +96,8 @@ impl Solution3 {
9896
if a == b | nums[i as usize] {
9997
*count += 1
10098
}
101-
subset(&nums, count, i - 1, a, b);
102-
subset(&nums, count, i - 1, a, b | nums[i as usize]);
99+
subset(nums, count, i - 1, a, b);
100+
subset(nums, count, i - 1, a, b | nums[i as usize]);
103101
}
104102

105103
let mut count = 0;

src/leetcode/problem/course-schedule.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::collections::{HashMap, VecDeque};
44
// https://leetcode.com/problems/course-schedule/
55
impl Solution {
66
pub fn can_finish(num_courses: i32, prerequisites: Vec<Vec<i32>>) -> bool {
7-
let mut indegree = (0..num_courses).map(|f| 0).collect::<Vec<i32>>();
7+
let mut indegree = (0..num_courses).map(|_| 0).collect::<Vec<i32>>();
88

99
let mut hm = HashMap::<i32, Vec<i32>>::new();
1010
for prereq in prerequisites.iter() {

src/leetcode/problem/course-schedule_two.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::collections::{HashMap, VecDeque};
44
// https://leetcode.com/problems/course-schedule-ii/
55
impl Solution {
66
pub fn find_order(num_courses: i32, prerequisites: Vec<Vec<i32>>) -> Vec<i32> {
7-
let mut indegree = (0..num_courses).map(|f| 0).collect::<Vec<i32>>();
7+
let mut indegree = (0..num_courses).map(|_| 0).collect::<Vec<i32>>();
88

99
let mut hm = HashMap::<i32, Vec<i32>>::new();
1010
for prereq in prerequisites.iter() {

src/leetcode/problem/keys-and-rooms.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ impl Solution {
2222
rooms[room as usize] = vec![];
2323
}
2424

25-
visited.iter().all(|v| *v == true)
25+
visited.iter().all(|v| *v)
2626
}
2727
}
2828

src/leetcode/problem/restore_ip_addresses.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ impl Solution {
66

77
fn helper(blocks: Vec<Vec<u32>>, digits: &Vec<u32>, i: usize, ans: &mut Vec<String>) {
88
if blocks.len() > 4 || i > digits.len() {
9-
return;
9+
1010
} else if blocks.len() == 4 && i == digits.len() {
1111
let mut s = String::new();
1212
for block in blocks {

0 commit comments

Comments
 (0)