Crates.io | kvfmt |
lib.rs | kvfmt |
version | 0.1.5 |
source | src |
created_at | 2019-12-10 06:53:00.124384 |
updated_at | 2019-12-10 06:53:00.124384 |
description | A helper macro for stringifying variables into a key=value style string |
homepage | https://github.com/yaahc/kvfmt |
repository | https://github.com/yaahc/kvfmt |
max_upload_size | |
id | 188144 |
size | 5,325 |
This library provides a convenient macro generating structured logging-esque strings with a minimalistic syntax.
[dependencies]
kvfmt = "0.1"
use kvfmt::kvfmt;
fn main() {
let dir = "/var/log";
let paths = vec!["dmesg", "syslog"];
assert_eq!(
"dir=/var/log paths=[\"dmesg\", \"syslog\"]",
kvfmt!(dir, ?paths)
);
}
?
to indicate that it should be formatted with the Debug
trait rather than
the Display
trait which is the default.
kvfmt!(dir)
⟶ format!("dir={}", dir)
kvfmt!(?dir)
⟶ format!("dir={:?}", dir)
A special thanks to Nika for helping me write the macro and David whose wonderful README style I continously steal for all of my projects.