Crates.io | format-bytes |
lib.rs | format-bytes |
version | 0.3.0 |
source | src |
created_at | 2020-06-10 16:38:26.631389 |
updated_at | 2021-12-17 10:39:54.502473 |
description | A macro to format bytestrings |
homepage | |
repository | https://foss.heptapod.net/octobus/rust/format-bytes/ |
max_upload_size | |
id | 252423 |
size | 18,488 |
This crate exposes a procedural macro that allows you to format bytestrings. For more background on why you would want to do that, read this article.
Add this to your Cargo.toml
:
[dependencies]
format-bytes = "0.2"
then use the macro like so:
use format_bytes::format_bytes;
fn main() {
assert_eq!(
format_bytes!(b"look at those {} bytes", &[0u8, 1, 2]),
b"look at those \x00\x01\x02 bytes"
);
}
See more examples of how it works on the documentation of
format_bytes!
itself.
Named arguments, but they should be added in a future version
Python-like "f-string" functionality is not planned because of its more complex implementation and limited actual benefit
format!
-like padding helpers: if the need manifests itself, they might
appear
#[no_std]
support
Not until named arguments have landed and the macro gets a bit of mileage (it will be used in Mercurial).