Commit aad1577a authored by FUJITA Tomonori's avatar FUJITA Tomonori Committed by Danilo Krummrich
Browse files

rust: simplify read_poll_timeout's example code



- Drop unnecessary Result's '<()>'
- Use '?' instead of match

Signed-off-by: default avatarFUJITA Tomonori <fujita.tomonori@gmail.com>
Signed-off-by: default avatarDanilo Krummrich <dakr@kernel.org>
parent 26c1a20b
Loading
Loading
Loading
Loading
+4 −10
Original line number Diff line number Diff line
@@ -42,8 +42,8 @@
///
/// const HW_READY: u16 = 0x01;
///
/// fn wait_for_hardware<const SIZE: usize>(io: &Io<SIZE>) -> Result<()> {
///     match read_poll_timeout(
/// fn wait_for_hardware<const SIZE: usize>(io: &Io<SIZE>) -> Result {
///     read_poll_timeout(
///         // The `op` closure reads the value of a specific status register.
///         || io.try_read16(0x1000),
///         // The `cond` closure takes a reference to the value returned by `op`
@@ -51,15 +51,9 @@
///         |val: &u16| *val == HW_READY,
///         Delta::from_millis(50),
///         Delta::from_secs(3),
///     ) {
///         Ok(_) => {
///             // The hardware is ready. The returned value of the `op` closure
///             // isn't used.
///     )?;
///     Ok(())
/// }
///         Err(e) => Err(e),
///     }
/// }
/// ```
#[track_caller]
pub fn read_poll_timeout<Op, Cond, T>(