mirror of
https://github.com/crate-ci/typos.git
synced 2024-12-23 16:12:25 -05:00
fix(parser): Ignore items at end of input
This commit is contained in:
parent
7e15afe81f
commit
1720e7d65e
1 changed files with 14 additions and 3 deletions
|
@ -142,6 +142,7 @@ mod parser {
|
||||||
+ nom::Slice<std::ops::RangeTo<usize>>
|
+ nom::Slice<std::ops::RangeTo<usize>>
|
||||||
+ nom::Offset
|
+ nom::Offset
|
||||||
+ Clone
|
+ Clone
|
||||||
|
+ Default
|
||||||
+ PartialEq
|
+ PartialEq
|
||||||
+ std::fmt::Debug,
|
+ std::fmt::Debug,
|
||||||
<T as nom::InputTakeAtPosition>::Item: AsChar + Copy,
|
<T as nom::InputTakeAtPosition>::Item: AsChar + Copy,
|
||||||
|
@ -172,6 +173,7 @@ mod parser {
|
||||||
+ nom::Slice<std::ops::RangeTo<usize>>
|
+ nom::Slice<std::ops::RangeTo<usize>>
|
||||||
+ nom::Offset
|
+ nom::Offset
|
||||||
+ Clone
|
+ Clone
|
||||||
|
+ Default
|
||||||
+ PartialEq
|
+ PartialEq
|
||||||
+ std::fmt::Debug,
|
+ std::fmt::Debug,
|
||||||
<T as nom::InputTakeAtPosition>::Item: AsChar + Copy,
|
<T as nom::InputTakeAtPosition>::Item: AsChar + Copy,
|
||||||
|
@ -198,10 +200,20 @@ mod parser {
|
||||||
|
|
||||||
fn sep1<T>(input: T) -> IResult<T, T>
|
fn sep1<T>(input: T) -> IResult<T, T>
|
||||||
where
|
where
|
||||||
T: nom::InputTakeAtPosition + std::fmt::Debug,
|
T: nom::InputTakeAtPosition
|
||||||
|
+ nom::InputTake
|
||||||
|
+ nom::InputIter
|
||||||
|
+ nom::InputLength
|
||||||
|
+ nom::Slice<std::ops::RangeFrom<usize>>
|
||||||
|
+ nom::Slice<std::ops::RangeTo<usize>>
|
||||||
|
+ nom::Offset
|
||||||
|
+ Clone
|
||||||
|
+ Default
|
||||||
|
+ PartialEq
|
||||||
|
+ std::fmt::Debug,
|
||||||
<T as nom::InputTakeAtPosition>::Item: AsChar + Copy,
|
<T as nom::InputTakeAtPosition>::Item: AsChar + Copy,
|
||||||
{
|
{
|
||||||
take_while1(is_ignore_char)(input)
|
alt((take_while1(is_ignore_char), map(eof, |_| T::default())))(input)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn other<T>(input: T) -> IResult<T, T>
|
fn other<T>(input: T) -> IResult<T, T>
|
||||||
|
@ -1159,7 +1171,6 @@ mod test {
|
||||||
Identifier::new_unchecked("c7087fe00d2ba919df1d813c040a5d47e43b0fe7", Case::None, 35), // BUG: This shouldn't be here
|
Identifier::new_unchecked("c7087fe00d2ba919df1d813c040a5d47e43b0fe7", Case::None, 35), // BUG: This shouldn't be here
|
||||||
Identifier::new_unchecked("src", Case::None, 77),
|
Identifier::new_unchecked("src", Case::None, 77),
|
||||||
Identifier::new_unchecked("rs", Case::None, 91),
|
Identifier::new_unchecked("rs", Case::None, 91),
|
||||||
Identifier::new_unchecked("51", Case::None, 94),
|
|
||||||
];
|
];
|
||||||
let actual: Vec<_> = parser.parse_bytes(input.as_bytes()).collect();
|
let actual: Vec<_> = parser.parse_bytes(input.as_bytes()).collect();
|
||||||
assert_eq!(expected, actual);
|
assert_eq!(expected, actual);
|
||||||
|
|
Loading…
Reference in a new issue