kvfmt 0.1.5

A helper macro for stringifying variables into a key=value style string
Documentation
  • Coverage
  • 0%
    0 out of 4 items documented0 out of 2 items with examples
  • Size
  • Source code size: 4.80 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 165.79 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • Homepage
  • yaahc/kvfmt
    3 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • yaahc

kvfmt="valuable"

Latest Version Rust Documentation

This library provides a convenient macro generating structured logging-esque strings with a minimalistic syntax.

[dependencies]
kvfmt = "0.1"

Example

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)
    );
}

Details

  • This macro supports any number of identifiers, optionally prefixed with a ? 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)

License

Credits

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.