faux
faux copied to clipboard
Mock an entire module
Ideally something like this would work
// imagine this is the start of a module
#![faux::mock]
struct Foo {}
impl Foo {}
/* more structs and impls here */
Unfortunately custom inner attributes are not supported
I would also be okay with
#[faux::mock]
mod foo; // mocks all of foo.rs
But this currently returns a ModItem
with no body.
The alternative is:
// inside foo.rs
#[faux::mock]
mod inner_foo {
struct Foo {}
impl Foo {}
}
pub use inner_foo::*;
There is a clear ergonomic hit to this latter approach though. I would very much dislike foricng the user to write this kind of code just to support faux
. This makes me unsure if a mod-level macro would be that useful until either option 1 or 2 are allowed.