Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

rust: simplify read_poll_timeout's example code

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

Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>
Signed-off-by: Danilo Krummrich <dakr@kernel.org>

authored by

FUJITA Tomonori and committed by
Danilo Krummrich
aad1577a 26c1a20b

+4 -10
+4 -10
rust/kernel/io/poll.rs
··· 42 42 /// 43 43 /// const HW_READY: u16 = 0x01; 44 44 /// 45 - /// fn wait_for_hardware<const SIZE: usize>(io: &Io<SIZE>) -> Result<()> { 46 - /// match read_poll_timeout( 45 + /// fn wait_for_hardware<const SIZE: usize>(io: &Io<SIZE>) -> Result { 46 + /// read_poll_timeout( 47 47 /// // The `op` closure reads the value of a specific status register. 48 48 /// || io.try_read16(0x1000), 49 49 /// // The `cond` closure takes a reference to the value returned by `op` ··· 51 51 /// |val: &u16| *val == HW_READY, 52 52 /// Delta::from_millis(50), 53 53 /// Delta::from_secs(3), 54 - /// ) { 55 - /// Ok(_) => { 56 - /// // The hardware is ready. The returned value of the `op` closure 57 - /// // isn't used. 58 - /// Ok(()) 59 - /// } 60 - /// Err(e) => Err(e), 61 - /// } 54 + /// )?; 55 + /// Ok(()) 62 56 /// } 63 57 /// ``` 64 58 #[track_caller]