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

ConIterOfRange must have trait bound Idx: std::iter::Step #1

Open
orxfun opened this issue Apr 3, 2024 · 0 comments
Open

ConIterOfRange must have trait bound Idx: std::iter::Step #1

orxfun opened this issue Apr 3, 2024 · 0 comments

Comments

@orxfun
Copy link
Owner

orxfun commented Apr 3, 2024

Currently, we cannot use this directly because the Step trait is unstable. The issue can be tracked here: rust-lang/rust#42168

This causes adding manual and very noisy trait bounds:

where
    Idx: Send
        + Sync
        + Clone
        + Copy
        + From<usize>
        + Into<usize>
        + Add<Idx, Output = Idx>
        + Sub<Idx, Output = Idx>
        + Ord,

which could simply be replaced by

where
    Idx: Send + Sync + Step

A bigger problem is the implementation of the fetch_n method which even affects the type of the returned iterator.

  • If we could use Idx: Step trait bound, we could have simply returned begin_value..end_value.
  • However, now we need to return (begin_idx..end_idx).map(Idx::from)
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

No branches or pull requests

1 participant