diff --git a/dummy_derive/src/lib.rs b/dummy_derive/src/lib.rs index 8287e5d..ef0f831 100644 --- a/dummy_derive/src/lib.rs +++ b/dummy_derive/src/lib.rs @@ -62,7 +62,7 @@ pub fn derive_dummy(input: TokenStream) -> TokenStream { ast::Style::Unit => { let impl_dummy = quote! { impl ::fake::Dummy<::fake::Faker> for #receiver_name { - fn dummy_with_rng(_: &::fake::Faker, rng: &mut R) -> Self { + fn dummy_with_rng(_: &::fake::Faker, rng: &mut R) -> Self { #receiver_name } } @@ -74,7 +74,7 @@ pub fn derive_dummy(input: TokenStream) -> TokenStream { let impl_dummy = quote! { impl ::fake::Dummy<::fake::Faker> for #receiver_name { - fn dummy_with_rng(_: &::fake::Faker, rng: &mut R) -> Self { + fn dummy_with_rng(_: &::fake::Faker, rng: &mut R) -> Self { #receiver_name(#(#tuple_fields),*) } } @@ -99,7 +99,7 @@ pub fn derive_dummy(input: TokenStream) -> TokenStream { let impl_dummy = quote! { impl ::fake::Dummy<::fake::Faker> for #receiver_name { - fn dummy_with_rng(_: &::fake::Faker, rng: &mut R) -> Self { + fn dummy_with_rng(_: &::fake::Faker, rng: &mut R) -> Self { #(#let_statements)* #receiver_name { #(#struct_fields),* @@ -171,7 +171,7 @@ pub fn derive_dummy(input: TokenStream) -> TokenStream { let impl_dummy = quote! { impl ::fake::Dummy<::fake::Faker> for #receiver_name { - fn dummy_with_rng(_: &::fake::Faker, rng: &mut R) -> Self { + fn dummy_with_rng(_: &::fake::Faker, rng: &mut R) -> Self { match rng.gen_range(0..#variant_count) { #(#match_statements)* _ => { @@ -186,7 +186,7 @@ pub fn derive_dummy(input: TokenStream) -> TokenStream { } else { let impl_dummy = quote! { impl ::fake::Dummy<::fake::Faker> for #receiver_name { - fn dummy_with_rng(_: &::fake::Faker, rng: &mut R) -> Self { + fn dummy_with_rng(_: &::fake::Faker, rng: &mut R) -> Self { panic!("can not create an empty enum") } } diff --git a/fake/src/lib.rs b/fake/src/lib.rs index d439925..fcf65eb 100644 --- a/fake/src/lib.rs +++ b/fake/src/lib.rs @@ -78,7 +78,8 @@ //! let result: Option = Faker.fake_with_rng(&mut rng); //! println!("Always Some: {}", result.unwrap()); //! ``` -use rand::Rng; +#[doc(hidden)] +pub use rand::Rng; /// Generate default fake value for given type using [`Fake`]. /// @@ -286,7 +287,7 @@ pub mod locales; /// Derive macro generating an impl of the trait [`Dummy`]. This works for both structs and enums. /// -/// # Attributes +/// # Attributes /// /// For any fields in the type there are a number of keys that can be used to control the code generation. /// All of these go within the dummy attribute.