File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -47,6 +47,18 @@ impl ProgressBar {
47
47
Self :: with_draw_target ( Some ( len) , ProgressDrawTarget :: stderr ( ) )
48
48
}
49
49
50
+ /// Creates a new progress bar without a specified length
51
+ ///
52
+ /// This progress bar by default draws directly to stderr, and refreshes a maximum of 20 times
53
+ /// a second. To change the refresh rate, [set] the [draw target] to one with a different refresh
54
+ /// rate.
55
+ ///
56
+ /// [set]: ProgressBar::set_draw_target
57
+ /// [draw target]: ProgressDrawTarget
58
+ pub fn no_length ( ) -> Self {
59
+ Self :: with_draw_target ( None , ProgressDrawTarget :: stderr ( ) )
60
+ }
61
+
50
62
/// Creates a completely hidden progress bar
51
63
///
52
64
/// This progress bar still responds to API changes but it does not have a length or render in
@@ -263,6 +275,11 @@ impl ProgressBar {
263
275
}
264
276
}
265
277
278
+ /// Sets the length of the progress bar to `None`
279
+ pub fn unset_length ( & self ) {
280
+ self . state ( ) . unset_length ( Instant :: now ( ) ) ;
281
+ }
282
+
266
283
/// Sets the length of the progress bar
267
284
pub fn set_length ( & self , len : u64 ) {
268
285
self . state ( ) . set_length ( Instant :: now ( ) , len) ;
Original file line number Diff line number Diff line change @@ -96,6 +96,11 @@ impl BarState {
96
96
}
97
97
}
98
98
99
+ pub ( crate ) fn unset_length ( & mut self , now : Instant ) {
100
+ self . state . len = None ;
101
+ self . update_estimate_and_draw ( now) ;
102
+ }
103
+
99
104
pub ( crate ) fn set_length ( & mut self , now : Instant , len : u64 ) {
100
105
self . state . len = Some ( len) ;
101
106
self . update_estimate_and_draw ( now) ;
You can’t perform that action at this time.
0 commit comments