Skip to content

Commit ff68295

Browse files
committed
refactor
- expect says what it expects to be true (but isn't). - avoid unwraps
1 parent a4ac58e commit ff68295

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

gitoxide-core/src/hours/core.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub fn estimate_hours(
2828
let mut hours = 0.0;
2929

3030
let mut commits = commits.iter().map(|t| &t.1).rev();
31-
let mut cur = commits.next().expect("not a single commit found");
31+
let mut cur = commits.next().expect("at least one commit if we are here");
3232

3333
for next in commits {
3434
let change_in_minutes = (next.time.seconds.saturating_sub(cur.time.seconds)) as f32 / MINUTES_PER_HOUR;
@@ -37,7 +37,6 @@ pub fn estimate_hours(
3737
} else {
3838
hours += FIRST_COMMIT_ADDITION_IN_MINUTES / MINUTES_PER_HOUR
3939
}
40-
4140
cur = next;
4241
}
4342

gitoxide-core/src/hours/util.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ where
5555
// estimate lower bound of capacity needed
5656
let (lower, _) = iter.size_hint();
5757
let mut result = String::with_capacity(sep.len() * lower);
58-
write!(&mut result, "{first_elt}").unwrap();
58+
write!(&mut result, "{first_elt}").expect("enough memory");
5959
iter.for_each(|elt| {
6060
result.push_str(sep);
61-
write!(&mut result, "{elt}").unwrap();
61+
write!(&mut result, "{elt}").expect("enough memory");
6262
});
6363
result
6464
}

0 commit comments

Comments
 (0)