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

Add support for forced custom implementation #269

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions Cargo.toml
Expand Up @@ -38,6 +38,8 @@ rdrand = []
js = ["wasm-bindgen", "js-sys"]
# Feature to enable custom RNG implementations
custom = []
# Feature to force usage of custom RNG implementation
force-custom = []
# Unstable feature to support being a libstd dependency
rustc-dep-of-std = [
"compiler_builtins",
Expand Down
6 changes: 4 additions & 2 deletions src/lib.rs
Expand Up @@ -162,7 +162,7 @@ mod error;
mod util;
// To prevent a breaking change when targets are added, we always export the
// register_custom_getrandom macro, so old Custom RNG crates continue to build.
#[cfg(feature = "custom")]
#[cfg(any(feature = "custom", feature = "force-custom"))]
mod custom;
#[cfg(feature = "std")]
mod error_impls;
Expand All @@ -173,7 +173,9 @@ pub use crate::error::Error;
//
// These should all provide getrandom_inner with the same signature as getrandom.
cfg_if! {
if #[cfg(any(target_os = "emscripten", target_os = "haiku",
if #[cfg(feature = "force-custom")] {
use custom as imp;
} else if #[cfg(any(target_os = "emscripten", target_os = "haiku",
target_os = "redox"))] {
mod util_libc;
#[path = "use_file.rs"] mod imp;
Expand Down