From: Skgland Date: Sat, 6 Feb 2021 18:58:31 +0000 (+0100) Subject: more clippy lints X-Git-Tag: v0.9.0~150^2~65^2~6^2~3 X-Git-Url: https://git.sagredo.dev/?a=commitdiff_plain;h=3f7a60d84b58a13eb38cd31f622797d2d7140a81;p=scryer-prolog.git more clippy lints --- diff --git a/crates/prolog_parser/src/ast.rs b/crates/prolog_parser/src/ast.rs index 2f976a0e..37c98b55 100644 --- a/crates/prolog_parser/src/ast.rs +++ b/crates/prolog_parser/src/ast.rs @@ -561,7 +561,7 @@ impl PartialEq for Constant { impl Eq for Constant {} impl Constant { - pub fn to_atom(self) -> Option { + pub fn to_atom(&self) -> Option { match self { Constant::Atom(a, _) => Some(a.defrock_brackets()), _ => None, @@ -678,7 +678,7 @@ impl ClauseName { !self.as_str().is_empty() && self.as_str().chars().nth(1).is_none() } - pub fn defrock_brackets(self) -> Self { + pub fn defrock_brackets(&self) -> Self { fn defrock_brackets(s: &str) -> &str { if s.starts_with('(') && s.ends_with(')') { &s[1..s.len() - 1] @@ -726,7 +726,7 @@ impl Term { } } - pub fn to_constant(self) -> Option { + pub fn into_constant(self) -> Option { match self { Term::Constant(_, c) => Some(c), _ => None, diff --git a/src/machine/preprocessor.rs b/src/machine/preprocessor.rs index f0c7f8b5..a15924c1 100644 --- a/src/machine/preprocessor.rs +++ b/src/machine/preprocessor.rs @@ -95,7 +95,7 @@ fn setup_predicate_indicator(term: &mut Term) -> Result n.to_usize(), Constant::Fixnum(n) => usize::try_from(n).ok(), @@ -104,7 +104,7 @@ fn setup_predicate_indicator(term: &mut Term) -> Result>) -> Result