#formatting

extfmt

Extended formatting options for commmon types

2 releases

0.1.1 Sep 29, 2017
0.1.0 Sep 29, 2017

#46 in Value formatting

Download history 31/week @ 2019-12-13 67/week @ 2019-12-20 33/week @ 2019-12-27 9/week @ 2020-01-03 62/week @ 2020-01-10 18/week @ 2020-01-17 9/week @ 2020-01-24 10/week @ 2020-01-31 11/week @ 2020-02-07 6/week @ 2020-02-14 19/week @ 2020-02-21 24/week @ 2020-02-28 30/week @ 2020-03-06 18/week @ 2020-03-13 30/week @ 2020-03-20 13/week @ 2020-03-27

192 downloads per month
Used in 4 crates (2 directly)

Apache-2.0

8KB
145 lines

extfmt

A crate with additional formatting options for Rust types

Usage

Add the dependency to your Cargo.toml:

[dependencies]
extfmt = "0.1"
extern crate extfmt;

use extfmt::*;

fn main() {
	// Wrapper types for prettier printing of slices.
	//
	// The string is formatted in a "slice" form, and supports most 
	// format specifiers as long as the underlying type implements them
	//
	// This prints "[01, 02, ff, 40]"
	println!("{:02x}", CommaSeparated(&[1, 2, 255, 64]));

	// Compact formatting of byte slices:
	// This prints "0102ff40".
	println!("{}", Hexlify(&[1, 2, 255, 64]));

	// Pretty buffer printing using `hexdump`.
	println!("{}", hexdump!(&[1u8, 2, 255, 64]));
	// 	 => 00000000	01 02 ff 40

	// Hexdump can also be used as a memory view for Sized types.
	println!("{}", hexdump!(64));
	//   => 00000000	40 00 00 00

	// Further hexdump options
	println!("{}", hexdump!(64, show_index: false));
	//   => 40 00 00 00
}

lib.rs:

A crate with extended formatting options for ceratin types.

No runtime deps