Skip to content

Commit

Permalink
collapse single match blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
danieleades authored and djc committed Dec 11, 2022
1 parent c582ebc commit 75a3311
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 15 deletions.
15 changes: 6 additions & 9 deletions src/multi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,15 +362,12 @@ impl MultiState {
}

fn insert(&mut self, location: InsertLocation) -> usize {
let idx = match self.free_set.pop() {
Some(idx) => {
self.members[idx] = MultiStateMember::default();
idx
}
None => {
self.members.push(MultiStateMember::default());
self.members.len() - 1
}
let idx = if let Some(idx) = self.free_set.pop() {
self.members[idx] = MultiStateMember::default();
idx
} else {
self.members.push(MultiStateMember::default());
self.members.len() - 1
};

match location {
Expand Down
11 changes: 5 additions & 6 deletions src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,15 +279,14 @@ impl ProgressState {

/// The number of steps per second
pub fn per_sec(&self) -> f64 {
match self.status {
Status::InProgress => match 1.0 / self.est.seconds_per_step() {
if let Status::InProgress = self.status {
match 1.0 / self.est.seconds_per_step() {
per_sec if per_sec.is_nan() => 0.0,
per_sec => per_sec,
},
_ => {
let len = self.len.unwrap_or_else(|| self.pos());
len as f64 / self.started.elapsed().as_secs_f64()
}
} else {
let len = self.len.unwrap_or_else(|| self.pos());
len as f64 / self.started.elapsed().as_secs_f64()
}
}

Expand Down

0 comments on commit 75a3311

Please sign in to comment.