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 *;
/* 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 *;
/* output:
[example\src\main.rs:5] in example: 'a' = 42
*/