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

Casting bytes array to str #3963

Closed
TomAFrench opened this issue Jan 5, 2024 · 0 comments
Closed

Casting bytes array to str #3963

TomAFrench opened this issue Jan 5, 2024 · 0 comments
Assignees
Milestone

Comments

@TomAFrench
Copy link
Member

Discussed in https://github.com/orgs/noir-lang/discussions/3962

Originally posted by LHerskind January 5, 2024

Problem

It is currently supported to go from str<n> to [u8; n] but not the other way around.

For anything string-based it would be useful to allow going back to str to not confuse it with bytes.

This is particularly useful for contracts where we wish to return a string, but have a compressed variant stored. Casting to str would allow us to have the decoder know that it is a string returned and not just bytes

Happy Case

fn convert_to_str(byts: [u8; N]) -> str<N> {
    str::from_bytes(byts)
}

Alternatives Considered

No response

Additional Context

No response

Would you like to submit a PR for this Issue?

No

Support Needs

No response

@github-project-automation github-project-automation bot moved this to 📋 Backlog in Noir Jan 5, 2024
AztecBot pushed a commit that referenced this issue Jan 12, 2024
A bunch of the tests in rust are broken as the trait implementations for
the EC operations were removed
@kevaundray kevaundray added this to the 1.0 milestone Jan 15, 2024
@kevaundray kevaundray mentioned this issue Jan 15, 2024
2 tasks
@TomAFrench TomAFrench self-assigned this Jan 20, 2024
@github-project-automation github-project-automation bot moved this from 📋 Backlog to ✅ Done in Noir Oct 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

No branches or pull requests

2 participants