Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: no-std feature housekeeping #38

Merged
merged 1 commit into from
Feb 24, 2024
Merged
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
5 changes: 4 additions & 1 deletion src/internal/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,12 @@ mod tests {
assert_eq!(state.get(), 11);
}

#[cfg(feature = "fmt")]
#[cfg(all(feature = "fmt", feature = "alloc"))]
#[test]
fn cell_state_no_leaking_debug() {
#[cfg(all(feature = "alloc", not(feature = "std")))]
use alloc::format;

let state = CellState::with_seed(Default::default());

assert_eq!(format!("{state:?}"), "CellState");
Expand Down
6 changes: 3 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
//!
//! Generate a random value:
//!
//! ```
//! ```ignore
//! use turborand::prelude::*;
//!
//! let rand = Rng::new();
Expand All @@ -20,7 +20,7 @@
//!
//! Sample a value from a list:
//!
//! ```
//! ```ignore
//! use turborand::prelude::*;
//!
//! let rand = Rng::new();
Expand All @@ -32,7 +32,7 @@
//!
//! Generate a vector with random values:
//!
//! ```
//! ```ignore
//! use turborand::prelude::*;
//! use std::iter::repeat_with;
//!
Expand Down
5 changes: 4 additions & 1 deletion src/rng.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,12 @@ mod tests {

use super::*;

#[cfg(feature = "fmt")]
#[cfg(all(feature = "fmt", feature = "alloc"))]
#[test]
fn rng_no_leaking_debug() {
#[cfg(all(feature = "alloc", not(feature = "std")))]
use alloc::format;

let rng = Rng::with_seed(Default::default());

assert_eq!(format!("{rng:?}"), "Rng(WyRand(CellState))");
Expand Down
5 changes: 4 additions & 1 deletion src/source/wyrand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,12 @@ mod tests {
);
}

#[cfg(feature = "fmt")]
#[cfg(all(feature = "fmt", feature = "alloc"))]
#[test]
fn no_leaking_debug() {
#[cfg(all(feature = "alloc", not(feature = "std")))]
use alloc::format;

let rng = WyRand::<CellState>::with_seed(Default::default());

assert_eq!(format!("{rng:?}"), "WyRand(CellState)");
Expand Down
4 changes: 2 additions & 2 deletions src/traits.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use core::ops::{Bound, RangeBounds};

#[cfg(feature = "alloc")]
#[cfg(all(feature = "alloc", not(feature = "std")))]
use alloc::{boxed::Box, vec::Vec};

use crate::internal::uniform::IncreasingUniformIter;
Expand Down Expand Up @@ -1047,7 +1047,7 @@ mod tests {
const GEN_KIND: TurboKind = TurboKind::FAST;

fn gen<const SIZE: usize>(&self) -> [u8; SIZE] {
std::array::from_fn(|_| self.next())
core::array::from_fn(|_| self.next())
}
}

Expand Down
2 changes: 2 additions & 0 deletions tests/smoke/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,8 @@ fn small_range_smoke_testing() {
#[test]
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)]
fn unbounded_range_smoke_testing() {
use std::ops::RangeBounds;

let rng = Rng::default();

for _ in 0..1000 {
Expand Down
2 changes: 1 addition & 1 deletion tests/suite.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{iter::repeat_with, ops::RangeBounds};
use std::iter::repeat_with;

use std::collections::BTreeMap;

Expand Down
Loading