我想要像下面这样的双重休息:
[ your title there ]
some kind of content...
在 rust 中,有两个宏可以打印到标准输入,一个有 like 中断,另一个没有 like 中断。 以及一些可能打印的代码,如下所示:
// use println! only for consistency.
println!("[ your title here ]\n"); // i find it awkward because prinln! already has some sort of '\n' in it.
println!("some kind of content...");
或
// use print! only for consistency.
// but still find it awkward because println! is usually used for single like break
// and this section of code may be the only place where print! is used to print single like break.
print!("[ your title here ]\n\n");
print!("some kind of content...\n");
有没有更好的方法在 Rust 中打印双或更多换行符? 或者其他语言将不带 like 中断的 print 和带单个 like 中断的打印作为单独的函数,如 C#、Java、...等?
怎么样
println!("[ your title here ]");
println!();
println!("some kind of content...");
您的代码具有与结果输出相同的布局和换行符数量,这使得换行符所在位置一目了然。