Skip to content

Commit a07590c

Browse files
committed
Minor cleanup possible with 0.5
1 parent 3f8c91f commit a07590c

File tree

3 files changed

+11
-22
lines changed

3 files changed

+11
-22
lines changed

gix-object/src/commit/decode.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub fn message<'a, E: ParserError<&'a [u8]> + AddContext<&'a [u8]>>(i: &mut &'a
1919
// newline + [message]
2020
return Err(
2121
winnow::error::ErrMode::from_error_kind(i, winnow::error::ErrorKind::Eof)
22-
.map(|err: E| err.add_context(i, "newline + <message>")),
22+
.add_context(i, "newline + <message>"),
2323
);
2424
}
2525
preceded(NL, rest.map(ByteSlice::as_bstr))

gix-object/src/lib.rs

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -280,18 +280,14 @@ pub mod decode {
280280

281281
impl<'a> From<winnow::error::ErrMode<ParseError<'a>>> for Error {
282282
fn from(v: winnow::error::ErrMode<ParseError<'a>>) -> Self {
283+
let err = v.into_inner().expect("we don't have streaming parsers");
283284
Error {
284-
inner: match v {
285-
winnow::error::ErrMode::Backtrack(err) | winnow::error::ErrMode::Cut(err) => {
286-
winnow::error::VerboseError {
287-
errors: err
288-
.errors
289-
.into_iter()
290-
.map(|(i, v)| (i.as_bstr().to_owned(), v))
291-
.collect(),
292-
}
293-
}
294-
winnow::error::ErrMode::Incomplete(_) => unreachable!("we don't have streaming parsers"),
285+
inner: winnow::error::VerboseError {
286+
errors: err
287+
.errors
288+
.into_iter()
289+
.map(|(i, v)| (i.as_bstr().to_owned(), v))
290+
.collect(),
295291
},
296292
}
297293
}
@@ -325,12 +321,8 @@ pub mod decode {
325321

326322
impl<'a> From<winnow::error::ErrMode<ParseError<'a>>> for Error {
327323
fn from(v: winnow::error::ErrMode<ParseError<'a>>) -> Self {
328-
Error {
329-
inner: match v {
330-
winnow::error::ErrMode::Backtrack(err) | winnow::error::ErrMode::Cut(err) => err,
331-
winnow::error::ErrMode::Incomplete(_) => unreachable!("we don't have streaming parsers"),
332-
},
333-
}
324+
let err = v.into_inner().expect("we don't have streaming parsers");
325+
Error { inner: err }
334326
}
335327
}
336328

tests/tools/src/lib.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -695,10 +695,7 @@ fn extract_archive(
695695
pub fn to_bstr_err<'i>(
696696
err: winnow::error::ErrMode<VerboseError<&'i [u8], &'static str>>,
697697
) -> VerboseError<&'i BStr, &'static str> {
698-
let err = match err {
699-
winnow::error::ErrMode::Backtrack(err) | winnow::error::ErrMode::Cut(err) => err,
700-
winnow::error::ErrMode::Incomplete(_) => unreachable!("not a streaming parser"),
701-
};
698+
let err = err.into_inner().expect("not a streaming parser");
702699
err.map_input(ByteSlice::as_bstr)
703700
}
704701

0 commit comments

Comments
 (0)