floop 0.3.2

A more convenient and less error prone replacement for loop `{ select! { .. }}`
Documentation
use std::{future::ready, time::Duration};

use floop::floop;
use smol::{Timer, block_on};

#[test]
fn break_() {
    let future = floop! {
        biased
        val in ready(2) => {
            break val;
        }
        val in ready(5) => {
            break val;
        }
    };

    let result = block_on(future);

    assert_eq!(result, (2, 5));
}

#[test]
fn break_complex() {
    let mut counter = 10;
    let mut collatz = 77031;
    
    // the collatz conjecture should result in the ordering of the 2 branches being chaotic.
    let future = floop! {
        biased
        _ in Timer::after(Duration::from_millis(counter))=> {
            if collatz == 1 {
                break;
            } else if collatz % 2 == 0 {
                collatz /= 2;
            } else {
                collatz = collatz * 3 + 1;
            }
        }
        _ in Timer::after(Duration::from_micros(collatz / 5)) => {
            if counter == 0 {
                break;
            }

            counter -= 1;
        }
    };

    block_on(future);

    assert_eq!(counter, 0);
    assert_eq!(collatz, 1);
}

#[test]
fn break_no_copy() {
    struct NoCopy;

    let future = floop! {
        biased
        _ in ready(()) => {
            break NoCopy;
        }
        _ in ready(()) => break,
    };

    block_on(future);
}