Skip to content
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

Implement append and split_off for BitSet (RFC 509) #24934

Merged
merged 1 commit into from
May 11, 2015

Conversation

jooert
Copy link
Contributor

@jooert jooert commented Apr 29, 2015

cc #19986

@rust-highfive
Copy link
Collaborator

r? @brson

(rust_highfive has picked a reviewer for you, use r? to override)

@jooert
Copy link
Contributor Author

jooert commented Apr 29, 2015

Oh, I completely forgot: @gankro, you're probably the best to review this as well.
r? @gankro

@rust-highfive rust-highfive assigned Gankra and unassigned brson Apr 29, 2015
@jooert jooert force-pushed the bitset-append-split_off branch from f3667ec to 9b69d47 Compare May 8, 2015 11:04
@jooert
Copy link
Contributor Author

jooert commented May 8, 2015

Renamed the feature gate using the same scheme as in #24890.

@Gankra
Copy link
Contributor

Gankra commented May 8, 2015

Woah! I totally missed this. Thanks for the reminder!

if at == 0 {
swap(self, &mut other);
return other;
} else if at > self.bit_vec.len() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same issue as the other PR; this should be a panic. == has this behaviour, though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought a set is more like a map than a vector and VecMap doesn't panic either if at is behind the last element.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean, we also don't panic if you try to access a non-existant element of a set -- it's just not there. But I don't know what semantics we want here so I'm fine with both.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, good point! This check should still be >=?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's right!

@Gankra
Copy link
Contributor

Gankra commented May 8, 2015

review done

@jooert jooert force-pushed the bitset-append-split_off branch from 9b69d47 to ef2e116 Compare May 8, 2015 22:11
@jooert
Copy link
Contributor Author

jooert commented May 8, 2015

Addressed your comments up to the behaviour of split_off if at is behind the last element.

// Pad `other` with `w` zero blocks,
// append `self`'s blocks in the range from `w` to the end to `other`
other.bit_vec.storage.extend(repeat(0u32).take(w)
.chain(self.bit_vec.storage[w..].iter().map(|&el| el)));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this map can be replaced with .cloned().

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, great, this map seemed rather odd when I was writing it.

@jooert jooert force-pushed the bitset-append-split_off branch from ef2e116 to f95c812 Compare May 10, 2015 19:47
@jooert
Copy link
Contributor Author

jooert commented May 10, 2015

I fixed the last remaining points, thanks for your review again!

@Gankra
Copy link
Contributor

Gankra commented May 10, 2015

@bors r+

Thanks!

@bors
Copy link
Contributor

bors commented May 10, 2015

📌 Commit f95c812 has been approved by Gankro

@bors
Copy link
Contributor

bors commented May 10, 2015

⌛ Testing commit f95c812 with merge fc83c55...

@bors
Copy link
Contributor

bors commented May 10, 2015

⛄ The build was interrupted to prioritize another pull request.

@bors
Copy link
Contributor

bors commented May 10, 2015

⌛ Testing commit f95c812 with merge 895ff4f...

@bors
Copy link
Contributor

bors commented May 10, 2015

⛄ The build was interrupted to prioritize another pull request.

@bors
Copy link
Contributor

bors commented May 10, 2015

⌛ Testing commit f95c812 with merge 3d425b5...

@bors
Copy link
Contributor

bors commented May 10, 2015

⛄ The build was interrupted to prioritize another pull request.

@bors
Copy link
Contributor

bors commented May 11, 2015

⌛ Testing commit f95c812 with merge bef0b4b...

@bors bors merged commit f95c812 into rust-lang:master May 11, 2015
@jooert jooert deleted the bitset-append-split_off branch May 11, 2015 09:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants