ordered-float

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

Library
Cargo
v5.3.0
333stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
65/100Good
Development Activity60
Maintenance40
Community80
Maturity60
Momentum20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
76/100Good
Architecture78
Code Quality82
Innovation60
Learning Curve85

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

Data Engineering · Analytics

5,005

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
Rust86%
Updated 1 weeks ago
TypeScript
75%
Apache 2.0

Fern

Developer Tools

3,761

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
67
Dependency
Built with
TypeScript75%
Updated today
Rust
96%
Apache 2.0

InfluxDB

Databases · Analytics

31,705

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
86
Repo Health
76
Technical
72
Dependency
Built with
Rust96%
Updated yesterday
Rust
84%
Apache 2.0

liteparse

Developer Tools

12,123

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
83
Repo Health
80
Technical
74
Dependency
Built with
Rust84%
Updated today
Rust
100%
Other

Meilisearch

Search

59,012

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

View details
90
Repo Health
88
Technical
68
Dependency
Built with
Rust100%
Updated 5 days ago
Rust
87%
AGPL 3.0

ParadeDB

Search · Databases · Analytics

9,175

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
88
Repo Health
87
Technical
71
Dependency
Built with
Rust87%
PLpgSQL12%
Updated today
Python
55%
Other

PostHog

Analytics · Monitoring · Developer Tools

37,777

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
67
Dependency
Built with
Python55%
TypeScript36%
Updated today
Rust
98%
Apache 2.0

Volga

Data Engineering

158

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
Rust98%
Updated today

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

Search