floop is a more convenient and less error-prone replacement for loop { select! { ... }} with support for any runtime, no-std, and no-alloc.
floop is not a replacement for select without a loop and does not need to be put inside a loop (it generates its own loop).
unlike loop select, cancel-safety doesn't matter, as futures are not cancelled when another arm finishes
(loop select requires cancel-safe futures or work arounds to make futures cancel safe, floop doesn't,
the worst part is that loop select doesn't warn you when a future is not cancel safe, it just silently causes unspecified behaviour),
futures also don't need to be fused, unpin, or have some other obscure property.
see the docs (TODO: add doc link) for details.
addtional features:
- if conditions on arms,
- if else conditions on arms,
- compile-time footgun detection (doesn't cover all footguns, see the docs for details)
- rust-analyzer friendly on errors
break, you can break individual arms usingbreak
Credits
max: the compiler-manipulation used to detect footguns is mostly copied from this blog post.
unsynn (crate): unsynn is the parser library used to implement the macro, it's great.
License
Licensed under either of:
- Apache License, Version 2.0, (LICENSE-APACHE)
- MIT license (LICENSE-MIT)
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.