From aaa2c2e80ed14b1c6099a4eb4d3ffe12011ba7c2 Mon Sep 17 00:00:00 2001 From: Raul Victor Trombin Date: Fri, 20 Oct 2023 10:32:51 -0300 Subject: [PATCH] src: lib: change to a for loop --- src/lib.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 6cce7a4..b309216 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -135,14 +135,13 @@ where } pub fn check_data_ready(&mut self) -> Result<(), Error> { - let mut retries = 10; - while retries > 0 { + let retries = 10; + for _ in 0..retries { let status = self.read_register(Register::ST1)?; if (status & 0x01) != 0 { return Ok(()); // Data ready } std::thread::sleep(std::time::Duration::from_millis(100)); - retries -= 1; } Err(Error::DataNotReady) }