Hi,
I have several "\n" in a string, but when I output it, the \n gets outputted, and doesn't go to the next line.
For example:
message += "\n\n\n\n_Unused instances. If you need to start a new instance, consider using one of these types:_\n";
Gives me the output:
\n\n\n\n\n\n\n_Unused instances. If you need to start a new instance, consider using one of these types:_\n
This is just one part of the "message" string. My code essentially parses a JSON file and adds relevant information to "message". There are several \n's throughout the string, but none of them cause line breaks.
Any help would be greatly appreciated. Thanks for your time.
How are you printing the string? A full runnable example will let us see exactly what's going on.
For example, this program prints the newlines correctly:
fn main() {
let mut message = String::new();
message += "\n\n\n\n_Unused instances. If you need to start a new instance, consider using one of these types:_\n";
println!("{}", message);
}
Output:
_Unused instances. If you need to start a new instance, consider using one of these types:_