#debug #print

develop_debug

Print debugging information at development time

9 releases (4 breaking)

0.4.1 May 19, 2021
0.3.1 Apr 15, 2021
0.2.6 Apr 12, 2021
0.1.2 Mar 30, 2021
0.0.0 Mar 27, 2021

#176 in Development tools

Download history 83/week @ 2021-03-31 37/week @ 2021-04-07 50/week @ 2021-04-14 24/week @ 2021-04-21 1/week @ 2021-04-28 2/week @ 2021-05-05 12/week @ 2021-05-12 18/week @ 2021-05-19 3/week @ 2021-05-26 2/week @ 2021-06-02 15/week @ 2021-06-09 2/week @ 2021-06-16 1/week @ 2021-06-23 3/week @ 2021-06-30 2/week @ 2021-07-07 14/week @ 2021-07-14

87 downloads per month

MPL-2.0 license

11KB
159 lines

Print debugging information at development time

What does this library do?

  • Print nice debugging information;
  • Does not affect performance in the release version;

Usage

Add this to your Cargo.toml :

[dependencies]
develop_debug = "0.4.1"

Use the develop_debug! :

use develop_debug::*;

// Standard usage
#[test]
fn use_develop_debug() {
    let x = "dear X";
    let say = "hello world!";
    let array = vec!["a", "b", "c"];
    let title2 = "balabala...";

    develop_debug!(output true);
    develop_debug!(title "example {}",title2);
    develop_debug!(step "do something...{}", say);
    develop_debug!(var x,say);
    develop_debug!(iter array.iter(),array);
    develop_debug!(done "genius {}",x);
    develop_debug!(error "dude, this road is blocked. {}",x);
    develop_debug!(
        "{}",
        "Use it just as you would with the `println!()` macro."
    );
    develop_debug!(output false);
}

// Using the shortcut, print the same result as above.
#[test]
fn use_develop_debug_shortcut() {
    let x = "dear X";
    let say = "hello world!";
    let array = vec!["a", "b", "c"];
    let title2 = "balabala...";

    dd____show!();
    dd___title!("example {}", title2);
    dd____step!("do something...{}", say);
    dd_____var!(x, say);
    dd____iter!(array.iter(), array);
    dd____done!("genius {}", x);
    dd___error!("dude, this road is blocked. {}", x);
    dd________!(
        "{}",
        "Use it just as you would with the `println!()` macro."
    );
    dd____hide!();
}

Output in debug mode :

🍀  example balabala...

🦀  do something...hello world!

🔹  ‹ x          › ="dear X"›
🔹  ‹ say        › ="hello world!"›

🔶  array.iter()
🔸  "a"
🔸  "b"
🔸  "c"

🔶  array
🔸  "a"
🔸  "b"
🔸  "c"


🌱  done. genius dear X


💥  error. dude, this road is blocked. dear X

🐰  Use it just as you would with the `println!()` macro.

No output in --release mode.

What are the benefits of develop_debug! shortcut?

😬 I think it's easy to recognize in the source code ;
🤤 I think it's convenient to prompt in VS Code ;
🤓 I think it visually splits up the code ;

Does the develop_debug! macro affect code performance?

  • It doesn't affect code performance at all;
  • When compiled to the release, develop_debug! actually expanded to empty;

If the document is not semantically fluent

🥺, please forgive my lack of English. All the documents are explained by the translation software; If you can provide a better translation, please contact me at code@autodo.xyz;

I hope this simple library is of some help to you.

😌 😌 😌 😌 😌 😌

No runtime deps