Short Question: How can i escape in the format macro? Standard-Escaping don't functioned like " \n.
The Standard Book says i should use {{ or }} to escape { or } but i want double quotes or cariage returns escpaed in an format macro? How does this functioned? Thx.
Can you post the code that doesn't work? C-style escaping in strings should work fine:
fn main() {
let message = format!("hello\nworld!");
println!("{}", message);
}
prints
hello
world!
@cbiffle yes this don't functioned:
format!("{} - \"{}\"","Test","Test with Double Quotes")
What do you want that to write? That code compiles, and it writes:
Test - "Test with Double Quotes"
@ExpHP and @cbiffle
Sorry my fault, i have outputted with debug and give the debugged variable to another function: format("{:?}","this must be quotes")
and the function received and debugged string. My old fault but there in a strange condition, no println ("ahhh whats that for an string, An debug string"), therefore an format! ("äh why he puts espaced characters, when i use not an debug function.). Smile sorry:).
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.