rand

The de facto standard random number generation library for Rust.

Library
Cargo
v0.10.3
2,089 stars
MIT OR Apache-2.0

Repository Health

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

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
92 /100 Excellent
Architecture 92
Code Quality 93
Innovation 94
Learning Curve 85

Rand is a Rust library for random number generation, providing a trait-based foundation for pseudo-random and cryptographically-secure generators alongside a rich toolkit for sampling values, ranges, distributions, and sequences. Built on the rand_core RngCore trait, it ships fast, automatically-seeded generators such as ThreadRng and StdRng plus small PRNGs, and layers on ergonomic helpers like rand::random() and random_range().

It supports uniform and non-uniform distributions, weighted sampling, shuffling and choosing from slices, and portable reproducible output, with #[no_std] compatibility and optional Serde support. Rand is the most widely adopted randomness crate in the Rust ecosystem, downloaded well over a billion times.

What You Get

  • Automatically-seeded, reasonably strong generators (ThreadRng, StdRng) plus fast small PRNGs, all built over the rand_core RngCore trait
  • Uniform and ranged value sampling via StandardUniform and Uniform, plus a large set of non-uniform distributions
  • Sequence utilities for shuffling, choosing, and weighted selection from slices and iterators
  • no_std compatibility, optional Serde support, and portably reproducible output for deterministic use cases

Common Use Cases

  • Generating random numbers, booleans, and values of common types with a single rand::random() call
  • Sampling from a numeric range or a statistical distribution for simulations and Monte Carlo methods
  • Shuffling collections or picking random and weighted elements from slices in games, tests, and tooling

Under The Hood

Architecture

Rand is layered on top of the separate rand_core crate, which defines the RngCore, Rng, and SeedableRng traits re-exported from src/lib.rs. The crate is organized into focused modules: src/rngs/ supplies concrete generators (StdRng backed by ChaCha in std.rs, ThreadRng in thread.rs, SmallRng and the xoshiro128/256++ PRNGs), src/distr/ holds the sampling layer (StandardUniform, Uniform with per-type uniform_int/uniform_float back-ends, Bernoulli, and weighted indices), and src/seq/ implements sequence operations like shuffle and choose via a coin-flipper and increasing-uniform index sampler. Top-level convenience functions (rand::random, random_range, rng) in src/rng.rs and a prelude tie the layers together for ergonomic use.

Tech Stack

Written in Rust on the 2024 edition with an MSRV of 1.85, the crate is #[no_std] by default with alloc and std opt-in feature layers. Runtime dependencies are minimal: rand_core for the trait foundation, chacha20 for the cryptographic StdRng, and getrandom for OS entropy seeding, with serde available behind a feature. A granular feature matrix (std_rng, sys_rng, thread_rng, chacha, simd_support, unbiased) lets consumers trade functionality against footprint. Building and testing use standard Cargo, with dev-dependencies including rand_pcg, rayon, and serde_json.

Code Quality

Code quality is high and correctness-focused. The crate enforces #![deny(missing_docs)], missing_debug_implementations, and undocumented_unsafe_blocks, and carries roughly 107 unit-test functions across ~20 files plus integration tests (tests/fill.rs), doctests on public APIs, and a dedicated benches/ suite. A clippy.toml and CI workflows back consistent linting. Naming follows idiomatic Rust conventions and unsafe blocks are documented, reflecting the project’s stated priority of correctness and speed over simplicity.

API Design

The public API is deliberately ergonomic: newcomers can call rand::random() or rand::random_range(a..b) with zero setup, while power users compose over the Rng trait and explicit generators. A prelude module surfaces the common imports, distributions read fluently (Uniform::new, StandardUniform), and sequence helpers hang off iterator/slice extension traits. Documentation is exceptional, spanning inline docs enforced by deny(missing_docs), published docs.rs reference, and the dedicated Rust Rand Book with a quick-start guide, which keeps the learning curve manageable despite the domain’s inherent depth.

Used by 46 apps in this directory

TypeScript
68%
MIT

Hoppscotch

Developer Tools

80,676

A lightweight, offline-capable API development ecosystem for testing HTTP, GraphQL, WebSocket, MQTT, and SSE endpoints across web, desktop, and CLI.

View details
91
Repo Health
83
Technical
62
Dependency
Built with
TypeScript 68%
Vue 24%
Updated 1 weeks ago
TypeScript
62%
EPL-2.0

Huly Platform

Collaboration · Project Management · Team Chat

27,978

Open-source all-in-one workspace that replaces Linear, Jira, Slack, and Notion for product and engineering teams.

View details
90
Repo Health
86
Technical
62
Dependency
Built with
TypeScript 62%
Svelte 34%
Updated 1 weeks ago
Rust
72%
Other

iii

Developer Tools · Devops

18,854

Compose, extend, and observe every backend service in real time using three primitives: Workers, Functions, and Triggers.

View details
87
Repo Health
85
Technical
65
Dependency
Built with
Rust 72%
TypeScript 16%
Updated 1 weeks ago
Rust
96%
Apache 2.0

InfluxDB

Analytics · Databases

31,779

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
80
Repo Health
76
Technical
72
Dependency
Built with
Rust 96%
Updated 1 weeks ago
Rust
56%
Other

Jan

AI Assistants

45,052

Run LLMs 100% locally with full privacy, or connect to cloud AI — your machine, your data, your control.

View details
90
Repo Health
81
Technical
65
Dependency
Built with
Rust 56%
TypeScript 40%
Updated 6 days ago
TypeScript
63%
Apache 2.0

Laminar

AI Development · Monitoring

3,434

Open-source observability platform purpose-built for AI agents — trace, evaluate, debug, and monitor at scale with SQL access and real-time replay.

View details
86
Repo Health
76
Technical
65
Dependency
Built with
TypeScript 63%
Rust 35%
Updated 6 days ago
TypeScript
78%
LGPL 3.0

Latitude

AI Agents · Monitoring

4,733

Open-source AI agent monitoring that catches what will break next before your users do.

View details
87
Repo Health
88
Technical
67
Dependency
Built with
TypeScript 78%
Python 11%
Rust 11%
Updated 1 weeks ago
Dart
79%
Apache 2.0

LocalSend

Networking

95,370

An open-source, cross-platform AirDrop alternative that sends files and messages device-to-device over your local network with no internet, no account, and no cloud server involved.

View details
88
Repo Health
61
Technical
78
Dependency
Built with
Dart 79%
Rust 17%
Updated 1 weeks ago
JavaScript
55%
Other

Lokus

Knowledge Management · Note Taking

829

Local-first note-taking with graph view, canvas & AI plugins—your Markdown files, zero telemetry, blazing-fast Rust performance.

View details
75
Repo Health
75
Technical
64
Dependency
Built with
JavaScript 55%
HTML 21%
Rust 12%
Updated 2 months 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