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(stdlib): Implement str as_bytes and into_bytes function #2298

Merged
merged 9 commits into from
Aug 15, 2023

Conversation

Ethan-000
Copy link
Contributor

@Ethan-000 Ethan-000 commented Aug 12, 2023

Description

Problem*

Resolves #2138

Summary*

use dep::std;
fn main() {
    let a = "hello";
    let b = a.as_bytes();
    assert(b[0]==104);
    assert(b[1]==101);
    assert(b[2]==108);
    assert(b[3]==108);
    assert(b[4]==111);
    let mut c = a.into_bytes();
    assert(c.get(0)==104);
    assert(c.get(1)==101);
    assert(c.get(2)==108);
    assert(c.get(3)==108);
    assert(c.get(4)==111);
}

Documentation

  • This PR requires documentation updates when merged.

    • I will submit a noir-lang/docs PR.
    • I will request for and support Dev Rel's help in documenting this PR.

Additional Context

PR Checklist*

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

@Ethan-000 Ethan-000 changed the title feat(stdlib): Implement str as_bytes function feat(stdlib): Implement str as_bytes and into_bytes function Aug 12, 2023
noir_stdlib/src/string.nr Outdated Show resolved Hide resolved
Ethan-000 and others added 3 commits August 14, 2023 20:50
@vezenovm
Copy link
Contributor

Once @jfecher comments are resolved this looks good

noir_stdlib/src/string.nr Outdated Show resolved Hide resolved
noir_stdlib/src/string.nr Outdated Show resolved Hide resolved
Ethan-000 and others added 2 commits August 15, 2023 16:09
Co-authored-by: jfecher <jake@aztecprotocol.com>
Co-authored-by: jfecher <jake@aztecprotocol.com>
@jfecher jfecher added this pull request to the merge queue Aug 15, 2023
Merged via the queue into master with commit 92549d4 Aug 15, 2023
15 checks passed
@jfecher jfecher deleted the e/string_to_byte branch August 15, 2023 19:52
TomAFrench added a commit that referenced this pull request Aug 15, 2023
* master:
  feat: Improved error message for unexpected return type (#2302)
  feat(stdlib): Implement `str` `as_bytes` and `into_bytes` function (#2298)
  chore(ci): automatically convert changelog entries to sentence case (#2325)
TomAFrench added a commit that referenced this pull request Aug 16, 2023
* master: (34 commits)
  chore: move orphaned integration tests to new directory (#2331)
  chore(noir): Release 0.10.1 (#2328)
  feat(ssa): Switch mem2reg pass to be per function rather than per block (#2243)
  feat(ssa): Perform dead instruction elimination on intrinsic functions (#2276)
  feat: Add full call stacks to runtime errors (#2310)
  chore(ci): fix mismatched input name to publish workflow (#2327)
  chore: add README for integration test structure (#2277)
  feat: Improved error message for unexpected return type (#2302)
  feat(stdlib): Implement `str` `as_bytes` and `into_bytes` function (#2298)
  chore(ci): automatically convert changelog entries to sentence case (#2325)
  chore(noir): Release 0.10.0 (#2039)
  fix(lsp): Ensure lsp does not crawl past the root specified (#2322)
  fix: Prevent panic when passing relative paths to `--program-dir` (#2324)
  fix: Overflowing assignment will result in an error (#2321)
  chore: clippy fixes (#2320)
  chore: Parameterize the build mode for noir-wasm (#2317)
  chore: Make `wasm` tests pull from `result` directory (#2319)
  chore: Fix typo (#2315)
  chore: Reuse workspace target directory in wasm build script (#2312)
  feat(nargo): Add `--workspace` flag to run commands in every package (#2313)
  ...
TomAFrench added a commit that referenced this pull request Aug 17, 2023
* master: (25 commits)
  chore: update noir-source-resolver from `1.1.2` to `^1.1.3` (#2349)
  chore(ci): Avoid writing to cache in workflows triggered by the merge queue (#2341)
  chore(noir): Release 0.10.3 (#2344)
  feat(lsp): Add `Execute` code lens for `main` functions (#2330)
  feat(lsp): Add `Compile` code lens for `main` function and contracts (#2309)
  feat: Allow calling higher-order functions with closures (#2335)
  fix: Display warning if last expression of block is unused (#2314)
  chore(noir): Release 0.10.2 (#2343)
  fix: Prevent dead instruction elimination of brillig functions which may contain side-effects (#2340)
  chore: Separate integration tests for contracts and programs (#2339)
  chore: move orphaned integration tests to new directory (#2331)
  chore(noir): Release 0.10.1 (#2328)
  feat(ssa): Switch mem2reg pass to be per function rather than per block (#2243)
  feat(ssa): Perform dead instruction elimination on intrinsic functions (#2276)
  feat: Add full call stacks to runtime errors (#2310)
  chore(ci): fix mismatched input name to publish workflow (#2327)
  chore: add README for integration test structure (#2277)
  feat: Improved error message for unexpected return type (#2302)
  feat(stdlib): Implement `str` `as_bytes` and `into_bytes` function (#2298)
  chore(ci): automatically convert changelog entries to sentence case (#2325)
  ...
@tsujp
Copy link
Contributor

tsujp commented Aug 20, 2023

The documentation in the release notes, PR title, and PR body here are incorrect. There is no method into_bytes(); rather there is as_bytes() and as_bytes_vec().

https://github.com/noir-lang/noir/blob/92549d432470244ff7e8581fbe02c744c88942d9/noir_stdlib/src/string.nr

@Ethan-000
Copy link
Contributor Author

ah forgot to change the pr title after renaming the function

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.

Implement a string to byte-array conversion method
4 participants