]> Repositorios git - scryer-prolog.git/commitdiff
more clippy lints
authorSkgland <[email protected]>
Sat, 6 Feb 2021 18:58:31 +0000 (19:58 +0100)
committerSkgland <[email protected]>
Sat, 6 Feb 2021 21:13:06 +0000 (22:13 +0100)
crates/prolog_parser/src/ast.rs
src/machine/preprocessor.rs

index 2f976a0e66a67c17b5bc6417d1bbcc8aad3fd576..37c98b55efdf7269e2e767293f76556e1d9755b2 100644 (file)
@@ -561,7 +561,7 @@ impl PartialEq for Constant {
 impl Eq for Constant {}
 
 impl Constant {
-    pub fn to_atom(self) -> Option<ClauseName> {
+    pub fn to_atom(&self) -> Option<ClauseName> {
         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<Constant> {
+    pub fn into_constant(self) -> Option<Constant> {
         match self {
             Term::Constant(_, c) => Some(c),
             _ => None,
index f0c7f8b5dc2acba1f210544713fd19361d1d339d..a15924c146d2da431900b1fb5a89f4a738a8c109 100644 (file)
@@ -95,7 +95,7 @@ fn setup_predicate_indicator(term: &mut Term) -> Result<PredicateKey, Compilatio
             let name = *terms.pop().unwrap();
 
             let arity = arity
-                .to_constant()
+                .into_constant()
                 .and_then(|c| match c {
                     Constant::Integer(n) => n.to_usize(),
                     Constant::Fixnum(n) => usize::try_from(n).ok(),
@@ -104,7 +104,7 @@ fn setup_predicate_indicator(term: &mut Term) -> Result<PredicateKey, Compilatio
                 .ok_or(CompilationError::InvalidModuleExport)?;
 
             let name = name
-                .to_constant()
+                .into_constant()
                 .and_then(|c| c.to_atom())
                 .ok_or(CompilationError::InvalidModuleExport)?;
 
@@ -174,7 +174,7 @@ pub(super) fn setup_module_export_list(
         export_list = *t2;
     }
 
-    if export_list.to_constant() != Some(Constant::EmptyList) {
+    if export_list.into_constant() != Some(Constant::EmptyList) {
         Err(CompilationError::InvalidModuleDecl)
     } else {
         Ok(exports)
@@ -189,7 +189,7 @@ fn setup_module_decl(
     let name = terms
         .pop()
         .unwrap()
-        .to_constant()
+        .into_constant()
         .and_then(|c| c.to_atom())
         .ok_or(CompilationError::InvalidModuleDecl)?;
 
@@ -205,7 +205,7 @@ fn setup_use_module_decl(mut terms: Vec<Box<Term>>) -> Result<ModuleSource, Comp
             terms
                 .pop()
                 .unwrap()
-                .to_constant()
+                .into_constant()
                 .and_then(|c| c.to_atom())
                 .map(|c| ModuleSource::Library(c))
                 .ok_or(CompilationError::InvalidUseModuleDecl)
@@ -257,7 +257,7 @@ fn setup_qualified_import(
             terms
                 .pop()
                 .unwrap()
-                .to_constant()
+                .into_constant()
                 .and_then(|c| c.to_atom())
                 .map(|c| ModuleSource::Library(c))
                 .ok_or(CompilationError::InvalidUseModuleDecl)
@@ -273,7 +273,7 @@ fn setup_qualified_import(
         export_list = *t2;
     }
 
-    if export_list.to_constant() != Some(Constant::EmptyList) {
+    if export_list.into_constant() != Some(Constant::EmptyList) {
         Err(CompilationError::InvalidModuleDecl)
     } else {
         Ok((module_src, exports))