| Crates.io | around |
| lib.rs | around |
| version | 0.1.0 |
| created_at | 2024-03-08 18:46:07.544507+00 |
| updated_at | 2024-03-08 18:46:07.544507+00 |
| description | execute code around a function |
| homepage | |
| repository | https://github.com/chapuzzo/around |
| max_upload_size | |
| id | 1167206 |
| size | 6,040 |
This is the around crate, a Rust procedural macro library for calling other functions inside your desired ones.
To use the around crate, add it to your Cargo.toml file:
[dependencies]
around = { version = "0.1.0"}
The around crate provides a procedural macros before, afer and both that enables running another function when expected.
The function must exist and be in scope.
Here's a basic example of how to use it:
#[around(database_clean)]
fn fancy_func(){
// Your function code here...
}
In this example database_clean would be called twice, once before and once after your original function code.
Currently this literally translates to:
fn fancy_func(){
database_clean();
// Your function code here...
database_clean();
}