File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed
Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -153,7 +153,7 @@ pub struct RetryConfig {
153153 /// Total number of attempts including the initial try. A value of `1` means no retries.
154154 ///
155155 /// Defaults to `3`.
156- pub max_attempts : u32 ,
156+ pub max_attempts : NonZeroU32 ,
157157 /// Minimum base delay for retries.
158158 ///
159159 /// Defaults to `100ms`.
@@ -172,7 +172,7 @@ pub struct RetryConfig {
172172impl Default for RetryConfig {
173173 fn default ( ) -> Self {
174174 Self {
175- max_attempts : 3 ,
175+ max_attempts : NonZeroU32 :: new ( 3 ) . expect ( "valid non-zero u32" ) ,
176176 min_base_delay : Duration :: from_millis ( 100 ) ,
177177 max_base_delay : Duration :: from_secs ( 1 ) ,
178178 append_retry_policy : AppendRetryPolicy :: All ,
@@ -187,13 +187,13 @@ impl RetryConfig {
187187 }
188188
189189 pub ( crate ) fn max_retries ( & self ) -> u32 {
190- self . max_attempts - 1
190+ self . max_attempts . get ( ) - 1
191191 }
192192
193193 /// Set the total number of attempts including the initial try.
194194 pub fn with_max_attempts ( self , max_attempts : NonZeroU32 ) -> Self {
195195 Self {
196- max_attempts : max_attempts . get ( ) ,
196+ max_attempts,
197197 ..self
198198 }
199199 }
You can’t perform that action at this time.
0 commit comments