rand

The de facto standard random number generation library for Rust.

Library
Cargo
v0.9.5
2,066stars
MIT OR Apache-2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
83/100Excellent
Development Activity88
Maintenance64
Community80
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
92/100Excellent
Architecture92
Code Quality93
Innovation94
Learning Curve85

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 42 apps in this directory

TypeScript
51%
MIT

Anarlog

Note Taking · AI Assistants · Productivity

9,087

Anarlog is an open-source, local-first AI meeting notetaker that records, transcribes, and summarizes meetings entirely on your device — no cloud lock-in, no mandatory account, and every note saved as a plain markdown file you own forever.

View details
86
Repo Health
77
Technical
69
Dependency
Built with
TypeScript51%
Rust38%
Updated today
Dart
74%
AGPL 3.0

AppFlowy

Productivity · Project Management · Collaboration

75,729

The open-source AI workspace that puts your data, your rules — with local LLMs, CRDT collaboration, and full self-hosting built in.

View details
66
Repo Health
81
Technical
66
Dependency
Built with
Dart74%
Rust24%
Updated 1 weeks ago
TypeScript
55%
Other

Cap

Team Chat · Video Conferencing

20,986

Open source Loom alternative with GPU-accelerated recording, instant share links, AI summaries, and full self-hosting via Docker Compose.

View details
89
Repo Health
81
Technical
65
Dependency
Built with
TypeScript55%
Rust40%
Updated yesterday
Rust
52%
Apache 2.0

cocoindex

Data Engineering · AI Development

11,350

An incremental data indexing engine that keeps AI agent context perpetually fresh by reprocessing only what changed.

View details
87
Repo Health
85
Technical
64
Dependency
Built with
Rust52%
Python48%
Updated yesterday
TypeScript
84%
Apache 2.0

Continue

Developer Tools · AI Development · AI Code Assistants

35,532

Open-source coding agent for VS Code, JetBrains, and CLI with support for 30+ LLM providers.

View details
87
Repo Health
88
Technical
65
Dependency
Built with
TypeScript84%
Updated today
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
95%
MIT

Fyrox

Game Development

9,512

A production-ready 2D/3D game engine written in Rust with a built-in scene editor, physics, and hot-reloading game scripts

View details
85
Repo Health
79
Technical
68
Dependency
Built with
Rust95%
Updated yesterday
Rust
50%
Other

hoodik

File Storage · Security

1,446

Self-hosted, end-to-end encrypted cloud storage with browser-based encryption and S3-compatible storage support

View details
74
Repo Health
71
Technical
65
Dependency
Built with
Rust50%
TypeScript33%
Vue15%
Updated 4 days ago
Rust
41%
Other

Hook0

Devops

1,477

Open-source Webhooks-as-a-Service: deliver events to your users with auto-retry, signed payloads, and a real-time subscriber dashboard — all without building the infrastructure yourself.

View details
83
Repo Health
82
Technical
70
Dependency
Built with
Rust41%
TypeScript17%
JavaScript15%
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