-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
token and SliceStream do not play together well #74
Comments
The reason for the That was my reasoning in any case :). As for the lifetime problem, that is not something I had considered actually. I can't think of anyway to make Line 209 in 6a57d7f
satisfy parser instead should work though.
|
Reasoning for |
Clone is a super-type of Copy, so everything that implements Copy already implements Clone. Therefore, this is strictly more general. In addition, .clone() on things that implement Copy should be inlined (to `return *self`) and essentially zero cost. And per Marwes#74 (comment), .clone() already be fast in order for parsing to be fast, so the performance assumptions in the non-Copy case should be similar.
Parser is defined for Token<I> only when I::Item: Clone, so there's no functional loss of generality when we restrict token() to only I::Item: Clone. The cost of .clone() should be negligible. With this, we can use token() with a StreamSlice.
…arwes#74. This test verifies we can use token() with a StreamSlice.
First, thanks for the library. It's a fun way to learn Rust!
I'd like to understand some of the API decisions the library makes. First, my motivating use case is to parse a token stream (not a character stream), and my token's do not implement
Copy
because they includeString
data, like:If I use
SliceStream
, I can parse&[Token]
. However, I can't really usetoken
, because theItem
type ofSliceStream
is&'a Token
and that's not something I can create with the correct lifetime. It seems to me liketoken
should havewhere Item : Clone
and explicitly.clone()
it's argument. I see at https://github.com/Marwes/combine/blob/master/src/combinator.rs#L200 that we can't actually parse withoutItem : Clone
.Is this deliberate? Oversight? Am I using
SliceStream
incorrectly?The text was updated successfully, but these errors were encountered: