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

Cleanup Ext + Add utility iterators #6

Merged
merged 6 commits into from
Dec 15, 2014
Merged

Cleanup Ext + Add utility iterators #6

merged 6 commits into from
Dec 15, 2014

Conversation

Gankra
Copy link
Collaborator

@Gankra Gankra commented Dec 14, 2014

Having the methods as default impls prevents repeating signatures, and future-proofs for the possibility of implementation specialization.

Also adds range et al as well as the count adaptor.

/// Return an iterator over the range [start, stop) by `step`. It handles overflow by stopping.
#[inline]
pub fn range_step<A: Int>(start: A, stop: A, step: A) -> RangeStep<A> {
RangeStep{start: start, stop: stop, step: step}
Copy link
Owner

Choose a reason for hiding this comment

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

I prefer RangeStep { .. } with spaces, do you have a strong preference to this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is largely a copy-paste job from the rust-lang, this file has some legacy style. Can clean up.

Copy link
Owner

Choose a reason for hiding this comment

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

Ah, that makes sense.

@reem
Copy link
Owner

reem commented Dec 15, 2014

I'll merge this with the style fixes but after actually thinking about it I realized that there's no reason to split this trait since IntrusiveIterator<T> isn't object-safe anyway.

@Gankra
Copy link
Collaborator Author

Gankra commented Dec 15, 2014

Hmm, good point. Want me to merge them in this PR?

@reem
Copy link
Owner

reem commented Dec 15, 2014

If you're up for it. I'd prefer if all the default definitions go in the trait, but the definitions of those types and their impls go in ext.rs so as not to clutter lib.rs.

@Gankra
Copy link
Collaborator Author

Gankra commented Dec 15, 2014

Ah crap, that doesn't work because the fields are private.

@reem
Copy link
Owner

reem commented Dec 15, 2014

Urgh. I guess the type definitions need to go in lib, but the impls can go in ext.rs.

@Gankra
Copy link
Collaborator Author

Gankra commented Dec 15, 2014

Done

stop: A,
}

impl<A:Copy> Copy for Range<A> {}
Copy link
Owner

Choose a reason for hiding this comment

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

#[deriving(Copy)]?

@reem
Copy link
Owner

reem commented Dec 15, 2014

Just some last nitpicks and ready to go

@Gankra
Copy link
Collaborator Author

Gankra commented Dec 15, 2014

Done.

@reem
Copy link
Owner

reem commented Dec 15, 2014

Alright, ready to go!

reem added a commit that referenced this pull request Dec 15, 2014
Cleanup Ext + Add utility iterators
@reem reem merged commit 816f072 into reem:master Dec 15, 2014
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