#pi #print #debugging

nightly pi_print_any

print any value without trait bounds using specialization (Rust nightly channel)

3 releases

0.1.2 Aug 26, 2022
0.1.1 Jul 5, 2022
0.1.0 May 12, 2022

#77 in #pi

Download history 28/week @ 2024-07-20 67/week @ 2024-07-27 36/week @ 2024-08-03 40/week @ 2024-08-10 35/week @ 2024-08-17 30/week @ 2024-08-24 27/week @ 2024-08-31 23/week @ 2024-09-07 34/week @ 2024-09-14 52/week @ 2024-09-21 31/week @ 2024-09-28 11/week @ 2024-10-05 33/week @ 2024-10-12 20/week @ 2024-10-19 19/week @ 2024-10-26 25/week @ 2024-11-02

101 downloads per month
Used in 13 crates (6 directly)

MIT/Apache

6KB
52 lines

output without the trait bounds (using specialization to find the right impl anyway)

output value for type of impl Debug, output type name for unimplDebug.

for example:

	#[derive(Debug)]
	struct A(usize);
	struct B(usize);
	fn main() {
		println_any!("{:?}", A(1)); // output: A(1)
		println_any!("{:?}", B(1)); // output: `pi_print_any::B`

		print_any!("{:?}", A(1)); // output: A(1)
		print_any!("{:?}", B(1)); // output: `pi_print_any::B`
	}

In addition to using print and println output, you can also use other macros to output, out_any allows you to pass in the output macro you want to use

for example:

	#[derive(Debug)]
	struct A(usize);
	struct B(usize);
	fn main() {
		out_any!(log::info, "{:?}", A(1)); // output: A(1)
		out_any!(log::info, "{:?}", B(1)); // output: `pi_print_any::B`
	}

lib.rs:

output without the trait bounds (using specialization to find the right impl anyway)

output value for type of impl Debug, output type name for unimplDebug.

for example:

#[derive(Debug)]
struct A(usize);
struct B(usize);
fn main() {
	println!("{:?}", A(1)); // output: A(1)
	println!("{:?}", B(1)); // output: `pi_print_any::B`
}

NOTE: This uses experimental Rust features and is therefore by itself experimental and unstable, and has all the problems of feature(specialization).

No runtime deps