pi_print_any

Crates.iopi_print_any
lib.rspi_print_any
version0.1.2
sourcesrc
created_at2022-05-12 02:40:41.031183
updated_at2022-08-26 06:00:04.20656
descriptionprint any value without trait bounds using specialization (Rust nightly channel)
homepage
repositoryhttps://github.com/GaiaWorld/pi_print_any.git
max_upload_size
id584982
size5,905
(wzjsun)

documentation

README

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`
	}
Commit count: 4

cargo fmt