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: add fmtstr::quoted #6018

Closed
wants to merge 6 commits into from
Closed

feat: add fmtstr::quoted #6018

wants to merge 6 commits into from

Conversation

asterite
Copy link
Collaborator

Description

Problem

Reviving the first commit in #5942

Summary

This adds a way to turn a fmtstr into a Quoted value that holds a string token. Otherwise there's no way to create string tokens by interpolating dymamic (well, at compile-time) values.

This PR also fixes an issue with how string tokens are displayed. Previously they wouldn't include the double quotes, and special characters weren't escaped.

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.

@github-actions github-actions bot added the documentation Improvements or additions to documentation label Sep 12, 2024
Copy link
Contributor

github-actions bot commented Sep 12, 2024

Changes to Brillig bytecode sizes

Generated at commit: 009497b99328d3b27fc3ad717e5dc9c7f8d35157, compared to commit: fc5bb025d7df901050af1d8ad6ebb9283faf641f

There are no changes in circuit sizes

Copy link
Contributor

github-actions bot commented Sep 12, 2024

Copy link
Contributor

FYI @noir-lang/developerrelations on Noir doc changes.

Copy link
Contributor

@jfecher jfecher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quoting & unquoting a format string will already turn it into a regular string so I don't think we need this method.

We could possibly instead add a helper method:

fn as_quoted_str(self) -> Quoted {
    let s = std::meta::unquote!(quote { $self });
    quote { $s }
}

@asterite
Copy link
Collaborator Author

We could possibly instead add a helper method

Would that be a method of fmtstr?

@asterite
Copy link
Collaborator Author

I'll split the "Correctly print string tokens" commit into a separate PR in the meantime...

@asterite asterite closed this Sep 12, 2024
@asterite asterite deleted the ab/fmtstr-quoted branch September 12, 2024 18:23
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