Skip to content

Commit

Permalink
Derive traits for rand types
Browse files Browse the repository at this point in the history
  • Loading branch information
justinlovinger authored and mbrubeck committed Apr 1, 2023
1 parent 60c9b15 commit f14ee61
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ serde_test = "1.0"
[features]
default = ["std"]
std = ["num-traits/std"]
serde = ["dep:serde", "rand/serde1"]
randtest = ["rand/std", "rand/std_rng"]
rkyv = ["rkyv_32"]
rkyv_16 = ["dep:rkyv", "rkyv/size_16"]
Expand Down
4 changes: 4 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2021,6 +2021,8 @@ mod impl_rand {
impl_distribution! { Open01, f32, f64 }
impl_distribution! { OpenClosed01, f32, f64 }

#[derive(Clone, Copy, Debug, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct UniformNotNan<T>(UniformFloat<T>);
impl SampleUniform for NotNan<f32> {
type Sampler = UniformNotNan<f32>;
Expand All @@ -2029,6 +2031,8 @@ mod impl_rand {
type Sampler = UniformNotNan<f64>;
}

#[derive(Clone, Copy, Debug, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct UniformOrdered<T>(UniformFloat<T>);
impl SampleUniform for OrderedFloat<f32> {
type Sampler = UniformOrdered<f32>;
Expand Down

0 comments on commit f14ee61

Please sign in to comment.