Skip to content

Commit c28dbd6

Browse files
authored
chore: format rust code with rustfmt (#3140)
1 parent a463351 commit c28dbd6

File tree

474 files changed

+14354
-14729
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

474 files changed

+14354
-14729
lines changed

basic/sorting/HeapSort/README.md

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -480,19 +480,13 @@ fn sink(nums: &mut Vec<i32>, mut i: usize, n: usize) {
480480
fn main() -> io::Result<()> {
481481
let mut s = String::new();
482482
io::stdin().read_line(&mut s)?;
483-
let s: Vec<usize> = s
484-
.split(' ')
485-
.map(|s| s.trim().parse().unwrap())
486-
.collect();
483+
let s: Vec<usize> = s.split(' ').map(|s| s.trim().parse().unwrap()).collect();
487484
// let n = s[0];
488485
let m = s[1];
489486

490487
let mut nums = String::new();
491488
io::stdin().read_line(&mut nums)?;
492-
let mut nums: Vec<i32> = nums
493-
.split(' ')
494-
.map(|s| s.trim().parse().unwrap())
495-
.collect();
489+
let mut nums: Vec<i32> = nums.split(' ').map(|s| s.trim().parse().unwrap()).collect();
496490

497491
heap_sort(&mut nums);
498492
for num in nums.iter().take(m) {

basic/sorting/MergeSort/README.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -302,10 +302,7 @@ fn main() -> io::Result<()> {
302302

303303
let mut nums = String::new();
304304
io::stdin().read_line(&mut nums)?;
305-
let mut nums: Vec<i32> = nums
306-
.split(' ')
307-
.map(|s| s.trim().parse().unwrap())
308-
.collect();
305+
let mut nums: Vec<i32> = nums.split(' ').map(|s| s.trim().parse().unwrap()).collect();
309306

310307
merge_sort(&mut nums, 0, n - 1);
311308
for num in nums.iter() {

lcci/01.03.String to URL/README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,11 @@ impl Solution {
181181
s.chars()
182182
.take(length as usize)
183183
.map(|c| {
184-
if c == ' ' { "%20".to_string() } else { c.to_string() }
184+
if c == ' ' {
185+
"%20".to_string()
186+
} else {
187+
c.to_string()
188+
}
185189
})
186190
.collect()
187191
}

lcci/01.03.String to URL/README_EN.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,11 @@ impl Solution {
195195
s.chars()
196196
.take(length as usize)
197197
.map(|c| {
198-
if c == ' ' { "%20".to_string() } else { c.to_string() }
198+
if c == ' ' {
199+
"%20".to_string()
200+
} else {
201+
c.to_string()
202+
}
199203
})
200204
.collect()
201205
}

lcci/02.05.Sum Lists/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ function addTwoNumbers(l1: ListNode | null, l2: ListNode | null): ListNode | nul
220220
impl Solution {
221221
pub fn add_two_numbers(
222222
mut l1: Option<Box<ListNode>>,
223-
mut l2: Option<Box<ListNode>>
223+
mut l2: Option<Box<ListNode>>,
224224
) -> Option<Box<ListNode>> {
225225
let mut dummy = Some(Box::new(ListNode::new(0)));
226226
let mut cur = dummy.as_mut();

lcci/02.05.Sum Lists/README_EN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ function addTwoNumbers(l1: ListNode | null, l2: ListNode | null): ListNode | nul
224224
impl Solution {
225225
pub fn add_two_numbers(
226226
mut l1: Option<Box<ListNode>>,
227-
mut l2: Option<Box<ListNode>>
227+
mut l2: Option<Box<ListNode>>,
228228
) -> Option<Box<ListNode>> {
229229
let mut dummy = Some(Box::new(ListNode::new(0)));
230230
let mut cur = dummy.as_mut();

lcci/03.02.Min Stack/README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,10 @@ struct MinStack {
250250
impl MinStack {
251251
/** initialize your data structure here. */
252252
fn new() -> Self {
253-
Self { stack: VecDeque::new(), min_stack: VecDeque::new() }
253+
Self {
254+
stack: VecDeque::new(),
255+
min_stack: VecDeque::new(),
256+
}
254257
}
255258

256259
fn push(&mut self, x: i32) {

lcci/03.02.Min Stack/README_EN.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,10 @@ struct MinStack {
270270
impl MinStack {
271271
/** initialize your data structure here. */
272272
fn new() -> Self {
273-
Self { stack: VecDeque::new(), min_stack: VecDeque::new() }
273+
Self {
274+
stack: VecDeque::new(),
275+
min_stack: VecDeque::new(),
276+
}
274277
}
275278

276279
fn push(&mut self, x: i32) {

lcci/03.05.Sort of Stacks/README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,11 @@ impl SortedStack {
323323
}
324324

325325
fn peek(&self) -> i32 {
326-
if self.is_empty() { -1 } else { *self.stk.back().unwrap() }
326+
if self.is_empty() {
327+
-1
328+
} else {
329+
*self.stk.back().unwrap()
330+
}
327331
}
328332

329333
fn is_empty(&self) -> bool {

lcci/03.05.Sort of Stacks/README_EN.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,11 @@ impl SortedStack {
337337
}
338338

339339
fn peek(&self) -> i32 {
340-
if self.is_empty() { -1 } else { *self.stk.back().unwrap() }
340+
if self.is_empty() {
341+
-1
342+
} else {
343+
*self.stk.back().unwrap()
344+
}
341345
}
342346

343347
fn is_empty(&self) -> bool {

0 commit comments

Comments
 (0)