developer_debug_tools 0.1.0

Tools for developer to debug their code
Documentation
developer_debug_tools-0.1.0 has been yanked.

developer_debug_tools License developer_debug_tools on crates.io developer_debug_tools on docs.rs Source Code Repository

developer_debug_tools

The crate aids developers to their code e.g debug recurive function by printing the recursion tree of call

Annotate any recursive function with proc macro print_recursion_tree. Recursion tree is printed in the stdout at the end of recursive call. The pre condition is that all arguments and return type of the function must implement std::fmt::Debug trait

use developer_debug_tools::print_recursion_tree;
#[print_recursion_tree(print_recursion_counter, print_each_pass)]
fn fibonacci_recursive(n: u16) -> u16 {
   if n <= 1 {
       return n;
   } else {
       return fibonacci_recursive(n - 1) + fibonacci_recursive(n - 2);
   }
} 

Output of fibonacci_recursive(3) is as below

fibonacci_recursive
 └─ 3
    ├─ 2
    │  ├─ 1
    │  │  └─ =1
    │  ├─ 0
    │  │  └─ =0
    │  └─ =1
    ├─ 1
    │  └─ =1
    └─ =2

fibonacci_recursive is the function name

└─3, └─2 denotes argument passed to the function

└─ =2, └─ =1 are the return value of each recursive call

Two flags(attributes) are supported by this proc-macro

1. print_each_pass

This prints the recursion tree on each recursive call. If this flag is not provided, recursion tree is printed only once at the end of the recursion

2.print_recursion_counter

This prints the total recursion calls evaluated. This can be useful to check the optimization of recursive call e.g using memoization

Total Number Of Recursions: 4