Last active
September 21, 2023 01:12
-
-
Save dimitrilw/1d16ac515463b7b82e36943024020b17 to your computer and use it in GitHub Desktop.
Rust multiline string abuse
This file contains 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
fn main() { | |
println!( | |
"{}", | |
" this is a test of multi-line string, with indents removed\n\ | |
AND also of using an invisible char (\\u{200b}) to anchor\n\ | |
the start of text, which allows an indented bullet-list\n\ | |
\u{200b} - this is a zero-width space\n\ | |
\u{200b} - this should be indented 4\n\ | |
".trim(), | |
); | |
println!( | |
"{}", | |
" this is a test of using multi-line string with *just* backslash\n\ | |
in order to take really long single lines & spread across multiple\n\ | |
lines in the code, but not in the output\n\ | |
\n\ | |
https://some-super-long-url.com/that-is-very-long-and-will-cause-the-line-to-wrap/\ | |
and-is-just-really-unsightly-and-absurdly-long/\ | |
which-is-why-i-am-using-a-multi-line-string/\ | |
even-if-some-URL-lib-might-be-better/\ | |
but-also-there-are-non-URL-uses-for-this/\ | |
such-as-when-you-just-have-a-really-long-string/\ | |
".trim(), | |
); | |
} | |
/* output: | |
this is a test of multi-line string, with indents removed | |
AND also of using an invisible char (\u{200b}) to anchor | |
the start of text, which allows an indented bullet-list | |
- this is a zero-width space | |
- this should be indented 4 | |
this is a test of using multi-line string with *just* backslash | |
in order to take really long single lines & spread across multiple | |
lines in the code, but not in the output | |
https://some-super-long-url.com/that-is-very-long-and-will-cause-the-line-to-wrap/and-is-just-really-unsightly-and-absurdly-long/which-is-why-i-am-using-a-multi-line-string/even-if-some-URL-lib-might-be-better/but-also-there-are-non-URL-uses-for-this/such-as-when-you-just-have-a-really-long-string/ | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment