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: implement From array trait for BoundedVec #2

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

akonior
Copy link
Collaborator

@akonior akonior commented Apr 25, 2024

Description

Problem*

Implementing a concise, single-line method for converting arrays to BoundedVec would enhance usability.

Summary*

This pull request implements the From trait to enable array-to-BoundedVec conversions, allowing for the following usage

let vec = BoundedVec::from([1, 2, 3]);

instead of:

let vec: BoundedVec<Field, 3> = BoundedVec::new();
vec.extend_from_array([1, 2, 3]);

Additional Context

Documentation*

Check one:

  • No documentation needed.
  • Documentation included in this PR.
  • [For Experimental Features] Documentation to be submitted in a separate PR.

PR Checklist*

  • I have tested the changes locally.
  • I have formatted the changes with Prettier and/or cargo fmt on default settings.

@akonior akonior force-pushed the arek/bounded_vec_from_trait branch from 946191a to 03e204c Compare April 25, 2024 10:15
@akonior akonior changed the title Implement the From trait for array to BoundedVec conversion feat: implement the From trait for array to BoundedVec conversion Apr 25, 2024
@akonior akonior changed the title feat: implement the From trait for array to BoundedVec conversion feat: implement From[T; ArrayLen] trait for BoundedVec Apr 25, 2024
@akonior akonior changed the title feat: implement From[T; ArrayLen] trait for BoundedVec feat: implement From<[T; ArrayLen]> trait for BoundedVec Apr 25, 2024
@akonior akonior changed the title feat: implement From<[T; ArrayLen]> trait for BoundedVec feat: implement From array trait for BoundedVec Apr 25, 2024
@akonior akonior force-pushed the arek/bounded_vec_from_trait branch 5 times, most recently from 70bd2d4 to 9b54ce6 Compare April 25, 2024 13:09
@akonior akonior force-pushed the arek/bounded_vec_from_trait branch from 9b54ce6 to 8a8c2e3 Compare April 25, 2024 13:15
@LogvinovLeon LogvinovLeon marked this pull request as ready for review April 25, 2024 13:33
Copy link

github-actions bot commented May 6, 2024

Thank you for your contribution to the Noir language.

Please do not force push to this branch after the Noir team have started review of this PR. Doing so will only delay us merging your PR as we will need to start the review process from scratch.

Thanks for your understanding.

@akonior akonior added the documentation Improvements or additions to documentation label May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants