Rename formatter variables
These formatter objects were just named “format,” but there’s no need to abbreviate that. This renames all occurrences to “formatter” for clarity.
This commit is contained in:
parent
d67e530fec
commit
9216bbbe31
@ -2,29 +2,29 @@ use super::terms::*;
|
|||||||
|
|
||||||
impl std::fmt::Debug for crate::ImplicationDirection
|
impl std::fmt::Debug for crate::ImplicationDirection
|
||||||
{
|
{
|
||||||
fn fmt(&self, format: &mut std::fmt::Formatter) -> std::fmt::Result
|
fn fmt(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result
|
||||||
{
|
{
|
||||||
match &self
|
match &self
|
||||||
{
|
{
|
||||||
Self::LeftToRight => write!(format, "left to right"),
|
Self::LeftToRight => write!(formatter, "left to right"),
|
||||||
Self::RightToLeft => write!(format, "right to left"),
|
Self::RightToLeft => write!(formatter, "right to left"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::fmt::Debug for crate::PredicateDeclaration
|
impl std::fmt::Debug for crate::PredicateDeclaration
|
||||||
{
|
{
|
||||||
fn fmt(&self, format: &mut std::fmt::Formatter) -> std::fmt::Result
|
fn fmt(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result
|
||||||
{
|
{
|
||||||
write!(format, "{}/{}", &self.name, self.arity)
|
write!(formatter, "{}/{}", &self.name, self.arity)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::fmt::Display for crate::PredicateDeclaration
|
impl std::fmt::Display for crate::PredicateDeclaration
|
||||||
{
|
{
|
||||||
fn fmt(&self, format: &mut std::fmt::Formatter) -> std::fmt::Result
|
fn fmt(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result
|
||||||
{
|
{
|
||||||
write!(format, "{:?}", &self)
|
write!(formatter, "{:?}", &self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,13 +126,13 @@ fn display_formula<'formula>(formula: &'formula crate::Formula,
|
|||||||
|
|
||||||
impl<'formula> std::fmt::Debug for FormulaDisplay<'formula>
|
impl<'formula> std::fmt::Debug for FormulaDisplay<'formula>
|
||||||
{
|
{
|
||||||
fn fmt(&self, format: &mut std::fmt::Formatter) -> std::fmt::Result
|
fn fmt(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result
|
||||||
{
|
{
|
||||||
let requires_parentheses = self.requires_parentheses();
|
let requires_parentheses = self.requires_parentheses();
|
||||||
|
|
||||||
if requires_parentheses
|
if requires_parentheses
|
||||||
{
|
{
|
||||||
write!(format, "(")?;
|
write!(formatter, "(")?;
|
||||||
}
|
}
|
||||||
|
|
||||||
match &self.formula
|
match &self.formula
|
||||||
@ -141,23 +141,23 @@ impl<'formula> std::fmt::Debug for FormulaDisplay<'formula>
|
|||||||
{
|
{
|
||||||
if exists.parameters.is_empty()
|
if exists.parameters.is_empty()
|
||||||
{
|
{
|
||||||
write!(format, "{:?}", display_formula(&exists.argument, self.parent_formula,
|
write!(formatter, "{:?}", display_formula(&exists.argument, self.parent_formula,
|
||||||
self.position))?;
|
self.position))?;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
write!(format, "exists")?;
|
write!(formatter, "exists")?;
|
||||||
|
|
||||||
let mut separator = " ";
|
let mut separator = " ";
|
||||||
|
|
||||||
for parameter in exists.parameters.iter()
|
for parameter in exists.parameters.iter()
|
||||||
{
|
{
|
||||||
write!(format, "{}{:?}", separator, parameter)?;
|
write!(formatter, "{}{:?}", separator, parameter)?;
|
||||||
|
|
||||||
separator = ", "
|
separator = ", "
|
||||||
}
|
}
|
||||||
|
|
||||||
write!(format, " {:?}", display_formula(&exists.argument, Some(self.formula),
|
write!(formatter, " {:?}", display_formula(&exists.argument, Some(self.formula),
|
||||||
FormulaPosition::Any))?;
|
FormulaPosition::Any))?;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -165,33 +165,33 @@ impl<'formula> std::fmt::Debug for FormulaDisplay<'formula>
|
|||||||
{
|
{
|
||||||
if for_all.parameters.is_empty()
|
if for_all.parameters.is_empty()
|
||||||
{
|
{
|
||||||
write!(format, "{:?}", display_formula(&for_all.argument, self.parent_formula,
|
write!(formatter, "{:?}", display_formula(&for_all.argument,
|
||||||
self.position))?;
|
self.parent_formula, self.position))?;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
write!(format, "forall")?;
|
write!(formatter, "forall")?;
|
||||||
|
|
||||||
let mut separator = " ";
|
let mut separator = " ";
|
||||||
|
|
||||||
for parameter in for_all.parameters.iter()
|
for parameter in for_all.parameters.iter()
|
||||||
{
|
{
|
||||||
write!(format, "{}{:?}", separator, parameter)?;
|
write!(formatter, "{}{:?}", separator, parameter)?;
|
||||||
|
|
||||||
separator = ", "
|
separator = ", "
|
||||||
}
|
}
|
||||||
|
|
||||||
write!(format, " {:?}", display_formula(&for_all.argument, Some(self.formula),
|
write!(formatter, " {:?}", display_formula(&for_all.argument,
|
||||||
FormulaPosition::Any))?;
|
Some(self.formula), FormulaPosition::Any))?;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
crate::Formula::Not(argument) => write!(format, "not {:?}",
|
crate::Formula::Not(argument) => write!(formatter, "not {:?}",
|
||||||
display_formula(argument, Some(self.formula), FormulaPosition::Any))?,
|
display_formula(argument, Some(self.formula), FormulaPosition::Any))?,
|
||||||
crate::Formula::And(arguments) =>
|
crate::Formula::And(arguments) =>
|
||||||
{
|
{
|
||||||
if arguments.is_empty()
|
if arguments.is_empty()
|
||||||
{
|
{
|
||||||
write!(format, "true")?;
|
write!(formatter, "true")?;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -205,7 +205,7 @@ impl<'formula> std::fmt::Debug for FormulaDisplay<'formula>
|
|||||||
|
|
||||||
for argument in arguments
|
for argument in arguments
|
||||||
{
|
{
|
||||||
write!(format, "{}{:?}", separator,
|
write!(formatter, "{}{:?}", separator,
|
||||||
display_formula(argument, parent_formula, position))?;
|
display_formula(argument, parent_formula, position))?;
|
||||||
|
|
||||||
separator = " and "
|
separator = " and "
|
||||||
@ -216,7 +216,7 @@ impl<'formula> std::fmt::Debug for FormulaDisplay<'formula>
|
|||||||
{
|
{
|
||||||
if arguments.is_empty()
|
if arguments.is_empty()
|
||||||
{
|
{
|
||||||
write!(format, "false")?;
|
write!(formatter, "false")?;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -230,7 +230,7 @@ impl<'formula> std::fmt::Debug for FormulaDisplay<'formula>
|
|||||||
|
|
||||||
for argument in arguments
|
for argument in arguments
|
||||||
{
|
{
|
||||||
write!(format, "{}{:?}", separator,
|
write!(formatter, "{}{:?}", separator,
|
||||||
display_formula(argument, parent_formula, position))?;
|
display_formula(argument, parent_formula, position))?;
|
||||||
|
|
||||||
separator = " or "
|
separator = " or "
|
||||||
@ -239,16 +239,16 @@ impl<'formula> std::fmt::Debug for FormulaDisplay<'formula>
|
|||||||
},
|
},
|
||||||
crate::Formula::Implies(crate::Implies{direction, antecedent, implication}) =>
|
crate::Formula::Implies(crate::Implies{direction, antecedent, implication}) =>
|
||||||
{
|
{
|
||||||
let format_antecedent = |format: &mut std::fmt::Formatter| -> Result<_, _>
|
let format_antecedent = |formatter: &mut std::fmt::Formatter| -> Result<_, _>
|
||||||
{
|
{
|
||||||
write!(format, "{:?}",
|
write!(formatter, "{:?}",
|
||||||
display_formula(antecedent, Some(self.formula),
|
display_formula(antecedent, Some(self.formula),
|
||||||
FormulaPosition::ImpliesAntecedent))
|
FormulaPosition::ImpliesAntecedent))
|
||||||
};
|
};
|
||||||
|
|
||||||
let format_implication = |format: &mut std::fmt::Formatter| -> Result<_, _>
|
let format_implication = |formatter: &mut std::fmt::Formatter| -> Result<_, _>
|
||||||
{
|
{
|
||||||
write!(format, "{:?}",
|
write!(formatter, "{:?}",
|
||||||
display_formula(implication, Some(self.formula), FormulaPosition::Any))
|
display_formula(implication, Some(self.formula), FormulaPosition::Any))
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -256,15 +256,15 @@ impl<'formula> std::fmt::Debug for FormulaDisplay<'formula>
|
|||||||
{
|
{
|
||||||
crate::ImplicationDirection::LeftToRight =>
|
crate::ImplicationDirection::LeftToRight =>
|
||||||
{
|
{
|
||||||
format_antecedent(format)?;
|
format_antecedent(formatter)?;
|
||||||
write!(format, " -> ")?;
|
write!(formatter, " -> ")?;
|
||||||
format_implication(format)?;
|
format_implication(formatter)?;
|
||||||
},
|
},
|
||||||
crate::ImplicationDirection::RightToLeft =>
|
crate::ImplicationDirection::RightToLeft =>
|
||||||
{
|
{
|
||||||
format_implication(format)?;
|
format_implication(formatter)?;
|
||||||
write!(format, " <- ")?;
|
write!(formatter, " <- ")?;
|
||||||
format_antecedent(format)?;
|
format_antecedent(formatter)?;
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -272,7 +272,7 @@ impl<'formula> std::fmt::Debug for FormulaDisplay<'formula>
|
|||||||
{
|
{
|
||||||
if arguments.is_empty()
|
if arguments.is_empty()
|
||||||
{
|
{
|
||||||
write!(format, "true")?;
|
write!(formatter, "true")?;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -286,7 +286,7 @@ impl<'formula> std::fmt::Debug for FormulaDisplay<'formula>
|
|||||||
|
|
||||||
for argument in arguments
|
for argument in arguments
|
||||||
{
|
{
|
||||||
write!(format, "{}{:?}", separator,
|
write!(formatter, "{}{:?}", separator,
|
||||||
display_formula(argument, parent_formula, position))?;
|
display_formula(argument, parent_formula, position))?;
|
||||||
|
|
||||||
separator = " <-> "
|
separator = " <-> "
|
||||||
@ -305,39 +305,39 @@ impl<'formula> std::fmt::Debug for FormulaDisplay<'formula>
|
|||||||
crate::ComparisonOperator::NotEqual => "!=",
|
crate::ComparisonOperator::NotEqual => "!=",
|
||||||
};
|
};
|
||||||
|
|
||||||
write!(format, "{:?} {} {:?}",
|
write!(formatter, "{:?} {} {:?}",
|
||||||
display_term(&compare.left, None, TermPosition::Any),
|
display_term(&compare.left, None, TermPosition::Any),
|
||||||
operator_string,
|
operator_string,
|
||||||
display_term(&compare.right, None, TermPosition::Any))?;
|
display_term(&compare.right, None, TermPosition::Any))?;
|
||||||
},
|
},
|
||||||
crate::Formula::Boolean(true) => write!(format, "true")?,
|
crate::Formula::Boolean(true) => write!(formatter, "true")?,
|
||||||
crate::Formula::Boolean(false) => write!(format, "false")?,
|
crate::Formula::Boolean(false) => write!(formatter, "false")?,
|
||||||
crate::Formula::Predicate(predicate) =>
|
crate::Formula::Predicate(predicate) =>
|
||||||
{
|
{
|
||||||
write!(format, "{}", predicate.declaration.name)?;
|
write!(formatter, "{}", predicate.declaration.name)?;
|
||||||
|
|
||||||
if !predicate.arguments.is_empty()
|
if !predicate.arguments.is_empty()
|
||||||
{
|
{
|
||||||
write!(format, "(")?;
|
write!(formatter, "(")?;
|
||||||
|
|
||||||
let mut separator = "";
|
let mut separator = "";
|
||||||
|
|
||||||
for argument in &predicate.arguments
|
for argument in &predicate.arguments
|
||||||
{
|
{
|
||||||
write!(format, "{}{:?}", separator, display_term(argument, None,
|
write!(formatter, "{}{:?}", separator, display_term(argument, None,
|
||||||
TermPosition::Any))?;
|
TermPosition::Any))?;
|
||||||
|
|
||||||
separator = ", "
|
separator = ", "
|
||||||
}
|
}
|
||||||
|
|
||||||
write!(format, ")")?;
|
write!(formatter, ")")?;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
if requires_parentheses
|
if requires_parentheses
|
||||||
{
|
{
|
||||||
write!(format, ")")?;
|
write!(formatter, ")")?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
@ -346,25 +346,25 @@ impl<'formula> std::fmt::Debug for FormulaDisplay<'formula>
|
|||||||
|
|
||||||
impl<'formula> std::fmt::Display for FormulaDisplay<'formula>
|
impl<'formula> std::fmt::Display for FormulaDisplay<'formula>
|
||||||
{
|
{
|
||||||
fn fmt(&self, format: &mut std::fmt::Formatter) -> std::fmt::Result
|
fn fmt(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result
|
||||||
{
|
{
|
||||||
write!(format, "{:?}", self)
|
write!(formatter, "{:?}", self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::fmt::Debug for crate::Formula
|
impl std::fmt::Debug for crate::Formula
|
||||||
{
|
{
|
||||||
fn fmt(&self, format: &mut std::fmt::Formatter) -> std::fmt::Result
|
fn fmt(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result
|
||||||
{
|
{
|
||||||
write!(format, "{:?}", display_formula(&self, None, FormulaPosition::Any))
|
write!(formatter, "{:?}", display_formula(&self, None, FormulaPosition::Any))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::fmt::Display for crate::Formula
|
impl std::fmt::Display for crate::Formula
|
||||||
{
|
{
|
||||||
fn fmt(&self, format: &mut std::fmt::Formatter) -> std::fmt::Result
|
fn fmt(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result
|
||||||
{
|
{
|
||||||
write!(format, "{}", display_formula(&self, None, FormulaPosition::Any))
|
write!(formatter, "{}", display_formula(&self, None, FormulaPosition::Any))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,52 +1,52 @@
|
|||||||
impl std::fmt::Debug for crate::SpecialInteger
|
impl std::fmt::Debug for crate::SpecialInteger
|
||||||
{
|
{
|
||||||
fn fmt(&self, format: &mut std::fmt::Formatter) -> std::fmt::Result
|
fn fmt(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result
|
||||||
{
|
{
|
||||||
match &self
|
match &self
|
||||||
{
|
{
|
||||||
Self::Infimum => write!(format, "#inf"),
|
Self::Infimum => write!(formatter, "#inf"),
|
||||||
Self::Supremum => write!(format, "#sup"),
|
Self::Supremum => write!(formatter, "#sup"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::fmt::Display for crate::SpecialInteger
|
impl std::fmt::Display for crate::SpecialInteger
|
||||||
{
|
{
|
||||||
fn fmt(&self, format: &mut std::fmt::Formatter) -> std::fmt::Result
|
fn fmt(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result
|
||||||
{
|
{
|
||||||
write!(format, "{:?}", &self)
|
write!(formatter, "{:?}", &self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::fmt::Debug for crate::FunctionDeclaration
|
impl std::fmt::Debug for crate::FunctionDeclaration
|
||||||
{
|
{
|
||||||
fn fmt(&self, format: &mut std::fmt::Formatter) -> std::fmt::Result
|
fn fmt(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result
|
||||||
{
|
{
|
||||||
write!(format, "{}/{}", &self.name, self.arity)
|
write!(formatter, "{}/{}", &self.name, self.arity)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::fmt::Display for crate::FunctionDeclaration
|
impl std::fmt::Display for crate::FunctionDeclaration
|
||||||
{
|
{
|
||||||
fn fmt(&self, format: &mut std::fmt::Formatter) -> std::fmt::Result
|
fn fmt(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result
|
||||||
{
|
{
|
||||||
write!(format, "{:?}", &self)
|
write!(formatter, "{:?}", &self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::fmt::Debug for crate::VariableDeclaration
|
impl std::fmt::Debug for crate::VariableDeclaration
|
||||||
{
|
{
|
||||||
fn fmt(&self, format: &mut std::fmt::Formatter) -> std::fmt::Result
|
fn fmt(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result
|
||||||
{
|
{
|
||||||
write!(format, "{}", &self.name)
|
write!(formatter, "{}", &self.name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::fmt::Display for crate::VariableDeclaration
|
impl std::fmt::Display for crate::VariableDeclaration
|
||||||
{
|
{
|
||||||
fn fmt(&self, format: &mut std::fmt::Formatter) -> std::fmt::Result
|
fn fmt(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result
|
||||||
{
|
{
|
||||||
write!(format, "{:?}", &self)
|
write!(formatter, "{:?}", &self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,27 +163,27 @@ pub(crate) fn display_term<'term>(term: &'term crate::Term, parent_term: Option<
|
|||||||
|
|
||||||
impl<'term> std::fmt::Debug for TermDisplay<'term>
|
impl<'term> std::fmt::Debug for TermDisplay<'term>
|
||||||
{
|
{
|
||||||
fn fmt(&self, format: &mut std::fmt::Formatter) -> std::fmt::Result
|
fn fmt(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result
|
||||||
{
|
{
|
||||||
let requires_parentheses = self.requires_parentheses();
|
let requires_parentheses = self.requires_parentheses();
|
||||||
|
|
||||||
if requires_parentheses
|
if requires_parentheses
|
||||||
{
|
{
|
||||||
write!(format, "(")?;
|
write!(formatter, "(")?;
|
||||||
}
|
}
|
||||||
|
|
||||||
match &self.term
|
match &self.term
|
||||||
{
|
{
|
||||||
crate::Term::Boolean(true) => write!(format, "true")?,
|
crate::Term::Boolean(true) => write!(formatter, "true")?,
|
||||||
crate::Term::Boolean(false) => write!(format, "false")?,
|
crate::Term::Boolean(false) => write!(formatter, "false")?,
|
||||||
crate::Term::SpecialInteger(value) => write!(format, "{:?}", value)?,
|
crate::Term::SpecialInteger(value) => write!(formatter, "{:?}", value)?,
|
||||||
crate::Term::Integer(value) => write!(format, "{}", value)?,
|
crate::Term::Integer(value) => write!(formatter, "{}", value)?,
|
||||||
crate::Term::String(value) => write!(format, "\"{}\"",
|
crate::Term::String(value) => write!(formatter, "\"{}\"",
|
||||||
value.replace("\\", "\\\\").replace("\n", "\\n").replace("\t", "\\t"))?,
|
value.replace("\\", "\\\\").replace("\n", "\\n").replace("\t", "\\t"))?,
|
||||||
crate::Term::Variable(variable) => write!(format, "{:?}", variable.declaration)?,
|
crate::Term::Variable(variable) => write!(formatter, "{:?}", variable.declaration)?,
|
||||||
crate::Term::Function(function) =>
|
crate::Term::Function(function) =>
|
||||||
{
|
{
|
||||||
write!(format, "{}", function.declaration.name)?;
|
write!(formatter, "{}", function.declaration.name)?;
|
||||||
|
|
||||||
assert!(function.declaration.arity == function.arguments.len(),
|
assert!(function.declaration.arity == function.arguments.len(),
|
||||||
"number of function arguments differs from declaration (expected {}, got {})",
|
"number of function arguments differs from declaration (expected {}, got {})",
|
||||||
@ -191,19 +191,19 @@ impl<'term> std::fmt::Debug for TermDisplay<'term>
|
|||||||
|
|
||||||
if !function.arguments.is_empty()
|
if !function.arguments.is_empty()
|
||||||
{
|
{
|
||||||
write!(format, "(")?;
|
write!(formatter, "(")?;
|
||||||
|
|
||||||
let mut separator = "";
|
let mut separator = "";
|
||||||
|
|
||||||
for argument in &function.arguments
|
for argument in &function.arguments
|
||||||
{
|
{
|
||||||
write!(format, "{}{:?}", separator,
|
write!(formatter, "{}{:?}", separator,
|
||||||
display_term(&argument, Some(self.term), TermPosition::Any))?;
|
display_term(&argument, Some(self.term), TermPosition::Any))?;
|
||||||
|
|
||||||
separator = ", ";
|
separator = ", ";
|
||||||
}
|
}
|
||||||
|
|
||||||
write!(format, ")")?;
|
write!(formatter, ")")?;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
crate::Term::BinaryOperation(binary_operation) =>
|
crate::Term::BinaryOperation(binary_operation) =>
|
||||||
@ -218,24 +218,24 @@ impl<'term> std::fmt::Debug for TermDisplay<'term>
|
|||||||
crate::BinaryOperator::Exponentiate => "**",
|
crate::BinaryOperator::Exponentiate => "**",
|
||||||
};
|
};
|
||||||
|
|
||||||
write!(format, "{:?} {} {:?}",
|
write!(formatter, "{:?} {} {:?}",
|
||||||
display_term(&binary_operation.left, Some(self.term), TermPosition::Left),
|
display_term(&binary_operation.left, Some(self.term), TermPosition::Left),
|
||||||
operator_string,
|
operator_string,
|
||||||
display_term(&binary_operation.right, Some(self.term), TermPosition::Right))?;
|
display_term(&binary_operation.right, Some(self.term), TermPosition::Right))?;
|
||||||
},
|
},
|
||||||
crate::Term::UnaryOperation(
|
crate::Term::UnaryOperation(
|
||||||
crate::UnaryOperation{operator: crate::UnaryOperator::Negative, argument})
|
crate::UnaryOperation{operator: crate::UnaryOperator::Negative, argument})
|
||||||
=> write!(format, "-{:?}",
|
=> write!(formatter, "-{:?}",
|
||||||
display_term(argument, Some(self.term), TermPosition::Any))?,
|
display_term(argument, Some(self.term), TermPosition::Any))?,
|
||||||
crate::Term::UnaryOperation(
|
crate::Term::UnaryOperation(
|
||||||
crate::UnaryOperation{operator: crate::UnaryOperator::AbsoluteValue, argument})
|
crate::UnaryOperation{operator: crate::UnaryOperator::AbsoluteValue, argument})
|
||||||
=> write!(format, "|{:?}|",
|
=> write!(formatter, "|{:?}|",
|
||||||
display_term(argument, Some(self.term), TermPosition::Any))?,
|
display_term(argument, Some(self.term), TermPosition::Any))?,
|
||||||
}
|
}
|
||||||
|
|
||||||
if requires_parentheses
|
if requires_parentheses
|
||||||
{
|
{
|
||||||
write!(format, ")")?;
|
write!(formatter, ")")?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
@ -244,25 +244,25 @@ impl<'term> std::fmt::Debug for TermDisplay<'term>
|
|||||||
|
|
||||||
impl<'term> std::fmt::Display for TermDisplay<'term>
|
impl<'term> std::fmt::Display for TermDisplay<'term>
|
||||||
{
|
{
|
||||||
fn fmt(&self, format: &mut std::fmt::Formatter) -> std::fmt::Result
|
fn fmt(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result
|
||||||
{
|
{
|
||||||
write!(format, "{:?}", self)
|
write!(formatter, "{:?}", self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::fmt::Debug for crate::Term
|
impl std::fmt::Debug for crate::Term
|
||||||
{
|
{
|
||||||
fn fmt(&self, format: &mut std::fmt::Formatter) -> std::fmt::Result
|
fn fmt(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result
|
||||||
{
|
{
|
||||||
write!(format, "{:?}", display_term(&self, None, TermPosition::Any))
|
write!(formatter, "{:?}", display_term(&self, None, TermPosition::Any))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl std::fmt::Display for crate::Term
|
impl std::fmt::Display for crate::Term
|
||||||
{
|
{
|
||||||
fn fmt(&self, format: &mut std::fmt::Formatter) -> std::fmt::Result
|
fn fmt(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result
|
||||||
{
|
{
|
||||||
write!(format, "{}", display_term(&self, None, TermPosition::Any))
|
write!(formatter, "{}", display_term(&self, None, TermPosition::Any))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user