From 0fbac8d1ddd59347052681b18685f3ea81c71861 Mon Sep 17 00:00:00 2001 From: tom pridham Date: Tue, 28 Jun 2022 12:30:11 -0600 Subject: [PATCH] docs: add some docs about using mock! to mock clone derives --- mockall/src/lib.rs | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/mockall/src/lib.rs b/mockall/src/lib.rs index 21803850..d30f53e2 100644 --- a/mockall/src/lib.rs +++ b/mockall/src/lib.rs @@ -668,8 +668,8 @@ //! } //! # fn main() {} //! ``` -//! For structs with more than one `impl` block, see [`mock!`] -//! instead. +//! For structs with more than one `impl` block or that have unsupported +//! `#[derive(X)]` attributes, e.g. `Clone`, see [`mock!`] instead. //! //! ## Generic methods //! @@ -1289,6 +1289,23 @@ pub use mockall_derive::automock; /// } /// # fn main() {} /// ``` +/// Mocking an unsupported `#[derive(X)]` attribute, e.g. `Clone`, is +/// similar. +/// ``` +/// # use mockall_derive::mock; +/// #[derive(Clone)] +/// struct MyStruct; +/// +/// mock!{ +/// pub MyStruct { +/// fn bar(&self); +/// } +/// impl Clone for MyStruct { +/// fn clone(&self) -> Self; +/// } +/// } +/// # fn main() {} +/// ``` /// /// When mocking a generic struct's implementation of a generic trait, use the /// same namespace for their generic parameters. For example, if you wanted to