From 8e32b58c99c2472d5ab1d40cbf5f97edf4cfad66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20L=C3=BChne?= Date: Mon, 13 Apr 2020 22:16:01 +0200 Subject: [PATCH] Remove unneeded indirection from vector types The type aliases for vectors of formulas and terms were defined as vectors of boxed formulas and terms, respectively. This is an unnecessary indirection, so store the formulas and terms directly. --- src/ast.rs | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/ast.rs b/src/ast.rs index 785947e..08a44dc 100644 --- a/src/ast.rs +++ b/src/ast.rs @@ -165,12 +165,12 @@ impl BinaryOperation pub struct Function { pub declaration: std::rc::Rc, - pub arguments: Vec>, + pub arguments: Terms, } impl Function { - pub fn new(declaration: std::rc::Rc, arguments: Vec>) -> Self + pub fn new(declaration: std::rc::Rc, arguments: Terms) -> Self { assert_eq!(declaration.arity, arguments.len(), "function has a different number of arguments then declared"); @@ -288,12 +288,12 @@ impl Implies pub struct Predicate { pub declaration: std::rc::Rc, - pub arguments: Vec>, + pub arguments: Terms, } impl Predicate { - pub fn new(declaration: std::rc::Rc, arguments: Vec>) -> Self + pub fn new(declaration: std::rc::Rc, arguments: Terms) -> Self { assert_eq!(declaration.arity, arguments.len(), "predicate has a different number of arguments then declared"); @@ -320,7 +320,7 @@ pub enum Term Variable(Variable), } -pub type Terms = Vec>; +pub type Terms = Vec; impl Term { @@ -359,8 +359,7 @@ impl Term Self::boolean(false) } - pub fn function(declaration: std::rc::Rc, arguments: Vec>) - -> Self + pub fn function(declaration: std::rc::Rc, arguments: Terms) -> Self { Self::Function(Function::new(declaration, arguments)) } @@ -440,7 +439,7 @@ pub enum Formula Predicate(Predicate), } -pub type Formulas = Vec>; +pub type Formulas = Vec; impl Formula { @@ -533,8 +532,7 @@ impl Formula Self::Or(arguments) } - pub fn predicate(declaration: std::rc::Rc, arguments: Vec>) - -> Self + pub fn predicate(declaration: std::rc::Rc, arguments: Terms) -> Self { Self::Predicate(Predicate::new(declaration, arguments)) }