#formatting

extfmt

Extended formatting options for commmon types

2 releases

Uses old Rust 2015

0.1.1 Sep 29, 2017
0.1.0 Sep 29, 2017

#50 in Value formatting

Download history 141/week @ 2020-10-06 420/week @ 2020-10-13 401/week @ 2020-10-20 499/week @ 2020-10-27 812/week @ 2020-11-03 720/week @ 2020-11-10 696/week @ 2020-11-17 667/week @ 2020-11-24 640/week @ 2020-12-01 916/week @ 2020-12-08 880/week @ 2020-12-15 641/week @ 2020-12-22 595/week @ 2020-12-29 446/week @ 2021-01-05 1430/week @ 2021-01-12 726/week @ 2021-01-19

1,654 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