Skip to content

Commit

Permalink
Merge pull request #38 from Bluefinger/housekeeping
Browse files Browse the repository at this point in the history
fix: no-std feature housekeeping
  • Loading branch information
Bluefinger authored Feb 24, 2024
2 parents a6abff2 + 2ed59a3 commit 3bc3e30
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 9 deletions.
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

0 comments on commit 3bc3e30

Please sign in to comment.