2019-07-24 00:22:11 +02:00
|
|
|
use crate::prelude::*;
|
2019-11-21 15:33:14 +01:00
|
|
|
use nu_source::{DebugDocBuilder, Spanned, SpannedItem, Tagged};
|
2019-11-04 16:47:03 +01:00
|
|
|
|
|
|
|
pub trait ShellTypeName {
|
|
|
|
fn type_name(&self) -> &'static str;
|
|
|
|
}
|
|
|
|
|
2019-11-21 15:33:14 +01:00
|
|
|
impl<T: ShellTypeName> ShellTypeName for Spanned<T> {
|
|
|
|
fn type_name(&self) -> &'static str {
|
|
|
|
self.item.type_name()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-04 16:47:03 +01:00
|
|
|
impl<T: ShellTypeName> ShellTypeName for &T {
|
|
|
|
fn type_name(&self) -> &'static str {
|
|
|
|
(*self).type_name()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub trait SpannedTypeName {
|
|
|
|
fn spanned_type_name(&self) -> Spanned<&'static str>;
|
|
|
|
}
|
|
|
|
|
2019-11-21 15:33:14 +01:00
|
|
|
impl<T: ShellTypeName + HasSpan> SpannedTypeName for T {
|
2019-11-04 16:47:03 +01:00
|
|
|
fn spanned_type_name(&self) -> Spanned<&'static str> {
|
2019-11-21 15:33:14 +01:00
|
|
|
self.type_name().spanned(self.span())
|
2019-11-04 16:47:03 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<T: ShellTypeName> SpannedTypeName for Tagged<T> {
|
|
|
|
fn spanned_type_name(&self) -> Spanned<&'static str> {
|
|
|
|
self.item.type_name().spanned(self.tag.span)
|
|
|
|
}
|
|
|
|
}
|
2019-07-24 00:22:11 +02:00
|
|
|
|
2019-11-04 16:47:03 +01:00
|
|
|
pub trait PrettyType {
|
|
|
|
fn pretty_type(&self) -> DebugDocBuilder;
|
|
|
|
}
|