Attribute Macro mocktopus_macros::mockable
source · #[mockable]
Expand description
Procedural macro, makes items and their sub-items mockable
Valid to annotate
- module definitions (makes all its valid to annotate items annotated, even if stored in another file)
#[mockable]
mod module {
mod nested {
fn mockable() { ... }
}
}
- standalone functions
#[mockable]
fn mockable() { ... }
- struct impl blocks (makes all functions inside mockable)
#[mockable]
impl Structure {
fn mockable() { ... }
}
- trait impl blocks (makes all functions inside mockable)
#[mockable]
impl Trait for Structure {
fn mockable() { ... }
}
- traits (makes all default functions inside mockable)
#[mockable]
trait Trait {
fn mockable() { ... }
}
Invalid to annotate (WILL FAIL TO COMPILE OR BREAK MOCKING!)
- single functions in struct impls
impl Structure {
#[mockable] //INVALID USAGE!
fn mockable() { ... }
}
- single functions in trait impls
impl Trait for Structure {
#[mockable] //INVALID USAGE!
fn mockable() { ... }
}
- single default functions in traits
trait Trait {
#[mockable] //INVALID USAGE!
fn mockable() { ... }
}
Indifferent to annotate
- already mockable items (inside annotated modules)
- const functions (they are impossible to mock)
- unsafe functions (they are impossible to mock)
- any macro generated items (they are impossible to mock)
- any other items