Repository navigation
Write string joins as format! in Rust and note them in C - #323
Open
matt-edmondson wants to merge 2 commits into
Open
matt-edmondson wants to merge 2 commits into
matt-edmondson wants to merge 2 commits into
Conversation
Rust implements + only as String + &str, so a literal on the left or a String on the right did not compile; a join of strings is now one format! call. Rust function bodies now open a static type scope so the parameters' and locals' types are known. C has no expression for a join, so the + keeps a note saying why and what to write instead. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018tZnrna9oooMZHDaLyXumk
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018tZnrna9oooMZHDaLyXumk
|
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.



Before: a string join such as
"Hello, " + namecame out as+in Rust and C. Neither compiler accepts it. Rust implements+only asString + &str, so a literal on the left or aStringon the right is rejected (E0369/E0308). C has no operator that joins strings at all.After: in Rust a join of strings is written as a single
format!call, which compiles whichever side holds the literal. In C the+is kept, with a note beside it that says why it cannot compile and what to write instead.How: Rust function bodies now open a static type scope, so the generator knows the types of the parameters and locals and can tell a string join from adding numbers.
StringConcatenationTestscovers both targets.Closes #240
https://claude.ai/code/session_018tZnrna9oooMZHDaLyXumk
Generated by Claude Code