From d98b386f368127abe1b1661b4f97777e4c0f93ac Mon Sep 17 00:00:00 2001 From: Pierre Chifflier Date: Wed, 19 Jan 2022 14:26:57 +0100 Subject: [PATCH] rust/conf: convert parser to nom7 --- rust/src/conf.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/rust/src/conf.rs b/rust/src/conf.rs index b3f996945c..94a868566d 100644 --- a/rust/src/conf.rs +++ b/rust/src/conf.rs @@ -21,11 +21,12 @@ use std::os::raw::c_int; use std::ffi::{CString, CStr}; use std::ptr; use std::str; -use nom::{ +use nom7::{ character::complete::{multispace0, not_line_ending}, sequence::{preceded, tuple}, number::complete::double, combinator::verify, + IResult, }; extern { @@ -86,9 +87,7 @@ pub struct ConfNode { impl ConfNode { pub fn wrap(conf: *const c_void) -> Self { - return Self { - conf: conf, - } + return Self { conf } } pub fn get_child_value(&self, key: &str) -> Option<&str> { @@ -170,9 +169,9 @@ pub fn get_memval(arg: &str) -> Result { let arg = arg.trim(); let val: f64; let mut unit: &str; - let parser = tuple((preceded(multispace0, double), + let mut parser = tuple((preceded(multispace0, double), preceded(multispace0, verify(not_line_ending, |c: &str| c.len() < 3)))); - let r: nom::IResult<&str, (f64, &str)> = parser(arg); + let r: IResult<&str, (f64, &str)> = parser(arg); if let Ok(r) = r { val = (r.1).0; unit = (r.1).1; -- 2.47.2