Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use std::fmt::Debug;
- pub fn type_name<T: Default + Debug>() -> String {
- format!("{:?}", T::default()).split_whitespace().next().unwrap().to_owned()
- }
- #[derive(Debug, Default)]
- struct Foo;
- #[derive(Debug, Default)]
- struct Bar;
- fn main() {
- println!("{} {}", type_name::<Foo>(), type_name::<Bar>())
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement