Use std::any::type_name
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
use std::any::{Any as StdAny, TypeId};
|
||||
use std::any::{type_name, Any as StdAny, TypeId};
|
||||
use std::fmt;
|
||||
|
||||
pub trait Any: StdAny {
|
||||
fn type_id(&self) -> TypeId;
|
||||
|
||||
fn type_name(&self) -> String;
|
||||
|
||||
fn box_clone(&self) -> Box<dyn Any>;
|
||||
|
||||
/// This type may only be implemented by `rhai`.
|
||||
@@ -20,6 +22,10 @@ where
|
||||
TypeId::of::<T>()
|
||||
}
|
||||
|
||||
fn type_name(&self) -> String {
|
||||
type_name::<T>().to_string()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn box_clone(&self) -> Box<dyn Any> {
|
||||
Box::new(self.clone())
|
||||
|
Reference in New Issue
Block a user