-
-
Notifications
You must be signed in to change notification settings - Fork 9
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
feat: Add the Skip
higher-order stream
#72
Conversation
777134d
to
bc8cadb
Compare
@@ -0,0 +1,2 @@ | |||
[default.extend-words] | |||
skeep = "skeep" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not finding this word in a dictionary, what's going on here? ^^
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hehe, it's skip
but I don't to use the same name as skip
to highlight it does a difference thing. If you don't like that, I can fallback to skip
, not a big deal after all. If you check the Skeep
trait and its implementation, you'll notice that the skeep
method on the Vector
implementation tries to be smart than the Vector::skip
method to avoid useless clones or splits.
bc8cadb
to
c4bf107
Compare
c4bf107
to
23104ae
Compare
(rebased on top of |
fn skeep(self, count: usize) -> Self { | ||
match count { | ||
// Skip 0 values, let's return all of them. | ||
0 => self, | ||
|
||
// Skip more values than `self` contains, let's return an empty `Vector`. | ||
count if count >= self.len() => Vector::new(), | ||
|
||
// Skip the first n values. | ||
count => self.skip(count), | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not submit a PR to imbl to make the upstream skip
more efficient like this? It even has a fixme in there about making it more efficient.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's do it then 🙂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
jneem/imbl#104 PR is here
Oh you merged it anyway? I'll open a follow-up PR as soon as |
Yeah, I saw that it's a private API anyways. I figured it might take a while until imbl releases a new version with that improvement. |
This patch adds the
Skip
higher-order stream. Similarly toHead
orTail
, it computes a limited view of the underlyingObservableVector
's items. The view starts after count number of values are skipped, until the end. It must not be confused withTail
whereTail
keeps the last values, whileSkip
skips the first values.Tail
higher-order stream #69.