Skip to content

Commit a54e821

Browse files
committed
Update winnow and fix compile errors
1 parent 2e2a956 commit a54e821

File tree

7 files changed

+25
-25
lines changed

7 files changed

+25
-25
lines changed

Cargo.lock

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ wide = "0.7.32"
2121
eyre = "0.6.12"
2222
nohash-hasher = "0.2.0"
2323
itoa = "1.0"
24-
winnow = { version = "0.6.26", features = ["simd"] }
24+
winnow = { version = "0.7.4", features = ["simd"] }
2525
tinystr = { version = "0.8.1", features = ["std"] }
2626
fnv = "1.0.7"
2727
petgraph = { version = "0.7.1", features = ["rayon"] }

src/2015/09.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use rayon::prelude::*;
55

66
use winnow::ascii::{alpha1, digit1};
77
use winnow::combinator::seq;
8-
use winnow::error::{ContextError, ErrMode, ParseError, StrContext};
8+
use winnow::error::{ContextError, StrContext};
99
use winnow::prelude::*;
1010

1111
use crate::common::{TryFromStr, TryParse};
@@ -107,7 +107,7 @@ struct Leg<'s> {
107107
}
108108

109109
impl<'s> TryFromStr<'s> for Leg<'s> {
110-
type Err = ParseError<&'s str, ErrMode<ContextError>>;
110+
type Err = ContextError;
111111

112112
fn try_from_str(input: &'s str) -> Result<Self, Self::Err> {
113113
seq! { Leg {
@@ -117,6 +117,6 @@ impl<'s> TryFromStr<'s> for Leg<'s> {
117117
_: " = ",
118118
distance: digit1.context(StrContext::Label("distance")).parse_to()
119119
}}
120-
.parse(input.trim())
120+
.parse_next(&mut input.trim())
121121
}
122122
}

src/2015/13.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use petgraph::{Directed, Graph};
55
use rayon::prelude::*;
66
use winnow::ascii::{alpha1, digit1};
77
use winnow::combinator::{alt, eof, preceded, separated_pair, seq};
8-
use winnow::error::{ContextError, ParseError};
8+
use winnow::error::{ContextError, ErrMode};
99
use winnow::prelude::*;
1010

1111
use crate::common::{TryFromStr, TryParse};
@@ -108,7 +108,7 @@ struct Relationship<'s> {
108108
}
109109

110110
impl<'s> TryFromStr<'s> for Relationship<'s> {
111-
type Err = ParseError<&'s str, ContextError>;
111+
type Err = ErrMode<ContextError>;
112112

113113
fn try_from_str(value: &'s str) -> Result<Self, Self::Err> {
114114
fn parse_feeling(input: &mut &str) -> ModalResult<isize> {
@@ -128,7 +128,7 @@ impl<'s> TryFromStr<'s> for Relationship<'s> {
128128
object: alpha1,
129129
_: preceded('.', eof)
130130
}}
131-
.parse(value.trim())
131+
.parse_next(&mut value.trim())
132132
}
133133
}
134134

src/2015/14.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use rayon::prelude::*;
99
use winnow::{
1010
ascii::{alpha1, digit1},
1111
combinator::{eof, preceded, seq},
12-
error::{ContextError, ParseError},
12+
error::ContextError,
1313
Parser,
1414
};
1515

@@ -180,7 +180,7 @@ impl<'s> TryFromStr<'s> for Reindeer<'s> {
180180
rest_duration: digit1.parse_to(),
181181
_: preceded(" seconds.", eof)
182182
}}
183-
.parse(value.trim())
184-
.map_err(|e: ParseError<_, ContextError>| eyre!("{e}"))
183+
.parse_next(&mut value.trim())
184+
.map_err(|e: ContextError| eyre!("{e}"))
185185
}
186186
}

src/2015/15.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -221,25 +221,25 @@ impl AddAssign for Qualities {
221221
impl<'s> TryFromStr<'s> for Ingredient<'s> {
222222
type Err = Report;
223223

224-
fn try_from_str(value: &'s str) -> Result<Self> {
224+
fn try_from_str(mut value: &'s str) -> Result<Self> {
225225
seq! {Ingredient {
226226
name: alpha1::<_, ContextError>,
227227
qualities: seq!{Qualities {
228228
_: ": capacity ",
229-
capacity: dec_int,
229+
capacity: dec_int::<_, _, ContextError>,
230230
_: ", durability ",
231-
durability: dec_int,
231+
durability: dec_int::<_, _, ContextError>,
232232
_: ", flavor ",
233-
flavor: dec_int,
233+
flavor: dec_int::<_, _, ContextError>,
234234
_: ", texture ",
235-
texture: dec_int,
235+
texture: dec_int::<_, _, ContextError>,
236236
_: ", calories ",
237-
calories: dec_int,
237+
calories: dec_int::<_, _, ContextError>,
238238
}},
239-
_: eof
239+
_: eof::<_, ContextError>
240240
}}
241-
.parse(value)
242-
.map_err(|e| eyre!("{e}"))
241+
.parse_next(&mut value)
242+
.map_err(|e: ContextError| eyre!("{e}"))
243243
}
244244
}
245245

src/2016/01.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -200,13 +200,13 @@ impl FromStr for Instruction {
200200
type Err = Report;
201201

202202
#[inline]
203-
fn from_str(s: &str) -> Result<Self, Self::Err> {
203+
fn from_str(mut s: &str) -> Result<Self, Self::Err> {
204204
seq! {Instruction {
205205
turn: alt::<_, _, ContextError, _>(("R", "L")).parse_to(),
206-
steps: dec_uint
206+
steps: dec_uint::<_, _, ContextError>
207207
}}
208-
.parse(s)
209-
.map_err(|_| eyre!("Invalid instruction: {s}"))
208+
.parse_next(&mut s)
209+
.map_err(|_: ContextError| eyre!("Invalid instruction: {s}"))
210210
}
211211
}
212212

0 commit comments

Comments
 (0)