mirror of
https://github.com/uuid-rs/uuid.git
synced 2025-09-27 04:50:59 +00:00
fix up feature selection
This commit is contained in:
parent
406fb23317
commit
1ed9390699
10
Cargo.toml
10
Cargo.toml
@ -71,8 +71,8 @@ v8 = []
|
||||
js = ["dep:wasm-bindgen"]
|
||||
|
||||
rng = ["dep:getrandom"]
|
||||
rng-getrandom = ["rng", "dep:uuid-getrandom-internal"]
|
||||
rng-rand = ["rng-getrandom", "dep:rand"]
|
||||
rng-getrandom = ["rng", "dep:getrandom", "dep:uuid-rng-internal", "uuid-rng-internal/getrandom"]
|
||||
rng-rand = ["rng", "dep:rand", "dep:uuid-rng-internal", "uuid-rng-internal/rand"]
|
||||
|
||||
fast-rng = ["rng", "dep:rand"]
|
||||
|
||||
@ -132,9 +132,9 @@ default-features = false
|
||||
version = "0.3"
|
||||
optional = true
|
||||
|
||||
[target.'cfg(all(target_arch = "wasm32", target_vendor = "unknown", target_os = "unknown"))'.dependencies.uuid-getrandom-internal]
|
||||
[target.'cfg(all(target_arch = "wasm32", target_vendor = "unknown", target_os = "unknown"))'.dependencies.uuid-rng-internal]
|
||||
version = "1.12.1"
|
||||
path = "getrandom"
|
||||
path = "rng"
|
||||
optional = true
|
||||
|
||||
# Private
|
||||
@ -198,7 +198,7 @@ version = "1"
|
||||
[workspace]
|
||||
members = [
|
||||
"macros",
|
||||
"getrandom",
|
||||
"rng",
|
||||
"examples",
|
||||
"tests/smoke-test",
|
||||
"tests/wasm32-getrandom-test",
|
||||
|
@ -1,5 +1,5 @@
|
||||
[package]
|
||||
name = "uuid-getrandom-internal"
|
||||
name = "uuid-rng-internal"
|
||||
version = "1.12.1"
|
||||
edition = "2018"
|
||||
authors = [
|
||||
@ -19,3 +19,8 @@ license = "Apache-2.0 OR MIT"
|
||||
# Forces a dependency on `getrandom`
|
||||
[dependencies.getrandom]
|
||||
version = "0.3"
|
||||
optional = true
|
||||
|
||||
[dependencies.rand]
|
||||
version = "0.9"
|
||||
optional = true
|
@ -12,5 +12,9 @@
|
||||
|
||||
#[doc(hidden)]
|
||||
pub mod __private {
|
||||
pub use getrandom::*;
|
||||
#[cfg(feature = "getrandom")]
|
||||
pub use getrandom;
|
||||
|
||||
#[cfg(feature = "rand")]
|
||||
pub use rand;
|
||||
}
|
12
src/rng.rs
12
src/rng.rs
@ -115,15 +115,15 @@ mod imp {
|
||||
#[cfg(feature = "rng-rand")]
|
||||
impl Rng for RngImp {
|
||||
fn u128() -> u128 {
|
||||
rand::random()
|
||||
uuid_rng_internal::__private::rand::random()
|
||||
}
|
||||
|
||||
fn u64() -> u64 {
|
||||
rand::random()
|
||||
uuid_rng_internal::__private::rand::random()
|
||||
}
|
||||
|
||||
fn u16() -> u16 {
|
||||
rand::random()
|
||||
uuid_rng_internal::__private::rand::random()
|
||||
}
|
||||
}
|
||||
|
||||
@ -136,7 +136,7 @@ mod imp {
|
||||
fn u128() -> u128 {
|
||||
let mut bytes = [0u8; 16];
|
||||
|
||||
uuid_getrandom_internal::__private::fill(&mut bytes).unwrap_or_else(|err| {
|
||||
uuid_rng_internal::__private::getrandom::fill(&mut bytes).unwrap_or_else(|err| {
|
||||
// NB: getrandom::Error has no source; this is adequate display
|
||||
panic!("could not retrieve random bytes for uuid: {}", err)
|
||||
});
|
||||
@ -147,7 +147,7 @@ mod imp {
|
||||
fn u64() -> u64 {
|
||||
let mut bytes = [0u8; 8];
|
||||
|
||||
uuid_getrandom_internal::__private::fill(&mut bytes).unwrap_or_else(|err| {
|
||||
uuid_rng_internal::__private::getrandom::fill(&mut bytes).unwrap_or_else(|err| {
|
||||
// NB: getrandom::Error has no source; this is adequate display
|
||||
panic!("could not retrieve random bytes for uuid: {}", err)
|
||||
});
|
||||
@ -158,7 +158,7 @@ mod imp {
|
||||
fn u16() -> u16 {
|
||||
let mut bytes = [0u8; 2];
|
||||
|
||||
uuid_getrandom_internal::__private::fill(&mut bytes).unwrap_or_else(|err| {
|
||||
uuid_rng_internal::__private::getrandom::fill(&mut bytes).unwrap_or_else(|err| {
|
||||
// NB: getrandom::Error has no source; this is adequate display
|
||||
panic!("could not retrieve random bytes for uuid: {}", err)
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user