Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/stream/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@ where

impl<'a, T> Positioned for &'a [T]
where
T: Clone + PartialEq,
T: Clone,
{
#[inline]
fn position(&self) -> Self::Position {
Expand All @@ -712,7 +712,7 @@ where

impl<'a, T> StreamOnce for &'a [T]
where
T: Clone + PartialEq,
T: Clone,
{
type Token = T;
type Range = &'a [T];
Expand Down Expand Up @@ -1020,7 +1020,7 @@ impl<'a, T> Clone for SliceStream<'a, T> {

impl<'a, T> Positioned for SliceStream<'a, T>
where
T: PartialEq + 'a,
T: 'a,
{
#[inline]
fn position(&self) -> Self::Position {
Expand All @@ -1030,7 +1030,7 @@ where

impl<'a, T> StreamOnce for SliceStream<'a, T>
where
T: PartialEq + 'a,
T: 'a,
{
type Token = &'a T;
type Range = &'a [T];
Expand Down
31 changes: 29 additions & 2 deletions tests/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ use combine::{
error::unexpected,
range::{self, range},
repeat::{count, count_min_max, many, sep_by, sep_end_by1, skip_until, take_until},
token::{any, eof, position, token, value, Token},
token::{any, eof, position, token, tokens, value, Token},
},
EasyParser, Parser,
stream::SliceStream,
EasyParser, Parser, Stream,
};

#[test]
Expand Down Expand Up @@ -667,4 +668,30 @@ mod tests_std {
Err(vec![]),
);
}

#[test]
fn test_no_eq() {
#[derive(Clone)]
struct NoEq;

let input: &[NoEq] = &[NoEq];

fn parse(stream: impl Stream) {
assert!(any().and(eof()).parse(stream).is_ok());
}

// Verify impl of Stream for &[T] does not require PartialEq.
parse(input);

// Verify impl of Stream for SliceStream<T> does not require PartialEq.
parse(SliceStream(input));

// Verify impl of Stream for &mut T does not require PartialEq.
parse(&mut SliceStream(input));

// Verify tokens() does not require PartialEq.
tokens(|_item, _token| true, "dummy ErrorInfo", vec![NoEq])
.parse(input)
.expect("parse succeeded");
}
}