diff --git a/src/main.rs b/src/main.rs index 918823c..01f820b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -15,7 +15,7 @@ enum Command #[structopt(long, default_value = "human-readable")] output_format: anthem::output::Format, - /// Input predicates (examples: p/0, q/2) + /// Input predicates (examples: p, q/2) #[structopt(long, parse(try_from_str = anthem::parse_predicate_declaration))] input_predicates: Vec>, diff --git a/src/utils.rs b/src/utils.rs index c5e6d9c..e7caf0a 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -52,11 +52,7 @@ pub fn parse_predicate_declaration(input: &str) { let mut parts = input.split("/"); - let name = match parts.next() - { - Some(name) => name.to_string(), - None => return Err(crate::Error::new_parse_predicate_declaration()), - }; + let name = parts.next().ok_or(crate::Error::new_parse_predicate_declaration())?; use std::str::FromStr; @@ -64,7 +60,7 @@ pub fn parse_predicate_declaration(input: &str) { Some(arity) => usize::from_str(arity).map_err(|_| crate::Error::new_parse_predicate_declaration())?, - None => return Err(crate::Error::new_parse_predicate_declaration()), + None => 0, }; if parts.next().is_some() @@ -74,7 +70,7 @@ pub fn parse_predicate_declaration(input: &str) Ok(std::rc::Rc::new(foliage::PredicateDeclaration { - name, + name: name.to_string(), arity, })) }