debug_utilities 0.1.0

debug_utilities provides procedural macros to simplify code debugging
Documentation
  • Coverage
  • 0%
    0 out of 3 items documented0 out of 2 items with examples
  • Size
  • Source code size: 7.99 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 282.5 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 6s Average build duration of successful builds.
  • all releases: 6s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • bjfssd757/debug-utilities
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • bjfssd757

debug-utilities

Rust procedural macros for simplified debugging.

Features

  • #[Trace] - An attribute for showing the input and output of a function, including the received parameters and the result of the function;
  • dbg_here!(variable) - Macro for debugging the contents of a variable.

Usage

First, you need to add the library to your project:

cargo add debug_utilities

Then, you need to add a dependency to highlight debug messages in the terminal:

cargo add colored

#[trace]

Adds a debug output to the beginning and end of the function, showing the function entry (along with the input parameters) and exit (with the returned result, if any).

use debug_utilities::*;

#[trace]
fn get_name(id: i32) -> String {
    if id == 0 {
        println!("Not valid id");
        "Invalid id".to_string()
    } else {
        println!("Valid id");
        "Some Name".to_string()
    }
}

fn main() {
    let name = get_name(1);
    println!("{}", name);
}


/* output:

--> Entering function: 'get_name'
    Param 'id' = 1

Valid id

<-- Exiting function: 'get_name' with result: "Some Name"

Some Name
*/

dbg_here!(variable)

Displays the value of the specified variable in the debug message.

use debug_utilities::*;

fn main() {
    let a = 42;
    dbg_here!(a);
}

/* output:
[example\src\main.rs:5] in example: 'a' = 42
*/