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

Rust
48%
MIT

Meetily

AI Assistants · Productivity

32,103

Privacy-first AI meeting assistant that transcribes and summarizes your meetings entirely on your local machine — no cloud, no data leakage.

View details
87
Repo Health
72
Technical
67
Dependency
Built with
Rust 48%
TypeScript 29%
Updated 1 weeks ago
Rust
100%
Other

Meilisearch

Search

59,644

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

View details
90
Repo Health
88
Technical
67
Dependency
Built with
Rust 100%
Updated 1 weeks ago
TypeScript
95%
MIT

melty

AI Code Assistants · Code Editors · Developer Tools

5,462

The AI code editor where every chat message is a git commit you can revert, branch, or squash

View details
35
Repo Health
75
Technical
67
Dependency
Built with
TypeScript 95%
Updated 1 years ago
Rust
86%
Apache 2.0

mesh-llm

AI Agents · AI Development

3,551

Mesh LLM pools GPUs and memory across every machine you own into one OpenAI-compatible API, so agents tap distributed compute instead of a single GPU box or a metered cloud bill.

View details
85
Repo Health
91
Technical
69
Dependency
Built with
Rust 86%
TypeScript 10%
Updated 6 days ago
Rust
43%
BSD 3

MicroBin

File Storage

4,622

A self-contained, encrypted paste bin and file-sharing app in Rust with animal-name URLs, burn-after-read, and one-command Docker deployment.

View details
53
Repo Health
67
Technical
71
Dependency
Built with
Rust 43%
HTML 28%
JavaScript 20%
Updated 1 months ago
Rust
93%
Apache 2.0

Murr

Databases

117

A RocksDB-based NVMe/S3 cache purpose-built for AI inference workloads — a faster Redis replacement optimized for batch, low-latency, zero-copy reads and writes between data pipelines and inference apps.

View details
73
Repo Health
72
Technical
75
Dependency
Built with
Rust 93%
Updated 1 weeks ago
Rust
97%
Apache 2.0

codex

AI Code Assistants · Developer Tools

130,715

OpenAI's open-source CLI coding agent that reads, edits, and runs code in your terminal using natural language prompts.

View details
89
Repo Health
80
Technical
75
Dependency
Built with
Rust 97%
Updated 1 weeks ago
Rust
59%
GPL 3.0

openfootmanager

Game Development

1,161

A free and open source football management simulation game built with Rust and Tauri, inspired by Football Manager.

View details
94
Repo Health
79
Technical
73
Dependency
Built with
Rust 59%
TypeScript 40%
Updated 1 weeks ago
Rust
87%
Apache 2.0

OpenShell

AI Agents · Developer Tools

18,930

The safe, private runtime that lets autonomous AI agents operate in sandboxed environments governed by declarative YAML policies — blocking data exfiltration, credential leaks, and unauthorized network activity before they happen.

View details
84
Repo Health
81
Technical
67
Dependency
Built with
Rust 87%
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