sfc_prng/lib.rs
1// SPDX-FileCopyrightText: 2025 Shun Sakai
2//
3// SPDX-License-Identifier: Apache-2.0 OR MIT
4
5//! The `sfc-prng` crate is an implementation of [Chris Doty-Humphrey's Small
6//! Fast Counting PRNGs].
7//!
8//! The SFC algorithms are not suitable for cryptographic uses but are very
9//! fast.
10//!
11//! This crate provides:
12//!
13//! - [ ] sfc16
14//! - [x] sfc32
15//! - [x] sfc64
16//!
17//! The sfc32 algorithm is implemented as [`Sfc32`], and the sfc64 algorithm is
18//! implemented as [`Sfc64`].
19//!
20//! This crate supports version 4 of the SFC algorithms.
21//!
22//! # Examples
23//!
24//! ```
25//! use sfc_prng::{
26//! Sfc64,
27//! rand_core::{RngCore, SeedableRng},
28//! };
29//!
30//! let mut rng = Sfc64::seed_from_u64(0);
31//! let x = rng.next_u64();
32//! assert_eq!(x, 0xd396_d4b3_98b6_c85d);
33//! ```
34//!
35//! [Chris Doty-Humphrey's Small Fast Counting PRNGs]: https://pracrand.sourceforge.net/RNG_engines.txt
36
37#![doc(html_root_url = "https://docs.rs/sfc-prng/0.3.0/")]
38#![no_std]
39#![cfg_attr(docsrs, feature(doc_cfg))]
40// Lint levels of rustc.
41#![deny(missing_docs)]
42
43#[cfg(test)]
44#[macro_use]
45extern crate alloc;
46
47mod sfc32;
48mod sfc64;
49
50pub use rand_core;
51
52pub use crate::{sfc32::Sfc32, sfc64::Sfc64};