xref: /DragonOS/kernel/src/libs/name.rs (revision cf7f801e1d50ee5b04cb728e4251a57f4183bfbc)
1*cf7f801eSMemoryShore use core::any::type_name;
2*cf7f801eSMemoryShore 
3*cf7f801eSMemoryShore use alloc::string::{String, ToString};
4*cf7f801eSMemoryShore 
5*cf7f801eSMemoryShore #[allow(dead_code)]
get_full_type_name<T>(_: &T) -> String6*cf7f801eSMemoryShore pub fn get_full_type_name<T>(_: &T) -> String {
7*cf7f801eSMemoryShore     type_name::<T>().to_string()
8*cf7f801eSMemoryShore }
9*cf7f801eSMemoryShore 
get_type_name<T>(_: &T) -> String10*cf7f801eSMemoryShore pub fn get_type_name<T>(_: &T) -> String {
11*cf7f801eSMemoryShore     let full_name = type_name::<T>();
12*cf7f801eSMemoryShore     full_name[(full_name.rfind("::").unwrap_or(0) + 2)..].to_string()
13*cf7f801eSMemoryShore }
14