#debugging #print #pi #output #bounds #impl #specialization

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

#10 in #specialization

Download history 11/week @ 2023-12-04 19/week @ 2023-12-11 387/week @ 2023-12-18 349/week @ 2023-12-25 193/week @ 2024-01-01 34/week @ 2024-01-08 14/week @ 2024-01-15 11/week @ 2024-01-22 2/week @ 2024-01-29 18/week @ 2024-02-05 47/week @ 2024-02-12 41/week @ 2024-02-19 79/week @ 2024-02-26 55/week @ 2024-03-04 42/week @ 2024-03-11 48/week @ 2024-03-18

225 downloads per month
Used in 12 crates (5 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