-
Notifications
You must be signed in to change notification settings - Fork 117
Support exporting string literals for some languages #259
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
Open
mr-briggs
wants to merge
1
commit into
1Password:main
Choose a base branch
from
mr-briggs:export_string_literals
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,39 @@ | ||
#[typeshare] | ||
pub const MY_VAR: u32 = 12; | ||
pub const MY_INT_VAR: u32 = 12; | ||
|
||
// String literal-related consts below: | ||
|
||
#[typeshare] | ||
pub const EMPTY: &'static str = ""; | ||
|
||
#[typeshare] | ||
pub const SIMPLE_ASCII: &'static str = "Hello, world!"; | ||
|
||
#[typeshare] | ||
pub const MULTILINE: &'static str = "Line1 | ||
Line2 | ||
Line3"; | ||
|
||
#[typeshare] | ||
pub const ESCAPED_CHARACTERS: &'static str = "First\\line.\nSecond \"quoted\" line.\tEnd."; | ||
|
||
#[typeshare] | ||
pub const UNICODE: &'static str = "Emoji: 😄, Accented: café, Chinese: 世界"; | ||
|
||
#[typeshare] | ||
pub const RAW_STRING: &'static str = r#"Raw \n, "quotes" are okay, and single \ is fine too"#; | ||
|
||
#[typeshare] | ||
pub const CONTAINS_BACKTICK: &'static str = "Backtick: ` inside"; | ||
|
||
#[typeshare] | ||
pub const CONTAINS_DOLLAR_CURLY: &'static str = "${not_interpolation}"; | ||
|
||
#[typeshare] | ||
pub const ENDS_WITH_ODD_BACKSLASH: &'static str = r"Odd number of backslashes: \\\"; | ||
|
||
#[typeshare] | ||
pub const NULL_BYTE: &'static str = "Null:\0End"; | ||
|
||
#[typeshare] | ||
pub const COMBINING: &'static str = "e\u{301} vs é"; // normalization check |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,15 @@ | ||
export const MY_VAR: number = 12; | ||
export const MY_INT_VAR: number = 12; | ||
export const EMPTY: string = ``; | ||
export const SIMPLE_ASCII: string = `Hello, world!`; | ||
export const MULTILINE: string = `Line1 | ||
Line2 | ||
Line3`; | ||
export const ESCAPED_CHARACTERS: string = `First\\line. | ||
Second "quoted" line. End.`; | ||
export const UNICODE: string = `Emoji: 😄, Accented: café, Chinese: 世界`; | ||
export const RAW_STRING: string = String.raw`Raw \n, "quotes" are okay, and single \ is fine too`; | ||
export const CONTAINS_BACKTICK: string = `Backtick: \` inside`; | ||
export const CONTAINS_DOLLAR_CURLY: string = `\${not_interpolation}`; | ||
export const ENDS_WITH_ODD_BACKSLASH: string = String.raw`Odd number of backslashes: \\` + '\\'; | ||
export const NULL_BYTE: string = `Null:\u0000End`; | ||
export const COMBINING: string = `é vs é`; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the original Rust string, these two accented characters are encoded differently (one as a combining accent). That's still the case here, but we've output the raw characters instead of escaped unicode, which makes them look the same here.
I think ideally, we'd export escaped unicode as-is (e.g. have
const Combining string = "e\u0301 vs é"
), but I wasn't sure how to achieve that.