From 79d6643598743102a11d163106a46bea371eb32a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20L=C3=BChne?= Date: Tue, 7 Jul 2020 09:56:14 +0200 Subject: [PATCH] Remove unneeded trait methods --- src/parse.rs | 38 ++++++++------------------------------ 1 file changed, 8 insertions(+), 30 deletions(-) diff --git a/src/parse.rs b/src/parse.rs index 625bb78..07f56de 100644 --- a/src/parse.rs +++ b/src/parse.rs @@ -11,17 +11,15 @@ pub trait Parser: Sized { type Flavor: crate::flavor::Flavor; - fn new_function_declaration(name: String, arity: usize) - -> ::FunctionDeclaration; - fn new_predicate_declaration(name: String, arity: usize) - -> ::PredicateDeclaration; + fn find_or_create_function_declaration(&self, name: &str, arity: usize) + -> std::rc::Rc<::FunctionDeclaration>; + + fn find_or_create_predicate_declaration(&self, name: &str, arity: usize) + -> std::rc::Rc<::PredicateDeclaration>; + fn new_variable_declaration(name: String) -> ::VariableDeclaration; - fn find_or_create_function_declaration(&self, name: &str, arity: usize) - -> std::rc::Rc<::FunctionDeclaration>; - fn find_or_create_predicate_declaration(&self, name: &str, arity: usize) - -> std::rc::Rc<::PredicateDeclaration>; fn find_or_create_variable_declaration( variable_declaration_stack_layer: &crate::VariableDeclarationStackLayer, variable_name: &str) @@ -93,26 +91,6 @@ impl Parser for DefaultParser { type Flavor = crate::flavor::DefaultFlavor; - fn new_function_declaration(name: String, arity: usize) - -> ::FunctionDeclaration - { - crate::FunctionDeclaration - { - name, - arity, - } - } - - fn new_predicate_declaration(name: String, arity: usize) - -> ::PredicateDeclaration - { - crate::PredicateDeclaration - { - name, - arity, - } - } - fn new_variable_declaration(name: String) -> ::VariableDeclaration { @@ -132,7 +110,7 @@ impl Parser for DefaultParser Some(declaration) => std::rc::Rc::clone(&declaration), None => { - let declaration = Self::new_function_declaration(name.to_string(), arity); + let declaration = crate::FunctionDeclaration::new(name.to_string(), arity); let declaration = std::rc::Rc::new(declaration); function_declarations.insert(std::rc::Rc::clone(&declaration)); @@ -152,7 +130,7 @@ impl Parser for DefaultParser Some(declaration) => std::rc::Rc::clone(&declaration), None => { - let declaration = Self::new_predicate_declaration(name.to_string(), arity); + let declaration = crate::PredicateDeclaration::new(name.to_string(), arity); let declaration = std::rc::Rc::new(declaration); predicate_declarations.insert(std::rc::Rc::clone(&declaration));