Skip to content

Commit a3b7fd9

Browse files
sanders41ppamorim
authored andcommitted
Refactor with review requests
1 parent e80133d commit a3b7fd9

File tree

1 file changed

+8
-18
lines changed

1 file changed

+8
-18
lines changed

src/progress.rs

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ impl<'a> Progress<'a> {
5555

5656
/// Wait until MeiliSearch processes an update, and get its status.
5757
///
58-
/// interval_ms = The frequency at which the server should be polled. Default = 50ms
59-
/// timeout_ms = The maximum time to wait for processing to complete. Default = 5000ms
58+
/// `interval` = The frequency at which the server should be polled. Default = 50ms
59+
/// `timeout` = The maximum time to wait for processing to complete. Default = 5000ms
6060
///
61-
/// If the time waited excedes timeout_ms then None will be returned.
61+
/// If the waited time exceeds `timeout` then `None` will be returned.
6262
///
6363
/// # Example
6464
///
@@ -98,21 +98,11 @@ impl<'a> Progress<'a> {
9898
/// ```
9999
pub async fn wait_for_pending_update(
100100
&self,
101-
interval_ms: Option<Duration>,
102-
timeout_ms: Option<Duration>,
101+
interval: Option<Duration>,
102+
timeout: Option<Duration>,
103103
) -> Option<Result<UpdateStatus, Error>> {
104-
let interval: Duration;
105-
let timeout: Duration;
106-
107-
match interval_ms {
108-
Some(v) => interval = v,
109-
None => interval = Duration::from_millis(50),
110-
}
111-
112-
match timeout_ms {
113-
Some(v) => timeout = v,
114-
None => timeout = Duration::from_millis(5000),
115-
}
104+
let interval = interval.unwrap_or_else(|| Duration::from_millis(50));
105+
let timeout = timeout.unwrap_or_else(|| Duration::from_millis(5000));
116106

117107
let mut elapsed_time = Duration::new(0, 0);
118108
let mut status_result: Result<UpdateStatus, Error>;
@@ -159,7 +149,7 @@ pub(crate) async fn async_sleep(interval: Duration) {
159149
.unwrap()
160150
.set_timeout_with_callback_and_timeout_and_arguments_0(
161151
&yes,
162-
interval.as_millis() as i32,
152+
interval.as_millis().try_into().unwrap(),
163153
)
164154
.unwrap();
165155
})).await.unwrap();

0 commit comments

Comments
 (0)