feat: Add loop_while() fn

This commit is contained in:
Berkus Decker 2021-12-17 23:18:51 +02:00
parent 33dbf79041
commit 16ec45b97c
1 changed files with 11 additions and 0 deletions

View File

@ -39,3 +39,14 @@ pub fn loop_until<F: Fn() -> bool>(f: F) {
asm::nop();
}
}
/// Loop while a passed function returns `true`.
#[inline]
pub fn loop_while<F: Fn() -> bool>(f: F) {
loop {
if !f() {
break;
}
asm::nop();
}
}