ordered-float

Wrapper types that give Rust's IEEE-754 floats a total ordering for sorting and hashing

Library
Cargo
v5.5.0
341 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
71 /100 Good
Development Activity 60
Maintenance 64
Community 80
Maturity 60
Momentum 20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
76 /100 Good
Architecture 78
Code Quality 82
Innovation 60
Learning Curve 85

ordered-float provides OrderedFloat and NotNan wrapper types that implement Ord, Eq, and Hash for floating-point numbers, which Rust’s native f32/f64 types cannot do because of NaN’s IEEE-754 comparison semantics. This lets floats be used as keys in BTreeMap/HashMap, sorted with the standard library’s sort functions, and compared with <, ==, and friends without runtime panics or partial-ordering workarounds.

What You Get

  • OrderedFloat<T> giving any float type a total order (NaN sorts consistently rather than being incomparable)
  • NotNan<T> which enforces at construction time that the wrapped value is never NaN, returning a Result otherwise
  • Hash implementations for both wrapper types, enabling floats as HashMap/HashSet keys
  • Optional integrations behind feature flags for serde, rand, arbitrary, bytemuck, rkyv, schemars, and proptest
  • no_std support via the libm feature for embedded and constrained environments

Common Use Cases

  • Sorting a Vec<f64> of scores, prices, or measurements without a custom comparator
  • Using floating-point values as keys in a BTreeMap or HashMap (e.g. for a priority queue keyed by a float weight)
  • Guaranteeing at the type level that a float field can never be NaN via NotNan
  • Serializing/deserializing float-keyed collections with serde in scientific or numerical Rust codebases

Under The Hood

Architecture - The crate is a single lib.rs module (~3000 lines including tests) defining two core newtypes, OrderedFloat<T> and NotNan<T>, each implementing Ord/Eq/Hash by treating NaN as a well-defined sort position rather than propagating IEEE-754’s incomparability, with NotNan additionally enforcing a construction-time invariant via Result-returning constructors. Tech Stack - Pure Rust, no_std-compatible (with an optional libm feature for math without the standard library), depending only on num-traits by default, with a long list of optional integration crates (serde, rand, arbitrary, bytemuck, rkyv, rkyv_08, schemars, speedy, derive-visitor) gated behind Cargo feature flags to keep the default dependency footprint minimal. Code Quality - The tests/ directory and inline unit tests cover both wrapper types, NaN edge cases, and each optional feature integration individually (e.g. serde round-tripping, proptest-based property tests), with rustfmt.toml enforcing consistent formatting across the small codebase. API Design - The API surface is deliberately minimal and idiomatic: both types implement the standard comparison/hash traits so they slot into existing generic code (sorted collections, hash maps) with zero special-casing, and NotNan::new() returning Result<Self, FloatIsNan> follows Rust’s fallible-construction convention rather than panicking.

Used by 8 apps in this directory

Rust
86%
Other

Arroyo

Analytics · Data Engineering

5,039

A distributed stream processing engine written in Rust that lets you write SQL to run stateful, real-time computations over data streams with subsecond results.

View details
86
Repo Health
74
Technical
62
Dependency
Built with
Rust 86%
Updated 1 weeks ago
TypeScript
75%
Apache 2.0

Fern

Developer Tools

3,787

Fern turns a single OpenAPI, AsyncAPI, or Protobuf definition into type-safe SDKs for nine languages and a hosted API documentation site, all from one CLI and one source of truth.

View details
90
Repo Health
86
Technical
66
Dependency
Built with
TypeScript 75%
Updated 5 days ago
Rust
96%
Apache 2.0

InfluxDB

Analytics · Databases

31,758

Open-source time-series database built for real-time ingest, fast SQL queries, and embedded Python automation — powered by Apache Arrow and Parquet.

View details
82
Repo Health
76
Technical
72
Dependency
Built with
Rust 96%
Updated 1 weeks ago
Rust
84%
Apache 2.0

liteparse

Developer Tools

12,682

A fast, lightweight, open-source document parser that extracts spatial text, bounding boxes, and Markdown from PDFs and Office files — entirely on your machine.

View details
82
Repo Health
80
Technical
74
Dependency
Built with
Rust 84%
Updated 1 weeks ago
Rust
100%
Other

Meilisearch

Search

59,424

Lightning-fast hybrid search engine with AI-powered semantic and full-text retrieval for modern applications.

View details
89
Repo Health
88
Technical
68
Dependency
Built with
Rust 100%
Updated 1 weeks ago
Rust
86%
AGPL 3.0

ParadeDB

Analytics · Databases · Search

9,311

Born out of Y Combinator's S2023 batch, ParadeDB is a Postgres extension that delivers Elasticsearch-quality BM25 search and real-time analytics without a separate search cluster to manage.

View details
89
Repo Health
87
Technical
68
Dependency
Built with
Rust 86%
PLpgSQL 14%
Updated 5 days ago
Python
55%
Other

PostHog

Ab Testing Experimentation · Analytics · Developer Tools

39,975

The all-in-one open source product platform combining analytics, session replay, feature flags, error tracking, AI observability, and a built-in data warehouse in a single self-hostable stack.

View details
92
Repo Health
80
Technical
65
Dependency
Built with
Python 55%
TypeScript 36%
Updated 5 days ago
Rust
97%
Apache 2.0

Volga

Data Engineering

161

A Rust-based real-time data processing engine for AI/ML feature computation, built on Apache DataFusion and Arrow — positioned as an alternative to Flink, Spark, Chronon, and OpenMLDB with unified streaming, batch, and request-time execution.

View details
67
Repo Health
67
Technical
72
Dependency
Built with
Rust 97%
Updated 6 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers