diff --git a/Cargo.toml b/Cargo.toml index 78f59df..c7e3c4e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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] diff --git a/src/perf_trace.rs b/src/perf_trace.rs index 8766cb5..bca63ff 100644 --- a/src/perf_trace.rs +++ b/src/perf_trace.rs @@ -1,6 +1,6 @@ #![allow(unused_imports)] -//! This module contains macros for logging to stdout a trace of wall-clock time required -//! to execute annotated code. One can use this code as follows: +//! This module contains macros for logging to stdout a trace of wall-clock time +//! required to execute annotated code. One can use this code as follows: //! ``` //! use ark_std::{start_timer, end_timer}; //! let start = start_timer!(|| "Addition of two integers"); @@ -13,8 +13,8 @@ //! End: Addition of two integers... 1ns //! ``` //! -//! These macros can be arbitrarily nested, and the nested nature is made apparent -//! in the output. For example, the following snippet: +//! These macros can be arbitrarily nested, and the nested nature is made +//! apparent in the output. For example, the following snippet: //! ``` //! use ark_std::{start_timer, end_timer}; //! let start = start_timer!(|| "Addition of two integers"); @@ -162,7 +162,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 } diff --git a/src/rand_helper.rs b/src/rand_helper.rs index 6af19c5..296e3da 100644 --- a/src/rand_helper.rs +++ b/src/rand_helper.rs @@ -1,7 +1,7 @@ #[cfg(feature = "std")] use rand::RngCore; use rand::{ - distributions::{Distribution, Standard}, + distr::{Distribution, StandardUniform}, prelude::StdRng, Rng, }; @@ -14,11 +14,11 @@ pub trait UniformRand: Sized { impl UniformRand for T where - Standard: Distribution, + StandardUniform: Distribution, { #[inline] fn rand(rng: &mut R) -> Self { - rng.sample(Standard) + rng.sample(StandardUniform) } } @@ -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), #[cfg(any(feature = "getrandom", test))] Randomized(rand::rngs::ThreadRng), } @@ -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"))]