Skip to content

Commit

Permalink
fix panic when range end is greater then start
Browse files Browse the repository at this point in the history
  • Loading branch information
cowboy8625 committed May 11, 2024
1 parent 0afebdc commit 39736ba
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ pub fn times(width: usize, (slowest, fastest): (u64, u64)) -> Vec<(Instant, Dura
/// Generates the visable length of each column.
pub fn lengths(width: usize, height: usize) -> Vec<usize> {
let mut rng = thread_rng();
(0..width).map(|_| rng.gen_range(4..height - 10)).collect()
(0..width.max(1))
.map(|_| rng.gen_range(4..(height - 10).max(4)))
.collect()
}

/// Uses Generates function to create all the color of the Rain/Characters.
Expand Down

0 comments on commit 39736ba

Please sign in to comment.