Skip to content

Commit

Permalink
Implement Clone for MockStore
Browse files Browse the repository at this point in the history
  • Loading branch information
orbwalk committed Feb 14, 2022
1 parent 43027e4 commit d4b9fe4
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/mock_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use std::{
/// implements_default(faux::MaybeFaux::Real(3));
/// ```
#[derive(Debug)]
#[derive(Clone, Debug)]
pub enum MaybeFaux<T> {
Real(T),
Faux(MockStore),
Expand All @@ -38,15 +38,6 @@ impl<T: Default> Default for MaybeFaux<T> {
}
}

impl<T: Clone> Clone for MaybeFaux<T> {
fn clone(&self) -> Self {
match self {
MaybeFaux::Real(r) => MaybeFaux::Real(r.clone()),
MaybeFaux::Faux(_) => panic!("cannot clone a mock"),
}
}
}

impl<T> MaybeFaux<T> {
pub fn faux() -> Self {
MaybeFaux::Faux(MockStore::new())
Expand Down Expand Up @@ -124,3 +115,12 @@ impl MockStore {
Err(errors.join("\n\n"))
}
}

impl Clone for MockStore {
fn clone(&self) -> Self {
let stubs = self.stubs.lock().unwrap();
Self {
stubs: Mutex::new(stubs.clone()),
}
}
}

0 comments on commit d4b9fe4

Please sign in to comment.