@@ -7,7 +7,7 @@ use ui_sys::{self, uiControl, uiProgressBar};
7
7
pub enum ProgressBarValue {
8
8
/// Represents a set, consistent percentage of the bar to be filled
9
9
///
10
- /// The u32 should be in the range 0..=100
10
+ /// The value should be in the range 0..=100
11
11
Determinate ( u32 ) ,
12
12
/// Represents an indeterminate value of the progress bar, useful
13
13
/// if you don't know how much of the task being represented is completed
@@ -40,10 +40,6 @@ impl ProgressBar {
40
40
}
41
41
42
42
/// Set the value of the progress bar to a determinate value
43
- ///
44
- /// # Panics
45
- ///
46
- /// This function will panic if `value` is not in the range 0..=100
47
43
pub fn set_determinate ( & mut self , value : u32 ) {
48
44
self . set_value ( ProgressBarValue :: Determinate ( value) ) ;
49
45
}
@@ -54,18 +50,10 @@ impl ProgressBar {
54
50
}
55
51
56
52
/// Set the value of the progress bar
57
- ///
58
- /// # Panics
59
- ///
60
- /// This function will panic if the value is `Determinate` and its value is not
61
- /// in the range 0..=100
62
53
pub fn set_value ( & mut self , value : ProgressBarValue ) {
63
54
let sys_value = match value {
64
55
ProgressBarValue :: Determinate ( value) => {
65
- assert ! ( match value {
66
- 0 ..=100 => true ,
67
- _ => false ,
68
- } ) ;
56
+ let value = if value > 100 { 100 } else { value } ;
69
57
value as i32
70
58
}
71
59
ProgressBarValue :: Indeterminate => -1 ,
0 commit comments