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

Add range methods to Channel and Buf #28

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

Be-ing
Copy link
Contributor

@Be-ing Be-ing commented Dec 11, 2022

on top of #13 because I'm tired of rebasing

@Be-ing Be-ing marked this pull request as draft December 11, 2022 19:04
}

// TODO: fix macro
// iterators!(range: core::ops::Range<usize> => self.range(range.clone(());
Copy link
Contributor Author

@Be-ing Be-ing Dec 11, 2022

Choose a reason for hiding this comment

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

If you can suggest how to get the macro to accept the range.clone(), that would allow getting rid of the boilerplate below.

Comment on lines +370 to +374
fn range(self, range: impl core::ops::RangeBounds<usize>) -> Self {
// Hack around trait method taking `self` rather than `mut self`.
// This method returns a Self by value, so it is okay to move self
// into a mut variable.
let mut new = self;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alternatively the trait method could take mut self, but I wanted to keep the signature consistent with the skip/tail/limit methods.

@Be-ing
Copy link
Contributor Author

Be-ing commented Dec 11, 2022

Rubato uses slice ranges a lot, so this is very helpful for refactoring Rubato.

@udoprog udoprog changed the title add range methods to Channel and Buf Add range methods to Channel and Buf Dec 12, 2022
@udoprog udoprog added the enhancement New feature or request label Dec 12, 2022
@udoprog
Copy link
Owner

udoprog commented Dec 12, 2022

Rebased by cherry-picking the range. Will review later*.

@Be-ing Be-ing marked this pull request as ready for review December 12, 2022 14:55
@Be-ing
Copy link
Contributor Author

Be-ing commented Jan 5, 2023

Will review later*.

ping

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants