mirror of
https://github.com/bevyengine/bevy
synced 2024-11-22 20:53:53 +00:00
Document That FloatOrd Implements Hash and Eq Too (#5228)
# Objective - Slight documentation tweak to make it more clear that `FloatOrd` also implements `Hash` and `Eq`, not just `Ord`. - I know that it does show that Hash is implemented in the docs, but I had missed it after reading the description and assuming it didn't do it, so hopefully this helps other people who might miss it like I did. :) ## Solution - Just mention in the Hash and Eq implementation in the docstring.
This commit is contained in:
parent
9b6253b769
commit
81bb4ef300
1 changed files with 9 additions and 3 deletions
|
@ -4,9 +4,15 @@ use std::{
|
|||
ops::Neg,
|
||||
};
|
||||
|
||||
/// A wrapper type that enables ordering floats. This is a work around for the famous "rust float
|
||||
/// ordering" problem. By using it, you acknowledge that sorting NaN is undefined according to spec.
|
||||
/// This implementation treats NaN as the "smallest" float.
|
||||
/// A wrapper for floats that implements [`Ord`], [`Eq`], and [`Hash`] traits.
|
||||
///
|
||||
/// This is a work around for the fact that the IEEE 754-2008 standard,
|
||||
/// implemented by Rust's [`f32`] type,
|
||||
/// doesn't define an ordering for [`NaN`](f32::NAN),
|
||||
/// and `NaN` is not considered equal to any other `NaN`.
|
||||
///
|
||||
/// Wrapping a float with `FloatOrd` breaks conformance with the standard
|
||||
/// by sorting `NaN` as less than all other numbers and equal to any other `NaN`.
|
||||
#[derive(Debug, Copy, Clone, PartialOrd)]
|
||||
pub struct FloatOrd(pub f32);
|
||||
|
||||
|
|
Loading…
Reference in a new issue