Skip to main content

aspect

Attribute Macro aspect 

Source
#[aspect]
Expand description

Applies an aspect to a function.

§Example

use aspect_macros::aspect;
use aspect_core::prelude::*;

#[derive(Default)]
struct Logger;

impl Aspect for Logger {
    fn before(&self, ctx: &JoinPoint) {
        println!("[ENTRY] {}", ctx.function_name);
    }
}

#[aspect(Logger)]
fn my_function(x: i32) -> i32 {
    x * 2
}