Skip to content

Commit

Permalink
cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
cksac committed Aug 17, 2023
1 parent 9cb37b5 commit 880e0b7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion fake/src/impls/glam/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use glam::{Mat4, Vec2, Vec3, Vec4};
use crate::{Dummy, Fake, Faker};
use glam::{Mat4, Vec2, Vec3, Vec4};

impl Dummy<Faker> for Mat4 {
fn dummy_with_rng<R: rand::Rng + ?Sized>(_f: &Faker, rng: &mut R) -> Self {
Expand Down
4 changes: 2 additions & 2 deletions fake/src/impls/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ pub mod color;
pub mod decimal;
#[cfg(feature = "geo-types")]
pub mod geo;
#[cfg(feature = "glam")]
pub mod glam;
#[cfg(feature = "http")]
pub mod http;
#[cfg(feature = "semver")]
Expand All @@ -25,5 +27,3 @@ pub mod time;
pub mod uuid;
#[cfg(feature = "zerocopy")]
pub mod zerocopy_byteorder;
#[cfg(feature = "glam")]
pub mod glam;
17 changes: 8 additions & 9 deletions fake/src/impls/std/num.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
use crate::{Dummy, Faker};
use rand::distributions::{Distribution, Uniform};
use rand::Rng;
use std::num::{NonZeroI8, NonZeroI16, NonZeroI32, NonZeroI64, NonZeroI128, NonZeroIsize,
NonZeroU8, NonZeroU16, NonZeroU32, NonZeroU64, NonZeroU128, NonZeroUsize};
use std::num::{
NonZeroI128, NonZeroI16, NonZeroI32, NonZeroI64, NonZeroI8, NonZeroIsize, NonZeroU128,
NonZeroU16, NonZeroU32, NonZeroU64, NonZeroU8, NonZeroUsize,
};

macro_rules! signed_faker_impl {
($nz_typ: ty, $typ:ty) => {

impl Dummy<Faker> for $nz_typ {
impl Dummy<Faker> for $nz_typ {
fn dummy_with_rng<R: Rng + ?Sized>(_: &Faker, rng: &mut R) -> Self {
if rng.gen_bool(0.5) {
let u = Uniform::new_inclusive(<$typ>::MIN, -1);
Expand All @@ -18,22 +19,20 @@ macro_rules! signed_faker_impl {
}
}
}
}
};
}

macro_rules! unsigned_faker_impl {
($nz_typ: ty, $typ:ty) => {

impl Dummy<Faker> for $nz_typ {
impl Dummy<Faker> for $nz_typ {
fn dummy_with_rng<R: Rng + ?Sized>(_: &Faker, rng: &mut R) -> Self {
let u = Uniform::new_inclusive(1, <$typ>::MAX);
<$nz_typ>::new(u.sample(rng)).unwrap()
}
}
}
};
}


signed_faker_impl!(NonZeroI8, i8);
signed_faker_impl!(NonZeroI16, i16);
signed_faker_impl!(NonZeroI32, i32);
Expand Down

0 comments on commit 880e0b7

Please sign in to comment.