more clippy lints
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user