mirror of
https://github.com/bertptrs/adventofcode.git
synced 2025-12-27 05:40:32 +01:00
Discover the magic of nom::combinator::value
This commit is contained in:
@@ -4,6 +4,7 @@ use nom::bytes::complete::tag;
|
||||
use nom::character::complete::newline;
|
||||
use nom::combinator::iterator;
|
||||
use nom::combinator::map;
|
||||
use nom::combinator::value;
|
||||
use nom::sequence::preceded;
|
||||
use nom::sequence::terminated;
|
||||
use nom::IResult;
|
||||
@@ -36,7 +37,7 @@ impl Instruction {
|
||||
fn parse_instruction(input: &[u8]) -> IResult<&[u8], Instruction> {
|
||||
terminated(
|
||||
alt((
|
||||
map(tag("noop"), |_| Instruction::Noop),
|
||||
value(Instruction::Noop, tag("noop")),
|
||||
map(preceded(tag("addx "), nom::character::complete::i32), |v| {
|
||||
Instruction::AddX(v)
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user