From 1aa064d77896b7216f2bbcddb088a9ef0dac7ca2 Mon Sep 17 00:00:00 2001 From: Peter Schilling Date: Mon, 23 Sep 2024 20:23:39 -0700 Subject: [PATCH] --- src/lib.rs | 2 +- src/parser.rs | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 90cd52f..cd0787a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -131,7 +131,7 @@ pub fn parse_args(vars: &[String]) -> Result, String> { vars.iter().try_fold(HashMap::new(), |mut acc, arg| { let parts: Vec<&str> = arg.splitn(2, '=').collect(); if parts.len() == 2 { - let key = parser::key_parser + let key = parser::key_parser() .parse(parts[0]) .map_err(|_| format!("Invalid key format in argument: {}", arg.bold().red()))?; acc.insert(key, parts[1].to_string()); diff --git a/src/parser.rs b/src/parser.rs index 8a63eee..9d61924 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -12,6 +12,11 @@ pub enum Line { }, } +// Parser for keys +pub fn key_parser() -> impl Parser> + Clone { + text::ident().padded() +} + pub fn parser() -> impl Parser, Error = Simple> + Clone { // Parser for comments let comment = just('#') @@ -19,12 +24,6 @@ pub fn parser() -> impl Parser, Error = Simple> + Clone { .map(|(chars, _)| chars.into_iter().collect::()) .map(Line::Comment); - // Parser for keys - pub fn key_parser() -> impl Parser> + Clone { - text::ident().padded() - } - - pub use key_parser; let key = key_parser();