#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

#81 in Value formatting

Download history 2868/week @ 2022-08-07 1832/week @ 2022-08-14 1377/week @ 2022-08-21 1395/week @ 2022-08-28 1795/week @ 2022-09-04 2936/week @ 2022-09-11 962/week @ 2022-09-18 1018/week @ 2022-09-25 959/week @ 2022-10-02 1705/week @ 2022-10-09 533/week @ 2022-10-16 1778/week @ 2022-10-23 1003/week @ 2022-10-30 1937/week @ 2022-11-06 1014/week @ 2022-11-13 2548/week @ 2022-11-20

6,519 downloads per month
Used in 7 crates (4 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