Some #Rust string literal #trivia - the following are equal:
let s = "one line string";
let s = "one line \
string";
And these ones are also equal:
let lines = "a\nmultiline\nstring";
let lines = "a
multiline
string";
and now my favorite... π₯
let lines = "a\n\
multiline\n\
string";
Playground:
https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=a2c5a0e080a4fc56bb9ea8accac22a8b
[#]RustLang #RustTips #Strings
=> More informations about this toot | More toots from janriemer@floss.social
@janriemer
My favorite is close to yours, but slightly different:
let s = "a\ \nmultiline\ \nstring.";
Indention is removed from the resulting string, but putting the \n first on the line makes it possible to add kept indention after the \n.
=> More informations about this toot | More toots from rkaj@mastodon.nu
@rkaj Oh wow, this is even better, indeed! π€―
Thank you! π
=> More informations about this toot | More toots from janriemer@floss.social This content has been proxied by September (3851b).Proxy Information
text/gemini