4 releases

0.2.1 Sep 26, 2020
0.2.0 Aug 24, 2019
0.1.1 Feb 7, 2019
0.1.0 Feb 6, 2019

#6 in #aspect

Download history 15184/week @ 2024-03-14 11947/week @ 2024-03-21 11407/week @ 2024-03-28 14590/week @ 2024-04-04 12645/week @ 2024-04-11 13708/week @ 2024-04-18 14686/week @ 2024-04-25 14920/week @ 2024-05-02 14675/week @ 2024-05-09 13784/week @ 2024-05-16 15180/week @ 2024-05-23 13467/week @ 2024-05-30 13187/week @ 2024-06-06 13855/week @ 2024-06-13 11566/week @ 2024-06-20 9378/week @ 2024-06-27

50,853 downloads per month
Used in 7 crates (2 directly)

Apache-2.0 OR MIT

72 lines


Build Status License Cargo Documentation Rust 1.31+

An Aspect Toolkit for Rust

Aspect-RS is a project aiming to provide common ground for the main Aspect-Oriented use cases in Rust. By leveraging the trait system, declarative and procedural macros, Aspect-RS provides blocks that let you wrap methods with your custom logic.

The project has been extracted from the Metered project, which uses the technique to build metrics that can work on expressions or methods, whether they're async or not. The technique seemed general enough to be in its own crate and see if it is of any interest to other parties.

Aspect-RS provides "pointcut" traits when entering or exiting an expression (OnEnter and OnResult), experimental Update and UpdateRef traits that can use parameter shadowing to intercept and update method parameters, and weaving constructs useful when building procedural macros. Please look at the Metered project to see Aspect-RS in action.


  • 0.2.1:
    • Added leave_scope function to OnResult to allow aspects to have a drop implementation to handle aspects that never returned
    • Updated indexmap to 1.6
  • 0.2.0:
    • Updated dependencies to use syn, proc-macro2 and quote 1.0

Required Rust version

Aspect-RS runs on Rust stable.


Licensed under either of

at your option.


Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.


~52K SLoC