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

feat(breaking): make FromIteratorFixed more generic #21

Merged
merged 2 commits into from
Jun 16, 2024

Conversation

Daniel-Aaron-Bloom
Copy link
Contributor

Presently, it's not really possible to express FromIteratorFixed as a generic bound. For example

fn build_cs<C, const N: usize>(vs: Vec<[u64; N]>) -> Vec<C>
where: C: FromIteratorFixed<WHAT_TO_PUT_HERE, N> {
  vs.into_iter().map(|v| v.into_iter_fixed().map(|i| i+10).collect()).collect()
}

This is because the FromIteratorFixed currently locks in the iterator type at the trait level, while all the IteratorFixed functions like map completely hide the type behind impl Iterator.

The solution is to move the iterator type down to the from_iter_fixed method, only preserving the Item type at the trait level. This is also logically correct as the specifics of the iterator type should not restrict implementations of FromIteratorFixed.

This is technically a breaking change, but I don't think it's likely to impact any casual users of this crate, only downstream crates which do things like add implementations of FromIteratorFixed will have to perform minor updates to signatures.

@usbalbin usbalbin merged commit ab7c49d into usbalbin:master Jun 16, 2024
7 checks passed
@usbalbin
Copy link
Owner

Thank you! :) 🎉

@usbalbin usbalbin mentioned this pull request Jun 16, 2024
usbalbin added a commit that referenced this pull request Jun 16, 2024
 ## Breaking
* #21 -feat(breaking): make FromIteratorFixed more generic
  Update `FromIteratorFixed` trait to avoid
  unnameable iterator type as type paramater in the trait

 ## Other changes

* #22 - Some cleaning from additional clippy lints
* #20 - fix: nightly flags and clippy warnings

 ## Thank you
* @Daniel-Aaron-Bloom
* @gwen-lg
@Daniel-Aaron-Bloom Daniel-Aaron-Bloom deleted the better-from branch June 17, 2024 17:00
usbalbin added a commit that referenced this pull request Jun 23, 2024
 ## Breaking
* #21 -feat(breaking): make FromIteratorFixed more generic
  Update `FromIteratorFixed` trait to avoid
  unnameable iterator type as type paramater in the trait

 ## Other changes

* #22 - Some cleaning from additional clippy lints
* #20 - fix: nightly flags and clippy warnings
* #24 - Migrate to use cargo readme
* #25 - Use cargo readme in ci

 ## Thank you
* @Daniel-Aaron-Bloom
* @gwen-lg
usbalbin added a commit that referenced this pull request Jun 23, 2024
 ## Breaking
* #21 -feat(breaking): make FromIteratorFixed more generic
  Update `FromIteratorFixed` trait to avoid
  unnameable iterator type as type paramater in the trait

 ## Other changes

* #22 - Some cleaning from additional clippy lints
* #20 - fix: nightly flags and clippy warnings
* #24 - Migrate to use cargo readme
* #25 - Use cargo readme in ci

 ## Thank you
* @Daniel-Aaron-Bloom
* @gwen-lg
usbalbin added a commit that referenced this pull request Jun 23, 2024
 ## Breaking
* #21 -feat(breaking): make FromIteratorFixed more generic
  Update `FromIteratorFixed` trait to avoid
  unnameable iterator type as type paramater in the trait

 ## Other changes

* #22 - Some cleaning from additional clippy lints
* #20 - fix: nightly flags and clippy warnings
* #24 - Migrate to use cargo readme
* #25 - Use cargo readme in ci

 ## Thank you
* @Daniel-Aaron-Bloom
* @gwen-lg
usbalbin added a commit that referenced this pull request Jun 23, 2024
## Breaking
* #21 -feat(breaking): make FromIteratorFixed more generic
  Update `FromIteratorFixed` trait to avoid
  unnameable iterator type as type paramater in the trait

## Other changes

* #22 - Some cleaning from additional clippy lints
* #20 - fix: nightly flags and clippy warnings
* #24 - Migrate to use cargo readme
* #25 - Use cargo readme in ci

## Thank you
* @Daniel-Aaron-Bloom
* @gwen-lg
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