Crates.io | spotlight |
lib.rs | spotlight |
version | 0.1.0 |
source | src |
created_at | 2022-07-30 22:33:53.282821 |
updated_at | 2022-07-30 22:33:53.282821 |
description | A debug macro |
homepage | |
repository | https://github.com/yoav-lavi/spotlight |
max_upload_size | |
id | 635815 |
size | 20,494 |
Warning
Spotlight is currently considered experimental / alpha level quality
spotlight!
is a drop in replacement macro for std::dbg!
which adds additional information, has colored output, and can be called in a postfix position (e.g. between chaining method calls, as .spotlight("label")
).
Note
The thread and function name are the same in these examples as they were taken from test runs, which name the main thread with the same name as the test function
use spotlight::spotlight;
fn swap() {
let mut left = 5;
let mut right = 3;
spotlight!(&left);
spotlight!(&right);
std::mem::swap(&mut left, &mut right);
spotlight!(&left);
spotlight!(&right);
}
outputs
[time 1659217308153] [file tests/mod.rs:18] [fn mod::swap] [thread swap] [addr 0x16de8d350] &left = 5
[time 1659217308153] [file tests/mod.rs:19] [fn mod::swap] [thread swap] [addr 0x16de8d354] &right = 3
[time 1659217308153] [file tests/mod.rs:21] [fn mod::swap] [thread swap] [addr 0x16de8d350] &left = 3
[time 1659217308153] [file tests/mod.rs:22] [fn mod::swap] [thread swap] [addr 0x16de8d354] &right = 5
use spotlight::Spotlight;
fn method() {
let _ = "test"
.chars()
.spotlight("as_chars")
.map(|char| char.to_uppercase().to_string())
.spotlight("mapped")
.collect::<String>()
.spotlight("new_string");
}
outputs
[time 1659217480013] [thread method] [addr 0x16bc020d8] as_chars = Chars([
't',
'e',
's',
't',
])
[time 1659217480014] [thread method] [addr 0x16bc01d68] mapped = Map {
iter: Chars([
't',
'e',
's',
't',
]),
}
[time 1659217480014] [thread method] [addr 0x16bc01d50] new_string = "TEST"
Spotlight
trait uses the implementation used in tapspotlight!
macro is derived from the dbg!
macro