You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'd like to understand some of the API decisions the library makes. Like in #74 , my motivating use case is to parse a token stream (not a character stream), and my tokens do not implement Copy because they include String data, like:
struct Token {
Keyword(String),
...
}
While implementing RangeStream for a newtype wrapping &'a [Token] (like SliceStream but with item type Token rather item type &'a Token), I've run into the following question. Why does uncons_while take an FnMut(Item) rather than FnMut(&Item) at https://github.com/Marwes/combine/blob/master/src/primitives.rs#L562?
In general, the Rust-y pattern seems to be that predicate filters take references to the elements in their containing collection -- but I'm not an experienced Rust user so I'm probably missing something. Any guidance appreciated.
The text was updated successfully, but these errors were encountered:
Summed together both answers in #74 (comment) since it is more or less the same reason.
Thanks for your very useful answer. I think this can just be closed with a link to #44 (comment) which justifies the ergonomics and a link to #74 (comment) which justifies the performance assumptions.
I'd like to understand some of the API decisions the library makes. Like in #74 , my motivating use case is to parse a token stream (not a character stream), and my tokens do not implement
Copy
because they includeString
data, like:While implementing
RangeStream
for a newtype wrapping&'a [Token]
(likeSliceStream
but with item typeToken
rather item type&'a Token
), I've run into the following question. Why doesuncons_while
take anFnMut(Item)
rather thanFnMut(&Item)
at https://github.com/Marwes/combine/blob/master/src/primitives.rs#L562?In general, the Rust-y pattern seems to be that predicate filters take references to the elements in their containing collection -- but I'm not an experienced Rust user so I'm probably missing something. Any guidance appreciated.
The text was updated successfully, but these errors were encountered: