matched_enums 1.3.0

A macro that provides the option to bin enum attribute to match-statements. This makes it easier to convert values into enums.
Documentation
use rstest::rstest;

use crate::Matched;

const EPSILON: f32 = f32::EPSILON;
const EPSILON_NEG: f32 = -EPSILON;

#[derive(Matched, PartialEq, Debug)]
#[matched_enum(value_type=f32)]
enum Signature {
    #[matches(EPSILON..)]
    Positive,

    #[matches(..=EPSILON_NEG)]
    Negative,

    #[matches(_)]
    Zero,
}

#[rstest]
#[case(0.0, Signature::Zero)]
#[case(10.5, Signature::Positive)]
#[case(-4023.0, Signature::Negative)]
#[case(f32::INFINITY, Signature::Positive)]
#[case(f32::NEG_INFINITY, Signature::Negative)]
#[case(f32::NAN, Signature::Zero)]
#[case(f32::MIN_POSITIVE, Signature::Zero)] // Value is <= EPSILON; thus, zero.
#[case(f32::MIN, Signature::Negative)]
pub fn get_signature_from_value(#[case] input: f32, #[case] expected: Signature) {
    assert_eq!(Signature::from(input), expected);
}