Skip to content

Commit

Permalink
docs: add some docs about using mock! to mock clone derives
Browse files Browse the repository at this point in the history
  • Loading branch information
tom pridham committed Jun 28, 2022
1 parent 21b2856 commit 0fbac8d
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions mockall/src/lib.rs
Expand Up @@ -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
//!
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 0fbac8d

Please sign in to comment.