1use std::any::Any;
2use std::cell::RefCell;
3use std::error::Error;
4use std::fmt::Debug;
5
6use crate::{Mock, Mockdown};
7
8pub fn new() -> RefCell<Mockdown> {
9 Default::default()
10}
11
12impl Mock for RefCell<Mockdown> {
13 fn clear(&'static self) -> &'static Self {
14 self.borrow_mut().clear();
15 self
16 }
17
18 fn expect<T: Any, U: Any>(&'static self, expect: fn(T) -> U) -> &'static Self {
19 self.borrow_mut().add(expect);
20 self
21 }
22
23 fn mock<T: Any + Debug, U: Any>(&'static self, args: T) -> Result<U, Box<dyn Error>> {
24 self.borrow_mut().mock(args)
25 }
26}