Macro trackable::track
[−]
[src]
macro_rules! track { ($target: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 e: Result<(), _> = Err(e); let e = track!(e, "This is a note about this location"); // `Option<T: Trackable>` implements `Trackable` let e = Some(e); let e = track!(e, "Hello {}", "World!"); assert_eq!(format!("\n{}", e.unwrap().err().unwrap()), r#" Failed (cause; something wrong) HISTORY: [0] at rust_out:<anon>:9 [1] at rust_out:<anon>:13; This is a note about this location [2] at rust_out:<anon>:17; Hello World! "#);