mirror of
https://github.com/nushell/nushell.git
synced 2024-10-17 15:52:50 +02:00
9f8d2a4de5
Each line is a string object
31 lines
567 B
Rust
31 lines
567 B
Rust
use std::any::Any;
|
|
use std::fmt::Debug;
|
|
|
|
pub trait Type: Debug + Send {
|
|
fn as_any(&self) -> &dyn Any;
|
|
fn equal(&self, other: &dyn Type) -> bool;
|
|
fn id(&self) -> u64;
|
|
fn copy(&self) -> Box<Type>;
|
|
}
|
|
|
|
#[derive(Debug, Eq, PartialEq)]
|
|
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>()
|
|
}
|
|
|
|
fn id(&self) -> u64 {
|
|
0
|
|
}
|
|
|
|
fn copy(&self) -> Box<Type> {
|
|
Box::new(AnyShell)
|
|
}
|
|
}
|