Rust تا كۆپ ئىشلىتىلىدىغان print بۇيرۇق شەكىللىرى
بەزى كودلارنىڭ ئىجرا بولغاندىكى نەتىجىسى بار، بەزىلىرىنىڭ يوق بولاپ قالدى. قىزىققۇچىلار https://play.rust-lang.org/ گە كىرىپ كودنى ئىجرا قىلىپ كۆرۈپ باقساڭلا بولىدۇ.
print!("hello world"); //打印
println!("Hello World") //打印后换行
print!("\thello\n world"); //t=tab,n=newline
print!("hello, this
is
new
world
!
"); //这样本身就样式打印
print!("{:?}","Debug print"); //调试打印,有些结或者无法打印的变量可以用这个方式打印
print!("{:?}",b"Debug print"); //调试打印,有些结或者无法打印的变量可以用这个方式打印
println!("{:X}",'吉' as u32);
print!("{:#?}","Debug print with format"); //跟上面类似,加上格式化打印
print!("{:b}",138); //打印二进制
print!("{:o}",138); //打印八进制
println!("{:x}", 138); //打印十六进制小写
println!("{:X}", 138); //打印十六进制大写
println!("{:p}", &138); // 打印指针(地址)
println!("I like {0} and {1}, {1} is perfect!", "JavaScript", "Rust"); //重复打印一些变量时很好用
println!("I like {fruit1} and {fruit2}, didnt like {fruit3}", fruit1="apple",fruit2="banana",fruit3="orange");//也可以这样写, 这个比较直观
println!("{:*>10}","hello");//左边填*,打印结果:*****hello
println!("{:*<10}","hello");//右边填*,打印结果: hello*****
println!("{:*^10}","hello");//左填*,打印结果:**hello***
println!("{:-^30}","start");
println!("{: <15}{: >15}","|","|");
println!("{: <15}{: >15}","|","|");
println!("{direction1:-<15}{direction2:->15}",direction1="left",direction2="right");
//打印结果
------------start-------------
| |
| |
left---------------------right