Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ readme = "README.md"
repository = "https://github.com/rust-random/rand_core"
documentation = "https://docs.rs/rand_core"
homepage = "https://rust-random.github.io/book"
description = """
Core random number generator traits and tools for implementation.
"""
description = "Core random number generation traits and tools for implementation."
keywords = ["random", "rng"]
categories = ["algorithms", "no-std"]
edition = "2024"
Expand Down
72 changes: 28 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,54 +1,38 @@
# rand_core
# rand_core: core random number generation traits

[![Test Status](https://github.com/rust-random/rand_core/actions/workflows/test.yml/badge.svg?event=push)](https://github.com/rust-random/rand_core/actions)
[![Latest version](https://img.shields.io/crates/v/rand_core.svg)](https://crates.io/crates/rand_core)
[![Book](https://img.shields.io/badge/book-master-yellow.svg)](https://rust-random.github.io/book/)
[![API](https://docs.rs/rand_core/badge.svg)](https://docs.rs/rand_core)
[![crate][crate-image]][crate-link]
[![Docs][docs-image]][docs-link]
![Apache2/MIT licensed][license-image]
![Rust Version][rustc-image]
[![Build Status][build-image]][build-link]

Core traits and error types of the [rand] library, plus tools for implementing
RNGs.
This crate provides a collection of traits used by implementations of Random Number Generation (RNG)
algorithms. Additionally, it includes helper utilities that assist with the implementation
of these traits.

This crate is intended for use when implementing the core trait, `RngCore`; it
defines the core traits to be implemented as well as several small functions to
aid in their implementation and types required for error handling.
Note that the traits focus solely on the core RNG functionality. Most users should prefer
the [`rand`] crate, which offers more advanced RNG capabilities built on these core traits,
such as sampling from restricted ranges, generating floating-point numbers, list permutations,
and more.

The main [rand] crate re-exports most items defined in this crate, along with
tools to convert the integer samples generated by `RngCore` to many different
applications (including sampling from restricted ranges, conversion to floating
point, list permutations and secure initialisation of RNGs). Most users should
prefer to use the main [rand] crate.
[`rand`]: https://docs.rs/rand

Links:
## License

- [API documentation (docs.rs)](https://docs.rs/rand_core)
- [Changelog](https://github.com/rust-random/rand_core/blob/master/CHANGELOG.md)
The crate is licensed under either of:

[rand]: https://crates.io/crates/rand
* [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0)
* [MIT license](http://opensource.org/licenses/MIT)

at your option.

## Functionality
[//]: # (badges)

The `rand_core` crate provides:

- base random number generator traits
- error-reporting types
- functionality to aid implementation of RNGs

The traits and error types are also available via `rand`.

## Versions

The current version is:

```toml
rand_core = "0.9.3"
```


# License

`rand_core` is distributed under the terms of both the MIT license and the
Apache License (Version 2.0).

See [LICENSE-APACHE](LICENSE-APACHE) and [LICENSE-MIT](LICENSE-MIT), and
[COPYRIGHT](COPYRIGHT) for details.
[crate-image]: https://img.shields.io/crates/v/rand_core.svg
[crate-link]: https://crates.io/crates/rand_core
[docs-image]: https://docs.rs/rand_core/badge.svg
[docs-link]: https://docs.rs/rand_core
[license-image]: https://img.shields.io/badge/license-Apache2.0/MIT-blue.svg
[rustc-image]: https://img.shields.io/badge/rustc-1.85+-blue.svg
[build-image]: https://github.com/rust-random/rand_core/actions/workflows/test.yml/badge.svg?branch=master
[build-link]: https://github.com/rust-random/rand_core/actions/workflows/test.yml?query=branch:master
29 changes: 7 additions & 22 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,31 +1,16 @@
//! Random number generation traits
//!
//! This crate is mainly of interest to crates publishing implementations of
//! [`RngCore`]. Other users are encouraged to use the [`rand`] crate instead
//! which re-exports the main traits and error types.
//!
//! [`RngCore`] is the core trait implemented by algorithmic pseudo-random number
//! generators and external random-number sources.
//!
//! [`SeedableRng`] is an extension trait for construction from fixed seeds and
//! other random number generators.
//!
//! The [`le`] sub-module includes a few small functions to assist
//! implementation of [`RngCore`] and [`SeedableRng`].
//!
//! [`rand`]: https://docs.rs/rand

#![no_std]
#![doc = include_str!("../README.md")]
#![doc(
html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk.png",
html_favicon_url = "https://www.rust-lang.org/favicon.ico",
html_root_url = "https://rust-random.github.io/rand/"
)]
#![deny(missing_docs)]
#![deny(missing_debug_implementations)]
#![deny(clippy::undocumented_unsafe_blocks)]
#![doc(test(attr(allow(unused_variables), deny(warnings))))]
#![cfg_attr(docsrs, feature(doc_cfg))]
#![no_std]
#![deny(
missing_docs,
missing_debug_implementations,
clippy::undocumented_unsafe_blocks
)]

use core::{fmt, ops::DerefMut};

Expand Down