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

SmallBitVec::range method (alternative to impl Index<Range<usize>>) #11

Merged
merged 4 commits into from
Apr 17, 2018
Merged

SmallBitVec::range method (alternative to impl Index<Range<usize>>) #11

merged 4 commits into from
Apr 17, 2018

Conversation

dbkaplun
Copy link
Contributor

No description provided.

Copy link
Collaborator

@mbrubeck mbrubeck left a comment

Choose a reason for hiding this comment

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

Looks good! One suggested change, below:

src/lib.rs Outdated

#[inline]
fn index(&self, i: usize) -> &bool {
&self.vec[i + self.range.start]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Perhaps this should panic when i + start >= end

src/lib.rs Outdated
/// assert_eq!(r[1], true);
/// ```
pub fn range(&self, range: Range<usize>) -> VecRange {
VecRange { vec: &self, range }
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should panic if either end of the range is greater than self.len().

@dbkaplun
Copy link
Contributor Author

@mbrubeck ready for review

@mbrubeck mbrubeck merged commit 5933346 into servo:master Apr 17, 2018
@dbkaplun dbkaplun deleted the vec-methods-range branch April 17, 2018 23:38
mbrubeck added a commit that referenced this pull request Apr 17, 2018
* Added `range` method for slicing a vector by a range of indices (#11)
* Some code cleanup and testing improvements
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.

2 participants