Skip to content

Latest commit

 

History

History
9 lines (7 loc) · 259 Bytes

print-type-in-rust.org

File metadata and controls

9 lines (7 loc) · 259 Bytes

Print Type in Rust

If you want to print the type in Rust (similar to %T in Go), here’s a snippet:

fn type_of<T>(_: &T) -> String {
    format!("{}", std::any::type_name::<T>())
}