My first crate :D, floop: A more convenient and less error prone replacement for loop `{ select! { .. }}`
⚓ Rust 📅 2026-05-09 👤 surdeus 👁️ 1i was trying to write async code in another project and quickly got frustrated with loop select and the lack of better alternatives,
so i created floop, floop does not require futures to be cancel-safe, fused, or unpin
and supports no-std, no-alloc, and all runtimes (it only uses async, await, and the future traits/types from core).
when a arm finishes only that arm's future is reconstructed,
the other futures are left unchanged and not canceled.
accidentally using a reference to a future instead of a new future, which would be a footgun,
is detected at compile time using const autoref specialization.
if conditions, if let conditions, and break (breaks the specific arm, not the entire loop, the loop breaks once all arms broke) are also supported.
floop should also be rust-analyzer friendly (in most cases, according to my testing.), and does not use synn.
crate: crates.io: Rust Package Registry
docs: floop - Rust
repo: miroo/floop: A more convenient and less error prone replacement for loop `{ select! { .. }}` - Codeberg.org
the code, comments, docs, readme, etc are all written by me, a human, i do not use LLMs
example from the docs:
// NOTE: this just showcases the syntax, the code is mostly nonsense.
// the loop is generated by floop so you just write `floop! { ... }`,
// **not** `loop { floop! { ... }}`
floop! {
// you need to specify whether `floop` should be `biased` or `unbiased`.
unbiased
foo in timer::every(Duration::from_millis(40)) => println!("tick"),
after => at_the_end_of_loop(),
// receive doesn't need to be cancel-safe, nothing does
(bar, baz) in if should_receive_messages(), receive() => {}
}
1 post - 1 participant
🏷️ Rust_feed