From 7df48110ab4010166543db7590bc2b8893d5c39e Mon Sep 17 00:00:00 2001 From: est31 Date: Thu, 29 Aug 2019 16:14:43 +0200 Subject: [PATCH] Remove unused functions that use specialization --- src/object/types.rs | 114 -------------------------------------------- 1 file changed, 114 deletions(-) diff --git a/src/object/types.rs b/src/object/types.rs index 9a29284cbf..2f3dc795f7 100644 --- a/src/object/types.rs +++ b/src/object/types.rs @@ -1,14 +1,9 @@ use crate::object::base as value; -use crate::parser::hir; use crate::prelude::*; use log::trace; pub trait ExtractType: Sized { fn extract(value: &Tagged) -> Result; - fn check(value: &'value Tagged) -> Result<&'value Tagged, ShellError>; - fn syntax_type() -> hir::SyntaxType { - hir::SyntaxType::Any - } } impl ExtractType for T { @@ -19,14 +14,6 @@ impl ExtractType for T { name ))) } - - default fn check(_value: &'value Tagged) -> Result<&'value Tagged, ShellError> { - Err(ShellError::unimplemented("ExtractType for T")) - } - - default fn syntax_type() -> hir::SyntaxType { - hir::SyntaxType::Any - } } impl ExtractType for Vec> { @@ -50,20 +37,6 @@ impl ExtractType for Vec> { )), } } - - fn check(value: &'value Tagged) -> Result<&'value Tagged, ShellError> { - match value.item() { - Value::List(_) => Ok(value), - other => Err(ShellError::type_error( - "Vec", - other.type_name().tagged(value.tag()), - )), - } - } - - fn syntax_type() -> hir::SyntaxType { - hir::SyntaxType::List - } } impl ExtractType for (T, U) { @@ -107,17 +80,6 @@ impl ExtractType for Option { Ok(result) } - - fn check(value: &'value Tagged) -> Result<&'value Tagged, ShellError> { - match value.item() { - Value::Primitive(Primitive::Nothing) => Ok(value), - _ => T::check(value), - } - } - - fn syntax_type() -> hir::SyntaxType { - T::syntax_type() - } } impl ExtractType for Tagged { @@ -127,14 +89,6 @@ impl ExtractType for Tagged { Ok(T::extract(value)?.tagged(value.tag())) } - - fn check(value: &'value Tagged) -> Result<&'value Tagged, ShellError> { - T::check(value) - } - - fn syntax_type() -> hir::SyntaxType { - T::syntax_type() - } } impl ExtractType for Value { @@ -143,21 +97,9 @@ impl ExtractType for Value { Ok(value.item().clone()) } - - fn check(value: &'value Tagged) -> Result<&'value Tagged, ShellError> { - Ok(value) - } - - fn syntax_type() -> hir::SyntaxType { - SyntaxType::Any - } } impl ExtractType for bool { - fn syntax_type() -> hir::SyntaxType { - hir::SyntaxType::Boolean - } - fn extract(value: &'a Tagged) -> Result { trace!("Extracting {:?} for bool", value); @@ -173,23 +115,9 @@ impl ExtractType for bool { other => Err(ShellError::type_error("Boolean", other.tagged_type_name())), } } - - fn check(value: &'value Tagged) -> Result<&'value Tagged, ShellError> { - match &value { - value @ Tagged { - item: Value::Primitive(Primitive::Boolean(_)), - .. - } => Ok(value), - other => Err(ShellError::type_error("Boolean", other.tagged_type_name())), - } - } } impl ExtractType for std::path::PathBuf { - fn syntax_type() -> hir::SyntaxType { - hir::SyntaxType::Path - } - fn extract(value: &'a Tagged) -> Result { trace!("Extracting {:?} for PathBuf", value); @@ -201,16 +129,6 @@ impl ExtractType for std::path::PathBuf { other => Err(ShellError::type_error("Path", other.tagged_type_name())), } } - - fn check(value: &'value Tagged) -> Result<&'value Tagged, ShellError> { - match &value { - v @ Tagged { - item: Value::Primitive(Primitive::Path(_)), - .. - } => Ok(v), - other => Err(ShellError::type_error("Path", other.tagged_type_name())), - } - } } impl ExtractType for i64 { @@ -225,16 +143,6 @@ impl ExtractType for i64 { other => Err(ShellError::type_error("Integer", other.tagged_type_name())), } } - - fn check(value: &'value Tagged) -> Result<&'value Tagged, ShellError> { - match value { - v @ Tagged { - item: Value::Primitive(Primitive::Int(_)), - .. - } => Ok(v), - other => Err(ShellError::type_error("Integer", other.tagged_type_name())), - } - } } impl ExtractType for String { @@ -249,31 +157,9 @@ impl ExtractType for String { other => Err(ShellError::type_error("String", other.tagged_type_name())), } } - - fn check(value: &'value Tagged) -> Result<&'value Tagged, ShellError> { - match value { - v @ Tagged { - item: Value::Primitive(Primitive::String(_)), - .. - } => Ok(v), - other => Err(ShellError::type_error("String", other.tagged_type_name())), - } - } } impl ExtractType for value::Block { - fn check(value: &'value Tagged) -> Result<&'value Tagged, ShellError> { - trace!("Extracting {:?} for Block", value); - - match value { - v @ Tagged { - item: Value::Block(_), - .. - } => Ok(v), - other => Err(ShellError::type_error("Block", other.tagged_type_name())), - } - } - fn extract(value: &Tagged) -> Result { match value { Tagged {