Crates.io | anal-eyes |
lib.rs | anal-eyes |
version | 0.0.1 |
source | src |
created_at | 2024-05-02 11:54:57.980971 |
updated_at | 2024-05-02 11:54:57.980971 |
description | Attribute macro to quickly add crude debugging markers to functions |
homepage | |
repository | https://github.com/j-stach/anal-eyes |
max_upload_size | |
id | 1227675 |
size | 9,769 |
Attribute macro to quickly add crude debugging markers to functions.
Inserts a println!
statement following every variable declaration
and semicolon-terminated expression within the function, to assist in debugging
when a backtrace is not available or when behavior needs to be assessed at runtime.
anal-eyes
to your project$ cargo add anal_eyes
#[anal_eyes]
above your troublesome function(s)use anal_eyes::anal_eyes;
use rand::{ Rng, rngs::ThreadRng };
struct Junk;
impl Junk {
#[anal_eyes]
fn see(&self, no_evil: &mut ThreadRng) -> bool {
no_evil.gen_range(0..3) == 3
}
#[anal_eyes]
fn r#do(&self) -> Self { Junk }
#[anal_eyes]
fn funky(monkey: Self) -> Self {
let mut no_evil = rand::thread_rng();
if monkey.see(&mut no_evil) {
monkey.r#do()
} else {
Self::funky(monkey)
}
}
}
#[anal_eyes]
fn main() {
Junk::funky(Junk);
}
$ cargo run
Executing 'main'
Executing 'funky'
funky, declaration 1
Executing 'see'
Executing 'funky'
funky, declaration 1
Executing 'see'
Executing 'funky'
funky, declaration 1
Executing 'see'
{ ... }
Executing 'funky'
funky, declaration 1
Executing 'see'
thread 'main' has overflowed its stack
fatal runtime error: stack overflow
I'm developing this crate primarily for personal use so I'll only be expanding it as the need arises.
The name is an immature play on the word "analyze", referencing the trait of
"anal-retentiveness" in the context of code scrutiny.
Don't ban me!