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
16 changes: 8 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
[package]
name = "ark-std"
version = "0.5.0"
authors = [ "arkworks contributors" ]
authors = ["arkworks contributors"]
description = "A library for no_std compatibility"
homepage = "https://arkworks.rs"
repository = "https://github.com/arkworks-rs/std"
documentation = "https://docs.rs/ark-std/"
keywords = [ "no_std" ]
keywords = ["no_std"]
categories = ["cryptography"]
include = ["Cargo.toml", "src", "README.md", "LICENSE-APACHE", "LICENSE-MIT"]
license = "MIT/Apache-2.0"
edition = "2021"

[dependencies]
rand = { version = "0.8", default-features = false, features = ["std_rng"]}
rand = { version = "0.9", default-features = false, features = ["std_rng"] }
rayon = { version = "1", optional = true }
colored = { version = "2", optional = true }
colored = { version = "3", optional = true }
num-traits = { version = "0.2", default-features = false }

[dev-dependencies]
rand = { version = "0.8", features = ["std"]}
rand = { version = "0.9", features = ["std"] }


[features]
default = [ "std" ]
default = ["std"]
std = []
parallel = [ "rayon", "std" ]
print-trace = [ "std", "colored" ]
parallel = ["rayon", "std"]
print-trace = ["std", "colored"]
getrandom = ["rand/std"]

[profile.bench]
Expand Down
2 changes: 1 addition & 1 deletion src/perf_trace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ pub mod inner {
pub fn compute_indent_whitespace(indent_amount: usize) -> String {
let mut indent = String::new();
for _ in 0..indent_amount {
indent.push_str(" ");
indent.push(' ');
}
indent
}
Expand Down
23 changes: 7 additions & 16 deletions src/rand_helper.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#[cfg(feature = "std")]
use rand::RngCore;
use rand::{
distributions::{Distribution, Standard},
distr::{Distribution, StandardUniform},
prelude::StdRng,
Rng,
};
Expand All @@ -14,11 +14,11 @@ pub trait UniformRand: Sized {

impl<T> UniformRand for T
where
Standard: Distribution<T>,
StandardUniform: Distribution<T>,
{
#[inline]
fn rand<R: Rng + ?Sized>(rng: &mut R) -> Self {
rng.sample(Standard)
rng.sample(StandardUniform)
}
}

Expand Down Expand Up @@ -46,21 +46,21 @@ pub fn test_rng() -> impl rand::Rng {
let is_deterministic =
std::env::vars().any(|(key, val)| key == "DETERMINISTIC_TEST_RNG" && val == "1");
if is_deterministic {
RngWrapper::Deterministic(test_rng_helper())
RngWrapper::Deterministic(Box::new(test_rng_helper()))
} else {
RngWrapper::Randomized(rand::thread_rng())
RngWrapper::Randomized(rand::rng())
}
}
#[cfg(not(any(feature = "getrandom", test)))]
{
RngWrapper::Deterministic(test_rng_helper())
RngWrapper::Deterministic(Box::new(test_rng_helper()))
}
}

/// Helper wrapper to enable `test_rng` to return `impl::Rng`.
#[cfg(feature = "std")]
enum RngWrapper {
Deterministic(StdRng),
Deterministic(Box<StdRng>),
#[cfg(any(feature = "getrandom", test))]
Randomized(rand::rngs::ThreadRng),
}
Expand Down Expand Up @@ -93,15 +93,6 @@ impl RngCore for RngWrapper {
Self::Randomized(rng) => rng.fill_bytes(dest),
}
}

#[inline(always)]
fn try_fill_bytes(&mut self, dest: &mut [u8]) -> Result<(), rand::Error> {
match self {
Self::Deterministic(rng) => rng.try_fill_bytes(dest),
#[cfg(any(feature = "getrandom", test))]
Self::Randomized(rng) => rng.try_fill_bytes(dest),
}
}
}

#[cfg(all(test, feature = "std"))]
Expand Down