Crates.io | float-derive |
lib.rs | float-derive |
version | 0.1.0 |
source | src |
created_at | 2022-10-29 16:43:24.062411 |
updated_at | 2022-10-29 16:43:24.062411 |
description | A crate that allows deriving Eq and Hash for types that contain floating points |
homepage | https://github.com/projectkml/float-derive |
repository | https://github.com/projectkml/float-derive |
max_upload_size | |
id | 701092 |
size | 3,975 |
[dependencies]
float-derive = "0.1.0"
This crate allows to derive Eq
and Hash
for traits that contain floating points by explicitly comparing floating points such that: NAN == NAN is true.
use float_derive::{FloatPartialEq, FloatEq, FloatHash};
#[derive(FloatPartialEq, FloatEq, FloatHash)]
struct MyStruct {
a: i32,
b: i32,
my_float: f32,
my_second_float: f64
}
#[derive(FloatPartialEq, FloatEq, FloatHash)]
enum MyEnum {
A(i32, f32),
B { a: i32, b: f64 },
C
}