2019-05-16 00:58:44 +02:00
|
|
|
use std::any::Any;
|
2019-05-24 20:48:33 +02:00
|
|
|
use std::fmt::Debug;
|
2019-05-10 18:59:12 +02:00
|
|
|
|
2019-05-24 20:48:33 +02:00
|
|
|
pub trait Type: Debug + Send {
|
2019-05-15 18:12:38 +02:00
|
|
|
fn as_any(&self) -> &dyn Any;
|
|
|
|
fn equal(&self, other: &dyn Type) -> bool;
|
2019-05-24 20:48:33 +02:00
|
|
|
fn id(&self) -> u64;
|
|
|
|
fn copy(&self) -> Box<Type>;
|
2019-05-15 18:12:38 +02:00
|
|
|
}
|
2019-05-10 18:59:12 +02:00
|
|
|
|
2019-05-24 20:48:33 +02:00
|
|
|
#[derive(Debug, Eq, PartialEq)]
|
2019-05-15 18:12:38 +02:00
|
|
|
pub struct AnyShell;
|
|
|
|
|
|
|
|
impl Type for AnyShell {
|
|
|
|
fn as_any(&self) -> &dyn Any {
|
|
|
|
self as &dyn Any
|
|
|
|
}
|
|
|
|
|
|
|
|
fn equal(&self, other: &dyn Type) -> bool {
|
|
|
|
other.as_any().is::<AnyShell>()
|
|
|
|
}
|
2019-05-24 20:48:33 +02:00
|
|
|
|
|
|
|
fn id(&self) -> u64 {
|
|
|
|
0
|
|
|
|
}
|
|
|
|
|
|
|
|
fn copy(&self) -> Box<Type> {
|
|
|
|
Box::new(AnyShell)
|
|
|
|
}
|
2019-05-15 18:12:38 +02:00
|
|
|
}
|