在Rust中实现两个或多个换行符的更好实践?[关闭]

2q5ifsrm  于 11个月前  发布在  其他
关注(0)|答案(1)|浏览(72)

已关闭。此问题为opinion-based。目前不接受回答。
**要改进此问题吗?**更新此问题,以便editing this post可以使用事实和引文来回答。

2天前关闭。
Improve this question
我想要像下面这样的双休息:

[ your title there ]

some kind of content...

字符串
在rust中,有两个宏要打印到stdin,一个有like break,一个没有like break。下面是一些可能的代码打印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中打印双行或多行换行符?或者其他语言,如C#,Java,.等,将不带like break的打印和带单个like break的打印作为单独的函数?

utugiqy6

utugiqy61#

怎么样

println!("[ your title here ]");
println!();
println!("some kind of content...");

字符串
您的程式码与产生的输出具有相同的版面配置和分行符号数目,这让您一眼就能看出分行符号的位置。

相关问题