We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 47ff937 commit 62ea1deCopy full SHA for 62ea1de
asyncgit/src/progress.rs
@@ -15,7 +15,7 @@ impl ProgressPercent {
15
pub fn new(current: usize, total: usize) -> Self {
16
let total = f64::conv(cmp::max(current, total));
17
let progress = f64::conv(current) / total * 100.0;
18
- let progress = u8::conv_nearest(progress);
+ let progress = u8::try_conv_nearest(progress).unwrap_or(100);
19
Self { progress }
20
}
21
///
@@ -39,6 +39,12 @@ mod tests {
39
assert_eq!(prog.progress, 100);
40
41
42
+ #[test]
43
+ fn test_progress_zero_all() {
44
+ let prog = ProgressPercent::new(0, 0);
45
+ assert_eq!(prog.progress, 100);
46
+ }
47
+
48
#[test]
49
fn test_progress_rounding() {
50
let prog = ProgressPercent::new(2, 10);
0 commit comments