asomers / mockall

A powerful mock object library for Rust
Apache License 2.0
1.5k stars 62 forks source link

`#[derive(Clone)]` is not generating the implementation #583

Closed cernicc closed 3 months ago

cernicc commented 3 months ago

version: 0.12.1

This doesn't work. If I implement the Clone manually it works.

mockall::mock! {
    #[derive(Clone)]
    pub Something {}
}
asomers commented 3 months ago

Mock objects cannot automatically implement Clone. If they did, what should happen to expectations when an object gets cloned? Should the expectations be cloned too? That's not always desirable, and not always even possible. Instead, Mockall treats Clone like any other trait.

cernicc commented 3 months ago

Aha. Good point. Thanks for the quick response