diff-ba-rs

Crates.iodiff-ba-rs
lib.rsdiff-ba-rs
version0.1.2
sourcesrc
created_at2022-07-24 08:58:43.474926
updated_at2022-07-25 17:04:07.229264
descriptionThis library provides macros to get the difference of variables caused by a procedure.
homepage
repositoryhttps://github.com/NaokiM03/diff-ba-rs
max_upload_size
id631889
size6,487
(NaokiM03)

documentation

https://docs.rs/diff-ba-rs

README

diff-ba-rs

About

This library provides macros to get the difference of variables caused by a procedure.

Before and after the operation, use the pretty-print format by fmt::Debug to string them, and get their diff.

How to use

# Cargo.toml

[dependencies]
diff-ba-rs = "0.1.0"
use diff_ba_rs::prelude::*;

#[derive(Debug)]
struct ComplexVariable {
    // ...
}

let mut complex_variable = ComplexVariable {
    // ...
};
let _result =  diff_ba::dbg!(&complex_variable, {
    // OPERATION YOU WANT TO VERIFY
    // The diff_ba::dbg! macro returns the final expression in this block.
});

Very easy sample

use diff_ba_rs::prelude::*;
let mut a = 2;
let b =  diff_ba::dbg!(&a,
    a *= 2;
    a + 1
});
// prints:
// ```
// - 2
// + 4
// ```
assert_eq!(b, 5);

Note

For now, only the dbg! macro prints to standard output, but if there is demand for it from myself or others, I may implement a macro that returns a string or writes to a file.

License

diff-ba-rs is released under the MIT License

Commit count: 12

cargo fmt