Skip to content

Commit

Permalink
just lint
Browse files Browse the repository at this point in the history
  • Loading branch information
rootulp committed Jan 13, 2025
1 parent 36e14a7 commit df9f20e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions rust/pascals-triangle/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pub struct PascalsTriangle {

impl PascalsTriangle {
pub fn new(row_count: u32) -> Self {
let rows = (1..=row_count).map(|i| generate_row(i)).collect();
let rows = (1..=row_count).map(generate_row).collect();
PascalsTriangle { rows }
}

Expand All @@ -18,7 +18,10 @@ fn generate_row(row_index: u32) -> Vec<u32> {
return vec![1];
}
let prev_row = generate_row(row_index - 1);
let mut row: Vec<u32> = prev_row.windows(2).map(|window| window[0] + window[1]).collect();
let mut row: Vec<u32> = prev_row
.windows(2)
.map(|window| window[0] + window[1])
.collect();
row.insert(0, 1);
row.push(1);
row
Expand Down

0 comments on commit df9f20e

Please sign in to comment.