refactor: Use preceded combinator

pull/24376/head
Jake Goulding 2020-03-16 11:35:37 -04:00 committed by Carol (Nichols || Goulding)
parent e60ae51c91
commit 1615aec46a
1 changed files with 4 additions and 4 deletions

View File

@ -5,7 +5,7 @@ use nom::{
character::complete::digit1,
combinator::{map, opt, recognize},
multi::separated_list,
sequence::{separated_pair, terminated, tuple},
sequence::{preceded, separated_pair, terminated, tuple},
IResult,
};
use snafu::Snafu;
@ -228,9 +228,9 @@ fn line_to_points(parsed_line: ParsedLine<'_>) -> Result<impl Iterator<Item = Po
}
fn parse_line(i: &str) -> IResult<&str, ParsedLine<'_>> {
let tag_set = map(tuple((tag(","), tag_set)), |(_, ts)| ts);
let field_set = map(tuple((tag(" "), field_set)), |(_, fs)| fs);
let timestamp = map(tuple((tag(" "), timestamp)), |(_, ts)| ts);
let tag_set = preceded(tag(","), tag_set);
let field_set = preceded(tag(" "), field_set);
let timestamp = preceded(tag(" "), timestamp);
let line = tuple((measurement, opt(tag_set), field_set, opt(timestamp)));