[][src]Macro trackable::track

macro_rules! track {
    ($target:expr) => { ... };
    ($target:expr; $($value:expr),+) => { ... };
    ($target:expr, $message:expr) => { ... };
    ($target:expr, $message:expr; $($value:expr),+) => { ... };
    ($target:expr, $($format_arg:tt)+) => { ... };
}

Tries to track the current location into the history of the $target.

$target must be evaluated to a value which implements Trackable trait.

If $target.in_tracking() is false, it will simply return the value of $target untouched.

Examples

use trackable::error::{Failed, ErrorKindExt};

// Makes a `TrackableError` value
let e = Failed.cause("something wrong");
let e = track!(e);

// `Result<_, TrackableError>` implements `Trackable`
let message = "This is a note about this location";
let e: Result<(), _> = Err(e);
let e = track!(e; message);

// `Option<T: Trackable>` implements `Trackable`
let e = Some(e);
let e = track!(e, "Hello {}", "World!");

assert_eq!(format!("\n{}", e.unwrap().err().unwrap()).replace('\\', "/"), r#"
Failed (cause; something wrong)
HISTORY:
  [0] at src/macros.rs:10
  [1] at src/macros.rs:15 -- message="This is a note about this location"
  [2] at src/macros.rs:19 -- Hello World!
"#);